1 |
REQUIRE "ivpsystem.a4l"; |
2 |
REQUIRE "johnpye/thermo_types.a4c"; |
3 |
|
4 |
IMPORT "freesteam"; |
5 |
(* IMPORT "johnpye/extpy/extpy"; |
6 |
IMPORT "johnpye/solvernotes"; |
7 |
IMPORT "johnpye/solve"; *) |
8 |
|
9 |
MODEL simple_state; |
10 |
p IS_A pressure; |
11 |
h IS_A specific_enthalpy; |
12 |
T IS_A temperature; |
13 |
s IS_A specific_entropy; |
14 |
iapws97: iapws97_Ts_ph( |
15 |
p, h : INPUT; |
16 |
T, s : OUTPUT |
17 |
); |
18 |
END simple_state; |
19 |
|
20 |
(* |
21 |
Enhanced version of johnpye/thermalequilibrium.a4c. This model uses |
22 |
real steam properties from http://freesteam.sf.net/. You will need to |
23 |
build the freesteam ASCEND hooks. See the freesteam site for instructions. |
24 |
|
25 |
NOTE: set the starting step to 0.1 and the minimum step to 0.01 s, and |
26 |
integrate from 0 to 3000 s. |
27 |
*) |
28 |
ADD NOTES IN thermalequilibrium2; |
29 |
'solver' name {QRSlv} |
30 |
'QRSlv' iterationlimit {50} |
31 |
'QRSlv' singtol {1e-10} |
32 |
(* following are not implemented yet *) |
33 |
'LSODE' minstep {0.01} |
34 |
'LSODE' firststep {0.1} |
35 |
'LSODE' duration {3000} |
36 |
END NOTES; |
37 |
|
38 |
MODEL thermalequilibrium2; |
39 |
S[1..2] IS_A simple_state; |
40 |
m[1..2] IS_A mass; |
41 |
h IS_A heat_transfer_coefficient; |
42 |
A IS_A area; |
43 |
|
44 |
p ALIASES S[1].p; |
45 |
S[2].p = S[1].p; |
46 |
|
47 |
Q IS_A energy_rate; |
48 |
Q = h*A*(S[1].T - S[2].T); (* rate of heat transfer from 1 to 2 *) |
49 |
m[1]*dhdt[1] = -Q; |
50 |
m[2]*dhdt[2] = +Q; |
51 |
|
52 |
dhdt[1..2] IS_A delta_specific_power; |
53 |
|
54 |
t IS_A time; |
55 |
METHODS |
56 |
METHOD specify; |
57 |
FIX h, A, m[1..2], S[1..2].h, p; |
58 |
END specify; |
59 |
METHOD values; |
60 |
A := 1 {m^2}; |
61 |
h := 10 {W/m^2/K}; |
62 |
|
63 |
p := 1 {bar}; |
64 |
|
65 |
m[1] := 2 {kg}; |
66 |
S[1].h := 200 {kJ/kg}; |
67 |
m[2] := 10 {kg}; |
68 |
S[2].h := 3500 {kJ/kg}; |
69 |
END values; |
70 |
METHOD ode_init; |
71 |
FOR i IN [1..2] DO |
72 |
S[i].h.ode_id := i; |
73 |
dhdt[i].ode_id := i; |
74 |
S[i].h.ode_type := 1; |
75 |
dhdt[i].ode_type := 2; |
76 |
END FOR; |
77 |
|
78 |
Q.obs_id := 2; |
79 |
S[1].T.obs_id := 3; |
80 |
S[2].T.obs_id := 4; |
81 |
|
82 |
t.ode_type := -1; |
83 |
t := 0 {s}; |
84 |
END ode_init; |
85 |
METHOD on_load; |
86 |
RUN reset; |
87 |
RUN values; |
88 |
(* EXTERNAL solvernotes(SELF); |
89 |
EXTERNAL solve(SELF); *) |
90 |
RUN ode_init; |
91 |
END on_load; |
92 |
|
93 |
END thermalequilibrium2; |