/[ascend]/trunk/models/dyn_tank.a4c
ViewVC logotype

Contents of /trunk/models/dyn_tank.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 896 - (show annotations) (download) (as text)
Tue Oct 24 05:04:24 2006 UTC (17 years, 7 months ago) by johnpye
File MIME type: text/x-ascend
File size: 2987 byte(s)
Renamed 'tank' to 'dyn_tank' in dyntank.* (for benefit of 'on_load' behaviour in PyGTK GUI)
Formatting in ivpStep.a4c (ivpDAE), updated copyright block.
Improved formatting of typelint error messages (using error_reporter a bit better, eliminating 'StatioLabel' calls where possible).
1 REQUIRE "ivpsystem.a4l"; (* provides a modified version of system.a4l for IVP problems *)
2 REQUIRE "atoms.a4l";
3
4 (* ASCEND modelling environment
5 Copyright (C) 1998, 2006 Carnegie Mellon University
6
7 The ASCEND Modeling Library is free software; you can redistribute
8 it and/or modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 The ASCEND Modeling Library is distributed in hope that it will
13 be useful, but WITHOUT ANY WARRANTY; without even the implied
14 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with the program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the
20 file named COPYING.
21 *)(*
22 by Duncan Coffey
23 This model gives a pretty trivial example of integration using LSODE.
24 *)
25
26 MODEL dyn_tank;
27 (* List of Variables *)
28 dM_dt IS_A molar_rate;
29 M IS_A mole;
30 input IS_A molar_rate;
31 output IS_A molar_rate;
32 Volume IS_A volume;
33 density IS_A real_constant;
34 dynamic IS_A boolean;
35 t IS_A time;
36
37 (* Equations *)
38 dM_dt = input - output;
39 M = Volume * density;
40
41 (* Assignment of values to Constants *)
42 density :==10 {mol/m^3};
43
44 METHODS
45 METHOD check_self;
46 IF (input < 1e-4 {mole/s}) THEN
47 STOP {Input dried up in tank};
48 END IF;
49 IF (output < 1e-4 {mole/s}) THEN
50 STOP {Output dried up in tank};
51 END IF;
52 END check_self;
53
54 METHOD check_all;
55 RUN check_self;
56 END check_all;
57
58 METHOD default_self;
59 dynamic := FALSE;
60 t :=0 {sec};
61 dM_dt :=0 {mol/sec};
62 dM_dt.lower_bound := -1e49 {mol/sec};
63 input := 1 {mol/sec};
64 output := 1 {mol/sec};
65 END default_self;
66
67 METHOD default_all;
68 RUN default_self;
69 END default_all;
70
71 METHOD bound_self;
72 END bound_self;
73
74 METHOD bound_all;
75 RUN bound_self;
76 END bound_all;
77
78 METHOD scale_self;
79 END scale_self;
80
81 METHOD scale_all;
82 RUN scale_self;
83 END scale_all;
84
85 METHOD seqmod;
86 FIX dM_dt;
87 FREE M;
88 FIX Volume;
89 FIX input;
90 FREE output;
91 IF dynamic THEN
92 FREE dM_dt;
93 FIX M;
94 FREE Volume;
95 FIX output;
96 END IF;
97 END seqmod;
98
99 METHOD specify;
100 FIX input;
101 RUN seqmod;
102 END specify;
103
104 METHOD set_ode;
105 (* set ODE_TYPE -1=independent variable,
106 0=algebraic variable, 1=state variable,
107 2=derivative *)
108 t.ode_type :=-1;
109 dM_dt.ode_type :=2;
110 M.ode_type :=1;
111 (* Set ODE_ID *)
112 dM_dt.ode_id :=1;
113 M.ode_id :=1;
114 END set_ode;
115
116 METHOD set_obs;
117 (* Set OBS_ID to any integer value greater
118 than 0, the variable will be recorded
119 (i.e., observed) *)
120 M.obs_id :=1;
121 Volume.obs_id :=2;
122 input.obs_id :=3;
123 output.obs_id :=4;
124 END set_obs;
125
126 METHOD values;
127 Volume :=5 {m^3};
128 input :=100 {mole/s};
129 END values;
130
131 METHOD on_load;
132 RUN default_self;
133 dynamic := TRUE;
134 RUN reset;
135 RUN specify;
136 RUN set_obs;
137 RUN set_ode;
138 END on_load;
139
140 END dyn_tank;

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