/[ascend]/branches/ksenija2/models/johnpye/solardynamics_simple.a4c
ViewVC logotype

Contents of /branches/ksenija2/models/johnpye/solardynamics_simple.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2869 - (show annotations) (download) (as text)
Tue Mar 24 13:25:23 2015 UTC (7 years, 3 months ago) by jpye
File MIME type: text/x-ascend
File size: 2854 byte(s)
add debug output of QRSlv vars are rels list (active,included etc) to idaboundary.c.
change solardynamics model for minimum-size boundary NLA problem. now it doesn't work.
some pointless tinkering with formatting.

1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3 REQUIRE "johnpye/thermo_types.a4c";
4
5 (* stripped-back version of 'solardynamics' with just enough detail to
6 provide the same switching behaviour, hopefully.
7
8 For 'sun' above 800 W, we charge the storage.
9 For 'sun' below 500 W, we ignore it.
10
11 For tank temperature above 200 K, we discharge the storage
12 For tank temperature below 150, we don't discharge.
13
14 *)
15 MODEL solardynamics_simple;
16 t IS_A time;
17 INDEPENDENT t;
18
19 E "stored energy" IS_A energy;
20 Qdot_in,Qdot_out IS_A energy_rate;
21 C "concentration ratio" IS_A factor;
22
23 (* sinusoidal 'sunlight' gives us up to 1000 W *)
24 qin_eq: Qdot_in = 1000 {W} * 0.5*(1 - cos(t * 2{PI}/1{d}));
25
26 cp IS_A specific_heat_capacity;
27 T, T_0 IS_A temperature;
28 m IS_A mass;
29 en_eq: E = m * cp * (T - T_0);
30
31 DERIVATIVE OF E;
32 dyn_eq: der(E) = C*Qdot_in - Qdot_out;
33
34 c1: C = 1;
35 c0: C = 0;
36 p1: Qdot_out = 2000 {W};
37 p0: Qdot_out = 0 {MW};
38 CONDITIONAL
39 c_c1: Qdot_in > 500 {W};
40 c_c0: Qdot_in < 300 {W};
41 c_p1: T > 200 {K};
42 c_p0: T < 150 {K};
43 END CONDITIONAL;
44 b_c1, b_c0, b_p1, b_p0 IS_A boolean_var;
45 b_c1 == SATISFIED(c_c1);b_c0 == SATISFIED(c_c0);
46 b_p1 == SATISFIED(c_p1);b_p0 == SATISFIED(c_p0);
47 e_c1:EVENT(b_c1) CASE TRUE: USE c1; END EVENT;
48 e_c0:EVENT(b_c0) CASE TRUE: USE c0; END EVENT;
49 e_p1:EVENT(b_p1) CASE TRUE: USE p1; END EVENT;
50 e_p0:EVENT(b_p0) CASE TRUE: USE p0; END EVENT;
51 METHODS
52 METHOD on_load;
53 FIX T_0 := 180 {K};
54 T := 200 {K};
55 E := 40 {MJ};
56 FIX C := 0;
57 FIX Qdot_out := 0 {W};
58 t := 0 {d};
59 FIX cp := 4 {kJ/kg/K};
60 FIX m := 100 {kg};
61 Qdot_in.obs_id := 1;
62 T.obs_id := 2;
63 C.obs_id := 3;
64 Qdot_out.obs_id := 4;
65 E.obs_id := 5;
66 b_c1.obs_id := 6;
67 b_c0.obs_id := 7;
68 b_p1.obs_id := 8;
69 b_p0.obs_id := 9;
70 END on_load;
71 METHOD e_c1; RUN freeze_c; END e_c1;
72 METHOD e_c1_end; RUN thaw_c; END e_c1_end;
73 METHOD e_c0; RUN freeze_c; END e_c0;
74 METHOD e_c0_end; RUN thaw_c; END e_c0_end;
75 METHOD e_p1; RUN freeze_p; END e_p1;
76 METHOD e_p1_end; RUN thaw_p; END e_p1_end;
77 METHOD e_p0; RUN freeze_p; END e_p0;
78 METHOD e_p0_end; RUN thaw_p; END e_p0_end;
79 METHOD freeze_c;
80 FREE C;
81 FIX T, E, der(E), Qdot_out, Qdot_in, t;
82 qin_eq.included := FALSE; en_eq.included := FALSE; dyn_eq.included := FALSE;
83 END freeze_c;
84 METHOD thaw_c;
85 FIX C;
86 FREE T, E, der(E), Qdot_out, Qdot_in, t;
87 qin_eq.included := TRUE; en_eq.included := TRUE; dyn_eq.included := TRUE;
88 END thaw_c;
89 METHOD freeze_p;
90 FREE Qdot_out;
91 FIX T, E, der(E), Qdot_out, Qdot_in, t;
92 qin_eq.included := FALSE; en_eq.included := FALSE; dyn_eq.included := FALSE;
93 END freeze_c;
94 METHOD thaw_p;
95 FIX Qdot_out;
96 FREE T, E, der(E), Qdot_out, Qdot_in, t;
97 qin_eq.included := TRUE; en_eq.included := TRUE; dyn_eq.included := TRUE;
98 END freeze_c;
99 END solardynamics_simple;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22