1 |
REQUIRE "ivpsystem.a4l"; |
2 |
REQUIRE "johnpye/thermo_types.a4c"; |
3 |
REQUIRE "johnpye/steam/iapwssat.a4c"; |
4 |
|
5 |
IMPORT "johnpye/extpy/extpy"; |
6 |
IMPORT "johnpye/listnotes"; |
7 |
IMPORT "johnpye/solve"; |
8 |
|
9 |
(* |
10 |
Simplified version of models/johnpye/thermalequilibrium2.a4c. This one uses |
11 |
saturated steam properties only (and is not suitable for cases where |
12 |
properties pass outside those limits). |
13 |
|
14 |
NOTE: set the starting step to 0.1 and the minimum step to 0.01 s, and |
15 |
integrate from 0 to 3000 s. |
16 |
*) |
17 |
ADD NOTES IN thermalequilibrium3; |
18 |
'solver' name {QRSlv} |
19 |
'QRSlv' iterationlimit {50} |
20 |
'QRSlv' singtol {1e-10} |
21 |
(* following are not implemented yet *) |
22 |
'LSODE' minstep {0.01} |
23 |
'LSODE' firststep {0.1} |
24 |
'LSODE' duration {3000} |
25 |
END NOTES; |
26 |
|
27 |
MODEL thermalequilibrium3; |
28 |
S[1..2] IS_A iapwssat; |
29 |
m[1..2] IS_A mass; |
30 |
h IS_A heat_transfer_coefficient; |
31 |
A IS_A area; |
32 |
|
33 |
p ALIASES S[1].p; |
34 |
S[2].p = S[1].p; |
35 |
|
36 |
Q IS_A energy_rate; |
37 |
Q = h*A*(S[1].T - S[2].T); (* rate of heat transfer from 1 to 2 *) |
38 |
m[1]*dhdt[1] = -Q; |
39 |
m[2]*dhdt[2] = +Q; |
40 |
|
41 |
dhdt[1..2] IS_A delta_specific_power; |
42 |
|
43 |
t IS_A time; |
44 |
METHODS |
45 |
METHOD specify; |
46 |
FIX h, A, m[1..2], S[1..2].h, p; |
47 |
END specify; |
48 |
METHOD values; |
49 |
A := 1 {m^2}; |
50 |
h := 10 {W/m^2/K}; |
51 |
|
52 |
p := 1 {bar}; |
53 |
|
54 |
m[1] := 2 {kg}; |
55 |
S[1].h := 1000 {kJ/kg}; |
56 |
m[2] := 10 {kg}; |
57 |
S[2].h := 2000 {kJ/kg}; |
58 |
END values; |
59 |
METHOD ode_init; |
60 |
FOR i IN [1..2] DO |
61 |
S[i].h.ode_id := i; |
62 |
dhdt[i].ode_id := i; |
63 |
S[i].h.ode_type := 1; |
64 |
dhdt[i].ode_type := 2; |
65 |
END FOR; |
66 |
|
67 |
Q.obs_id := 2; |
68 |
S[1].h.obs_id := 3; |
69 |
S[2].h.obs_id := 4; |
70 |
|
71 |
t.ode_type := -1; |
72 |
t := 0 {s}; |
73 |
END ode_init; |
74 |
METHOD on_load; |
75 |
RUN reset; |
76 |
RUN values; |
77 |
EXTERNAL setup_solver(SELF); |
78 |
EXTERNAL solve(SELF); |
79 |
RUN ode_init; |
80 |
END on_load; |
81 |
|
82 |
END thermalequilibrium3; |