forked from yijianzeng/STEMMUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
h_EQ.m
70 lines (64 loc) · 2.85 KB
/
h_EQ.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
58
59
60
61
62
63
64
65
66
67
68
69
70
function h_EQ
global ARG1 ARG2 ARG3
global MN ML ND NL NN Delt_t RHS T TT h P_gg SAVE Thmrlefc Soilairefc
global C1 C2 C4 C5 C6 C7 C5_a C9
if Thmrlefc && ~Soilairefc
RHS(1)=-C9(1)-C7(1)+(C1(1,1)*h(1)+C1(1,2)*h(2))/Delt_t ...
-(C2(1,1)/Delt_t+C5(1,1))*TT(1)-(C2(1,2)/Delt_t+C5(1,2))*TT(2) ...
+(C2(1,1)/Delt_t)*T(1)+(C2(1,2)/Delt_t)*T(2);
for ML=2:NL
ARG1=C2(ML-1,2)/Delt_t;
ARG2=C2(ML,1)/Delt_t;
ARG3=C2(ML,2)/Delt_t;
RHS(ML)=-C9(ML)-C7(ML)+(C1(ML-1,2)*h(ML-1)+C1(ML,1)*h(ML)+C1(ML,2)*h(ML+1))/Delt_t ...
-(ARG1+C5(ML-1,2))*TT(ML-1)-(ARG2+C5(ML,1))*TT(ML)-(ARG3+C5(ML,2))*TT(ML+1) ...
+ARG1*T(ML-1)+ARG2*T(ML)+ARG3*T(ML+1);
end
RHS(NN)=-C9(NN)-C7(NN)+(C1(NN-1,2)*h(NN-1)+C1(NN,1)*h(NN))/Delt_t ...
-(C2(NN-1,2)/Delt_t+C5(NN-1,2))*TT(NN-1)-(C2(NN,1)/Delt_t+C5(NN,1))*TT(NN) ...
+(C2(NN-1,2)/Delt_t)*T(NN-1)+(C2(NN,1)/Delt_t)*T(NN);
elseif ~Thmrlefc && Soilairefc
RHS(1)=-C9(1)-C7(1)+(C1(1,1)*h(1)+C1(1,2)*h(2))/Del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