Changes between Version 5 and Version 6 of LanguageChanges


Ignore:
Timestamp:
Jan 12, 2007, 1:08:49 PM (15 years ago)
Author:
Rafael de Pelegrini Soares
Comment:

Added switch suggestion

Legend:

Unmodified
Added
Removed
Modified
  • LanguageChanges

    v5 v6  
    151151||Who || Opinion || Why ||
    152152||Rafael || '''option 3''' || With option 3 we have a clear distinction between the graphical interface and the models ||
     153
     154== Switcher for equations ==
     155
     156Currently, continuous-discrete modeling is supported in EMSO using the '''if''' statement.
     157But some more complex situations cannot be modeled with '''if'''.
     158
     159For example, a safety valve which opens if the pressure is higher than 2 atm but closes only when the pressure is lower than 1 atm.
     160This situation cannot be modeled by a simply '''if'''. For this case, a State Transition Network (STN) is needed.
     161
     162For this case the '''Switcher''' is proposed, usage:
     163{{{
     164#!mso
     165Model SafetyValve
     166    PARAMETERS
     167    mode as Switcher(Valid = ["closed", "opened"], Default = "closed")
     168    ...
     169    EQUATIONS
     170    switch(mode)
     171    case "closed":
     172       flow = 0 * "mol/h";
     173       change to "opened" if P>2*"atm";
     174    case "opened":
     175       flow = k*sqrt(P - Pout);
     176       change to "closed" if P<1*"atm";
     177    end
     178    ...
     179end
     180}}}
     181
     182In the piece of code above there are the following news:
     183 * A new basic type called '''Switcher'''
     184 * The '''Switcher''' type has an extra attribute called '''Valid''' which are the valid values for the switcher
     185 * There is a '''switch''' command which can be used in the EQUATIONS
     186 * There is a '''change to''' command which can be used inside a '''case''' of a '''switch'''
     187
     188||Who || Opinion || Why ||
     189||Rafael || '''agreed''' || proposed the change ||