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

Contents of /trunk/models/kvalues.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 421 - (show annotations) (download) (as text)
Mon Apr 3 17:26:22 2006 UTC (18 years, 3 months ago) by ben.allan
File MIME type: text/x-ascend
File size: 2281 byte(s)
updated kvalues example to parse and put in model library.
changed import library name to dquote text for more generality.
fixed many, but not all problems in kvalues.c
1 IMPORT KValues_Init FROM "kvalues";
2
3 ATOM comp_atom REFINES generic_real;
4 component IS_A symbol;
5 END comp_atom;
6
7
8 MODEL component_data;
9 ncomps IS_A integer_constant;
10 ncomps :== 3;
11 components[1..ncomps] IS_A symbol_constant;
12
13 components[1] :== 'benzene';
14 components[2] :== 'hexane';
15 components[3] :== 'chloro';
16 END component_data;
17
18 MODEL test1;
19
20 liq, feed, vap IS_A generic_real;
21 T, P IS_A generic_real;
22 x[1..5] IS_A generic_real;
23 y[1..3] IS_A generic_real;
24 data IS_A component_data;
25
26
27 gnew: bubblepnt( T, x[1..3], P : INPUT ;
28 y[1..3] : OUTPUT ;
29 data : DATA);
30
31 h4: x[1] + x[2] + x[3] = 1.0;
32 h5: x[2] * 0.1805 = y[3];
33
34
35 METHODS
36
37
38 METHOD mytest;
39 END mytest;
40
41 METHOD specify;
42 x[1].fixed := TRUE;
43 x[2].fixed := TRUE;
44 x[1] := 0.3;
45 x[2] := 0.5;
46 x[3] := 1.0 - (x[1] + x[2]);
47
48 y[1].fixed := FALSE;
49 y[2].fixed := FALSE;
50 y[3].fixed := FALSE;
51
52 T.fixed := TRUE;
53 T := 300.0;
54 P.fixed := TRUE;
55 P := 760.0;
56 END specify;
57
58 END test1;
59
60
61 MODEL test2;
62
63 t1 IS_A test1;
64
65 END test2;
66
67
68
69 MODEL test1_normal;
70
71 comp IS_A set OF integer_constant;
72 a[comp],b[comp],c[comp] IS_A real_constant;
73 comp :== [1..3];
74 a[1] :== 15.5381; b[1] :== 2032.73; c[1] :== -33.15;
75 a[2] :== 15.8333; b[2] :== 2477.07; c[2] :== -39.94;
76 a[3] :== 15.8737; b[3] :== 2911.32; c[3] :== -56.51;
77
78
79 T, P IS_A generic_real;
80 psat[1..3] IS_A generic_real;
81 x[1..3] IS_A comp_atom;
82 y[1..3] IS_A generic_real;
83
84
85 FOR i IN comp CREATE
86 pres[i]: ln(psat[i]) = a[i] - b[i]/(T + c[i]);
87 END FOR;
88
89 FOR i IN comp CREATE
90 raoult[i]: P*y[i] = psat[i]*x[i];
91 END FOR;
92 h4: x[1] + x[2] + x[3] = 1.0;
93 h5: x[2] * 0.1805 = y[3];
94
95 METHODS
96
97 METHOD default_self;
98 x[1].component := 'benzene';
99 x[2].component := 'hexane';
100 x[3].component := 'chloro';
101 END default_self;
102
103 METHOD specify;
104 x[1].fixed := TRUE;
105 x[3].fixed := TRUE;
106 x[1] := 0.3;
107 x[2] := 0.5;
108 x[3] := 1.0 - (x[1] + x[2]);
109
110 y[1].fixed := FALSE;
111 y[2].fixed := FALSE;
112 y[3].fixed := FALSE;
113
114 T.fixed := TRUE;
115 T := 300.0;
116 P.fixed := TRUE;
117 P := 760.0;
118 END specify;
119
120 END test1_normal;
121
122
123
124 MODEL test2_normal;
125
126 t1 IS_A test1_normal;
127
128 END test2_normal;

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