Jump to: navigation, search

The SELECT statement is used to selectively compile equations according to the value of constants in the model. This similar to the WHEN statement used in Conditional modelling, except that it allows no possibility of equations being switched on or off after the model is instantiated.

Be careful when naming your equations inside a SELECT statement: A name cannot be defined two different ways inside the SELECT statement, but it may be defined outside the case statement and then refined in different ways in separate cases, using IS_REFINED_TO.

This statement is declarative. Order of the CASEs does not matter. All matching cases are executed. The OTHERWISE is executed if present and no other CASEs match. SELECT is not allowed inside FOR, but writing FOR statements inside SELECT is allowed.

MODEL eos_constants (

    component_name WILL_BE symbol_constant;
    T_c IS_A temperature_constant;
    p_c IS_A pressure_constant;

    (* depending on the value of the 'component_name' parameter, set the
    critical temperature and pressure to the appropriate value. *)
        CASE 'hydrogen':

            T_c :== 33 {K};
            p_c :== 12.9 {bar};

        CASE 'water':
            T_c :== 647.3 {K};
            p_c :== 221.2 {bar};

        CASE 'oxygen':
            T_c :== 154.6 {K};
            p_c :== 50.4 {bar};

            T_c :== -1 {K};
            p_c :== -1 {Pa};

END eos_constants;

In fact, this is the technique used in the current models/components.a4l model in our ModelLibrary.

See also Conditional modelling, IF, WHEN, and SWITCH.