forked from yijianzeng/STEMMUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
h_MAT.m
57 lines (50 loc) · 2.09 KB
/
h_MAT.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function h_MAT
global C1 C2 C4 C3 C4_a C5 C6 C7 C9 C4ARG1 C4ARG2_1 C4ARG2_2 C5ARG1 C6ARG C7ARG C9ARG1 C9ARG2 Srt
global Chh ChT Khh KhT Kha Vvh VvT Chg DeltZ C5ARG2_1 C5ARG2_2 C5_a
global ML NL NN ND
for MN=1:NN % Clean the space in C1-7 every iteration,otherwise, in *.PARM files,
for ND=1:2 % C1-7 will be mixed up with pre-storaged data, which will cause extremly crazy for computation, which exactly results in NAN.
C1(MN,ND)=0;
C7(MN)=0;
C9(MN)=0; % C9 is the matrix coefficient of root water uptake;
C4(MN,ND)=0;
C4_a(MN)=0;
C5_a(MN)=0;
C2(MN,ND)=0;
C3(MN,ND)=0;
C5(MN,ND)=0;
C6(MN,ND)=0;
end
end
for ML=1:NL
C1(ML,1)=C1(ML,1)+Chh(ML,1)*DeltZ(ML)/2;
C1(ML+1,1)=C1(ML+1,1)+Chh(ML,2)*DeltZ(ML)/2;%
C2(ML,1)=C2(ML,1)+ChT(ML,1)*DeltZ(ML)/2;
C2(ML+1,1)=C2(ML+1,1)+ChT(ML,2)*DeltZ(ML)/2; %
C4ARG1=(Khh(ML,1)+Khh(ML,2))/(2*DeltZ(ML));%sqrt(Khh(ML,1)*Khh(ML,2))/(DeltZ(ML));%
C4ARG2_1=Vvh(ML,1)/3+Vvh(ML,2)/6;
C4ARG2_2=Vvh(ML,1)/6+Vvh(ML,2)/3;
C4(ML,1)=C4(ML,1)+C4ARG1-C4ARG2_1;
C4(ML,2)=C4(ML,2)-C4ARG1-C4ARG2_2;
C4(ML+1,1)=C4(ML+1,1)+C4AR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