Skip to content

Type Declarations

Moritz Lauster edited this page Oct 7, 2016 · 9 revisions

Type Declarations


Protected

Declare all public parameters before protected ones. Declare variables and final parameters that are not of interest to users as protected.

Default Values

Set default parameter values as follows:

  • If a parameter value can range over a large region, do not provide a default value. Examples are nominal mass flow rates.

  • If a parameter value does not vary significantly but need to be verified by the user, provide a default value by using its start attribute. For example, for a heat exchanger, use

    parameter Real eps(start=0.8, min=0, max=1, unit="1")
      "Heat exchanger effectiveness";

    Do not use parameter Real eps=0.8 as this can lead to errors that are difficult to detect if a modeller forgets to overwrite the default value of 0.8 with the actual value. The model will simulate, but gives wrong results due to unsuited parameter values and there will be no warning. On the other hand, using parameter Real eps(start=0.8) will give a warning and hence users can assign better values.

  • If a parameter value can be precomputed based on other parameters, set its value to this equation. For example,

    parameter Medium.MassFlowRate m_flow_small(min=0) = 1E-4*m_flow_nominal
    ...

Final

If a parameter value should not be changed by a user, use the final keyword.

Start/Min/Max

For parameters and variables, provide values for the min and max attribute where applicable. Be aware, that these bounds are not enforced by the simulator. If the min and max attribute are set, each violation of these bounds during the simulation may raise a warning.

Simulators may allow to supress these warnings. In Dymola, violation of bounds can be checked using

      Advanced.AssertAllInsideMinMax=true;

For any variable or parameter that may need to be solved numerically, provide a value for the start and nominal attribute.

SI Units

All variables that have a physical correspondence, including physical ratios, must have a unit. Use (derived) SI units, and where possible, use types from Modelica.SIunits. Non-SI units are to be kept at an absolute minimum, and they must be declared as protected.


Equations

Clone this wiki locally