Changeset 141 for branches/newlanguage


Ignore:
Timestamp:
Jan 30, 2007, 1:55:55 PM (16 years ago)
Author:
Rafael de Pelegrini Soares
Message:

Updated the switch sample, now working fine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/newlanguage/sample/miscellaneous/sample_switcher.mso

    r137 r141  
    1313        T as temperature;
    1414        Pout as pressure;
    15         k as Real;
     15        k as Real(Default=1e-3);
    1616
    1717        VARIABLES
    1818        flow_in as flow_mol;
    1919        flow_out as flow_mol;
    20         P as pressure;
     20        P as pressure(Default=3);
    2121        n as mol;
    2222       
     
    4040end
    4141
     42
     43Model 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
     79end
     80
    4281FlowSheet Test
    4382        DEVICES
     
    4887        ball.T = 300 * "K";
    4988        ball.Pout = 1 * "atm";
    50         ball.ValveMode = "closed";
     89        ball.ValveMode = "opened";
    5190       
    5291        SPECIFY
    53         ball.flow_in = 2 * "mol/h";
     92        ball.flow_in = 0.1 * "kmol/h";
    5493       
    5594        INITIAL
    56         ball.P = 0.8 * "atm";
     95        ball.P = 1 * "atm";
     96       
     97        OPTIONS
     98        TimeStep = 0.01;
     99        TimeEnd = 10;
    57100end
Note: See TracChangeset for help on using the changeset viewer.