1 |
johnpye |
885 |
REQUIRE "ivpsystem.a4l"; |
2 |
|
|
REQUIRE "johnpye/thermo_types.a4c"; |
3 |
|
|
|
4 |
|
|
IMPORT "freesteam"; |
5 |
johnpye |
897 |
IMPORT "johnpye/extpy/extpy"; |
6 |
johnpye |
915 |
IMPORT "johnpye/solvernotes"; |
7 |
johnpye |
910 |
IMPORT "johnpye/solve"; |
8 |
johnpye |
885 |
|
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 |
johnpye |
965 |
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 |
johnpye |
897 |
|
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 |
johnpye |
885 |
*) |
28 |
johnpye |
897 |
ADD NOTES IN thermalequilibrium2; |
29 |
|
|
'solver' name {QRSlv} |
30 |
johnpye |
898 |
'QRSlv' iterationlimit {50} |
31 |
|
|
'QRSlv' singtol {1e-10} |
32 |
johnpye |
903 |
(* following are not implemented yet *) |
33 |
|
|
'LSODE' minstep {0.01} |
34 |
johnpye |
898 |
'LSODE' firststep {0.1} |
35 |
|
|
'LSODE' duration {3000} |
36 |
johnpye |
897 |
END NOTES; |
37 |
|
|
|
38 |
johnpye |
885 |
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 |
johnpye |
910 |
METHOD specify; |
57 |
johnpye |
885 |
FIX h, A, m[1..2], S[1..2].h, p; |
58 |
johnpye |
910 |
END specify; |
59 |
|
|
METHOD values; |
60 |
johnpye |
885 |
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 |
johnpye |
897 |
S[2].h := 3500 {kJ/kg}; |
69 |
johnpye |
910 |
END values; |
70 |
|
|
METHOD ode_init; |
71 |
johnpye |
885 |
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 |
johnpye |
897 |
|
82 |
|
|
t.ode_type := -1; |
83 |
|
|
t := 0 {s}; |
84 |
johnpye |
910 |
END ode_init; |
85 |
|
|
METHOD on_load; |
86 |
johnpye |
915 |
EXTERNAL solve(SELF); |
87 |
johnpye |
910 |
RUN reset; |
88 |
|
|
RUN values; |
89 |
johnpye |
915 |
EXTERNAL solvernotes(SELF); |
90 |
johnpye |
910 |
EXTERNAL solve(SELF); |
91 |
|
|
RUN ode_init; |
92 |
johnpye |
885 |
END on_load; |
93 |
|
|
|
94 |
|
|
END thermalequilibrium2; |
95 |
|
|
|