| 1 |
IMPORT KValues_Init FROM libkvalues; |
| 2 |
|
| 3 |
ATOM comp_atom REFINES generic_real; |
| 4 |
component IS_A symbol; |
| 5 |
END comp_atom; |
| 6 |
|
| 7 |
MODEL component_data; |
| 8 |
ncomps IS_A integer; |
| 9 |
ncomps := 3; |
| 10 |
components[1..ncomps] IS_A symbol; |
| 11 |
|
| 12 |
components[1] := 'benzene'; |
| 13 |
components[2] := 'hexane'; |
| 14 |
components[3] := 'chloro'; |
| 15 |
END component_data; |
| 16 |
|
| 17 |
MODEL test1; |
| 18 |
|
| 19 |
liq, feed, vap IS_A generic_real; |
| 20 |
T, P IS_A generic_real; |
| 21 |
x[1..5] IS_A generic_real; |
| 22 |
y[1..3] IS_A generic_real; |
| 23 |
data IS_A component_data; |
| 24 |
|
| 25 |
|
| 26 |
(* given T,x, compute P,y. *) |
| 27 |
gnew: |
| 28 |
bubblepnt( |
| 29 |
T,x[1..3],P : INPUT, |
| 30 |
y[1..3] : OUTPUT, |
| 31 |
data : DATA); |
| 32 |
|
| 33 |
h4: x[1] + x[2] + x[3] = 1.0; |
| 34 |
h5: x[2] * 0.1805 = y[3]; |
| 35 |
|
| 36 |
|
| 37 |
INITIALIZATION |
| 38 |
|
| 39 |
PROCEDURE mytest; |
| 40 |
END mytest; |
| 41 |
|
| 42 |
PROCEDURE specify; |
| 43 |
x[1].fixed := TRUE; |
| 44 |
x[2].fixed := TRUE; |
| 45 |
x[1] := 0.3; |
| 46 |
x[2] := 0.5; |
| 47 |
x[3] := 1.0 - (x[1] + x[2]); |
| 48 |
|
| 49 |
y[1].fixed := FALSE; |
| 50 |
y[2].fixed := FALSE; |
| 51 |
y[3].fixed := FALSE; |
| 52 |
|
| 53 |
T.fixed := TRUE; |
| 54 |
T := 300.0; |
| 55 |
P.fixed := TRUE; |
| 56 |
P := 760.0; |
| 57 |
END specify; |
| 58 |
|
| 59 |
END test1; |
| 60 |
|
| 61 |
|
| 62 |
MODEL test2; |
| 63 |
|
| 64 |
t1 IS_A test1; |
| 65 |
|
| 66 |
END test2; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
MODEL test1_normal; |
| 71 |
|
| 72 |
comp IS_A set OF integer; |
| 73 |
a[comp],b[comp],c[comp] IS_A real; |
| 74 |
comp := [1..3]; |
| 75 |
a[1] := 15.5381; b[1] := 2032.73; c[1] := -33.15; |
| 76 |
a[2] := 15.8333; b[2] := 2477.07; c[2] := -39.94; |
| 77 |
a[3] := 15.8737; b[3] := 2911.32; c[3] := -56.51; |
| 78 |
|
| 79 |
|
| 80 |
T, P IS_A generic_real; |
| 81 |
psat[1..3] IS_A generic_real; |
| 82 |
x[1..3] IS_A comp_atom; |
| 83 |
x[1].component := 'benzene'; |
| 84 |
x[2].component := 'hexane'; |
| 85 |
x[3].component := 'chloro'; |
| 86 |
y[1..3] IS_A generic_real; |
| 87 |
|
| 88 |
|
| 89 |
FOR i IN comp |
| 90 |
CREATE |
| 91 |
pres[i]: ln(psat[i]) = a[i] - b[i]/(T + c[i]); |
| 92 |
END; |
| 93 |
|
| 94 |
FOR i IN comp |
| 95 |
CREATE |
| 96 |
raoult[i]: P*y[i] = psat[i]*x[i]; |
| 97 |
END; |
| 98 |
h4: x[1] + x[2] + x[3] = 1.0; |
| 99 |
h5: x[2] * 0.1805 = y[3]; |
| 100 |
|
| 101 |
INITIALIZATION |
| 102 |
|
| 103 |
PROCEDURE 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; |
| 129 |
|