Last change
on this file since 141 was
141,
checked in by Rafael de Pelegrini Soares, 15 years ago
|
Updated the switch sample, now working fine
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.7 KB
|
Rev | Line | |
---|
[137] | 1 | |
---|
| 2 | using "types"; |
---|
| 3 | |
---|
| 4 | Model BallWithSafetyValve |
---|
| 5 | ATTRIBUTES |
---|
| 6 | Info = "A fixed volume ball with a safety valve |
---|
| 7 | for the pressure."; |
---|
| 8 | |
---|
| 9 | PARAMETERS |
---|
| 10 | ValveMode as Switcher(Valid = ["closed", "opened"], Default = "closed"); |
---|
| 11 | R as Real(Unit="J/(K*mol)", Default=8.314472); |
---|
| 12 | V as volume; |
---|
| 13 | T as temperature; |
---|
| 14 | Pout as pressure; |
---|
[141] | 15 | k as Real(Default=1e-3); |
---|
[137] | 16 | |
---|
| 17 | VARIABLES |
---|
| 18 | flow_in as flow_mol; |
---|
| 19 | flow_out as flow_mol; |
---|
[141] | 20 | P as pressure(Default=3); |
---|
[137] | 21 | n as mol; |
---|
| 22 | |
---|
| 23 | EQUATIONS |
---|
| 24 | |
---|
| 25 | "Ideal gas relation" |
---|
| 26 | P*V = n*R*T; |
---|
| 27 | |
---|
| 28 | "Mass balance" |
---|
| 29 | diff(n) = flow_in - flow_out; |
---|
| 30 | |
---|
| 31 | switch ValveMode |
---|
| 32 | case "closed": |
---|
| 33 | flow_out = 0 * "mol/h"; |
---|
| 34 | when P > 2*"atm" switchto "opened"; |
---|
| 35 | |
---|
| 36 | case "opened": |
---|
| 37 | flow_out = k*sqrt(P - Pout); |
---|
| 38 | when P < Pout * 1.1 switchto "closed"; |
---|
| 39 | end |
---|
| 40 | end |
---|
| 41 | |
---|
[141] | 42 | |
---|
| 43 | Model BallWithSafetyValve2 |
---|
| 44 | ATTRIBUTES |
---|
| 45 | Info = "A fixed volume ball with a safety valve |
---|
| 46 | for the pressure."; |
---|
| 47 | |
---|
| 48 | PARAMETERS |
---|
| 49 | ValveMode as Switcher(Valid = ["closed", "opened"], Default = "closed"); |
---|
| 50 | R as Real(Unit="J/(K*mol)", Default=8.314472); |
---|
| 51 | V as volume; |
---|
| 52 | T as temperature; |
---|
| 53 | Pout as pressure; |
---|
| 54 | k as Real(Default=1e-4); |
---|
| 55 | |
---|
| 56 | VARIABLES |
---|
| 57 | flow_in as flow_mol; |
---|
| 58 | flow_out as flow_mol; |
---|
| 59 | P as pressure(Default=3); |
---|
| 60 | n as mol; |
---|
| 61 | |
---|
| 62 | EQUATIONS |
---|
| 63 | |
---|
| 64 | "Ideal gas relation" |
---|
| 65 | P*V = n*R*T; |
---|
| 66 | |
---|
| 67 | "Mass balance" |
---|
| 68 | diff(n) = flow_in - flow_out; |
---|
| 69 | |
---|
| 70 | #switch ValveMode |
---|
| 71 | #case "closed": |
---|
| 72 | # flow_out = 0 * "mol/h"; |
---|
| 73 | # when P > 2*"atm" switchto "opened"; |
---|
| 74 | |
---|
| 75 | #case "opened": |
---|
| 76 | flow_out = k*sqrt(P - Pout); |
---|
| 77 | # when P < Pout * 1.1 switchto "closed"; |
---|
| 78 | #end |
---|
| 79 | end |
---|
| 80 | |
---|
[137] | 81 | FlowSheet Test |
---|
| 82 | DEVICES |
---|
| 83 | ball as BallWithSafetyValve; |
---|
| 84 | |
---|
| 85 | SET |
---|
| 86 | ball.V = 1 * "l"; |
---|
| 87 | ball.T = 300 * "K"; |
---|
| 88 | ball.Pout = 1 * "atm"; |
---|
[141] | 89 | ball.ValveMode = "opened"; |
---|
[137] | 90 | |
---|
| 91 | SPECIFY |
---|
[141] | 92 | ball.flow_in = 0.1 * "kmol/h"; |
---|
[137] | 93 | |
---|
| 94 | INITIAL |
---|
[141] | 95 | ball.P = 1 * "atm"; |
---|
| 96 | |
---|
| 97 | OPTIONS |
---|
| 98 | TimeStep = 0.01; |
---|
| 99 | TimeEnd = 10; |
---|
[137] | 100 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.