Ticket #4504: test.mos

File test.mos, 1.7 KB (added by Francesco Casella, 5 years ago)
Line 
1loadString("
2model Superheater
3 parameter Integer N = 8 \"Number of finite volumes\";
4 parameter Real M = 500 \"Superheater wall mass\";
5 parameter Real c = 500 \"Wall specific heat\";
6 parameter Real cp = 2000 \"Steam cp\";
7 parameter Real UA = 1200 \"Total heat conductance external fluid\";
8
9 parameter Real Te_des = 1000 \"Design value of the external fluid temperature\";
10 parameter Real Ti_des = 800 \"Design value of the inlet fluid temperature\";
11 parameter Real To_des = 888 \"Design value of the outlet fluid temperature\";
12 parameter Real wv_des = 1.0 \"Design value of the steam mass flow rate\";
13
14 input Real wv \"Steam mass flow rate\";
15 input Real Ti \"Steam inlet temperature\";
16 input Real Te \"External fluid temperature\";
17 output Real To \"Outlet temperature\";
18 Real T[N] \"Volume outlet temperature\";
19 Real Q[N] \"Heat flows entering the volumes\";
20equation
21 M*c/N*der(T[1]) = cp*Ti - cp*T[1] + Q[1];
22 for j in 2:N loop
23 M*c/N*der(T[j]) = wv*cp*T[j-1] - wv*cp*T[j] + Q[j];
24 end for;
25 for j in 1:N loop
26 Q[j] = UA/N*(Te-T[j]);
27 end for;
28 To = T[N];
29initial equation
30 for j in 1:N loop
31 der(T[j]) = 0 \"Steady-state initial conditions\";
32 end for;
33end Superheater;
34");
35
36loadString("
37model TestSuperheater
38 Superheater SH;
39 parameter Real DTi = 1 \"Inlet temperature change\";
40 parameter Real DTe = 1 \"External temperature change\";
41 parameter Real Dwv = SH.wv_des*0.02 \"Steam mass flow rate change\";
42equation
43 SH.Ti = SH.Ti_des + (if time > 1000 then DTi else 0);
44 SH.Te = SH.Te_des + (if time > 2000 then DTe else 0);
45 SH.wv = SH.wv_des + (if time > 0 then Dwv else 0);
46end TestSuperheater;
47");
48
49simulate(TestSuperheater);
50getErrorString()
51