Index: branches/newlanguage/sample/miscellaneous/sample_switcher.mso
===================================================================
--- branches/newlanguage/sample/miscellaneous/sample_switcher.mso (revision 137)
+++ branches/newlanguage/sample/miscellaneous/sample_switcher.mso (revision 137)
@@ -0,0 +1,57 @@
+
+using "types";
+
+Model BallWithSafetyValve
+ 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;
+
+ VARIABLES
+ flow_in as flow_mol;
+ flow_out as flow_mol;
+ P as pressure;
+ 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
+ ball as BallWithSafetyValve;
+
+ SET
+ ball.V = 1 * "l";
+ ball.T = 300 * "K";
+ ball.Pout = 1 * "atm";
+ ball.ValveMode = "closed";
+
+ SPECIFY
+ ball.flow_in = 2 * "mol/h";
+
+ INITIAL
+ ball.P = 0.8 * "atm";
+end