-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEnrgy_EQ.m
70 lines (61 loc) · 2.74 KB
/
Enrgy_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 Enrgy_EQ
global ARG1 ARG2 ARG3 ARG4 ARG5 ARG6
global MN ML ND NL NN Delt_t RHS T h hh P_g P_gg SAVE
global C1 C2 C3 C4 C5 C6 C7 Soilairefc C4_a C6_a Thmrlefc
if Soilairefc && Thmrlefc
RHS(1)=-C7(1)+(C2(1,1)*T(1)+C2(1,2)*T(2))/Delt_t ...
-(C1(1,1)/Delt_t+C4(1,1))*hh(1)-(C1(1,2)/Delt_t+C4(1,2))*hh(2) ...
-(C3(1,1)/Delt_t+C6(1,1))*P_gg(1)-(C3(1,2)/Delt_t+C6(1,2))*P_gg(2) ...
+(C3(1,1)/Delt_t)*P_g(1)+(C3(1,2)/Delt_t)*P_g(2) ...
+(C1(1,1)/Delt_t)*h(1)+(C1(1,2)/Delt_t)*h(2);
for ML=2:NL
ARG1=C3(ML-1,2)/Delt_t;
ARG2=C3(ML,1)/Delt_t;
ARG3=C3(ML,2)/Delt_t;
ARG4=C1(ML-1,2)/Delt_t;
ARG5=C1(ML,1)/Delt_t;
ARG6=C1(ML,2)/Delt_t;
RHS(ML)=-C7(ML)+(C2(ML-1,2)*T(ML-1)+C2(ML,1)*T(ML)+C2(ML,2)*T(ML+1))/Delt_t ...
-(ARG1+C6_a(ML-1))*P_gg(ML-1)-(ARG2+C6(ML,1))*P_gg(ML)-(ARG3+C6(ML,2))*P_gg(ML+1) ...
-(ARG4+C4_a(ML-1))*hh(ML-1)-(ARG5+C4(ML,1))*hh(ML)-(ARG6+C4(ML,2))*hh(ML+1) ...
+ARG1*P_g(ML-1)+ARG2*P_g(ML)+AR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