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

Annotation of /trunk/models/dyn_tank.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 896 - (hide annotations) (download) (as text)
Tue Oct 24 05:04:24 2006 UTC (17 years, 8 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 johnpye 896 REQUIRE "ivpsystem.a4l"; (* provides a modified version of system.a4l for IVP problems *)
2     REQUIRE "atoms.a4l";
3 aw0a 1
4 johnpye 896 (* 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 aw0a 1 (* 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 johnpye 896 METHODS
45     METHOD check_self;
46 aw0a 1 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 johnpye 896 END check_self;
53 aw0a 1
54 johnpye 896 METHOD check_all;
55 aw0a 1 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 johnpye 669 input := 1 {mol/sec};
64     output := 1 {mol/sec};
65 johnpye 896 END default_self;
66 aw0a 1
67 johnpye 896 METHOD default_all;
68 aw0a 1 RUN default_self;
69 johnpye 896 END default_all;
70 aw0a 1
71 johnpye 896 METHOD bound_self;
72     END bound_self;
73 aw0a 1
74 johnpye 896 METHOD bound_all;
75     RUN bound_self;
76     END bound_all;
77 aw0a 1
78 johnpye 896 METHOD scale_self;
79     END scale_self;
80 aw0a 1
81 johnpye 896 METHOD scale_all;
82 aw0a 1 RUN scale_self;
83 johnpye 896 END scale_all;
84 aw0a 1
85 johnpye 896 METHOD seqmod;
86 johnpye 576 FIX dM_dt;
87     FREE M;
88     FIX Volume;
89     FIX input;
90     FREE output;
91 aw0a 1 IF dynamic THEN
92 johnpye 576 FREE dM_dt;
93     FIX M;
94     FREE Volume;
95     FIX output;
96 aw0a 1 END IF;
97 johnpye 896 END seqmod;
98 aw0a 1
99 johnpye 896 METHOD specify;
100 johnpye 576 FIX input;
101 aw0a 1 RUN seqmod;
102 johnpye 896 END specify;
103 aw0a 1
104 johnpye 896 METHOD set_ode;
105 aw0a 1 (* 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 johnpye 896 END set_ode;
115 aw0a 1
116 johnpye 896 METHOD set_obs;
117 aw0a 1 (* 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 johnpye 896 END set_obs;
125 aw0a 1
126 johnpye 896 METHOD values;
127 aw0a 1 Volume :=5 {m^3};
128     input :=100 {mole/s};
129 johnpye 896 END values;
130 johnpye 669
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 johnpye 896 END dyn_tank;

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