Index: /branches/newlanguage/sample/miscellaneous/sample_switcher.mso
===================================================================
--- /branches/newlanguage/sample/miscellaneous/sample_switcher.mso (revision 140)
+++ /branches/newlanguage/sample/miscellaneous/sample_switcher.mso (revision 141)
@@ -13,10 +13,10 @@
T as temperature;
Pout as pressure;
- k as Real;
+ k as Real(Default=1e-3);
VARIABLES
flow_in as flow_mol;
flow_out as flow_mol;
- P as pressure;
+ P as pressure(Default=3);
n as mol;
@@ -40,4 +40,43 @@
end
+
+Model BallWithSafetyValve2
+ ATTRIBUTES
+ Info = "A fixed volume ball with a safety valve
+ for the pressure.";
+
+ PARAMETERS
+ ValveMode as Switcher(Valid = ["closed", "opened"], Default = "closed");
+ R as Real(Unit="J/(K*mol)", Default=8.314472);
+ V as volume;
+ T as temperature;
+ Pout as pressure;
+ k as Real(Default=1e-4);
+
+ VARIABLES
+ flow_in as flow_mol;
+ flow_out as flow_mol;
+ P as pressure(Default=3);
+ n as mol;
+
+ EQUATIONS
+
+ "Ideal gas relation"
+ P*V = n*R*T;
+
+ "Mass balance"
+ diff(n) = flow_in - flow_out;
+
+ #switch ValveMode
+ #case "closed":
+ # flow_out = 0 * "mol/h";
+ # when P > 2*"atm" switchto "opened";
+
+ #case "opened":
+ flow_out = k*sqrt(P - Pout);
+ # when P < Pout * 1.1 switchto "closed";
+ #end
+end
+
FlowSheet Test
DEVICES
@@ -48,10 +87,14 @@
ball.T = 300 * "K";
ball.Pout = 1 * "atm";
- ball.ValveMode = "closed";
+ ball.ValveMode = "opened";
SPECIFY
- ball.flow_in = 2 * "mol/h";
+ ball.flow_in = 0.1 * "kmol/h";
INITIAL
- ball.P = 0.8 * "atm";
+ ball.P = 1 * "atm";
+
+ OPTIONS
+ TimeStep = 0.01;
+ TimeEnd = 10;
end