Skip to content
jmoeckel edited this page Nov 5, 2015 · 1 revision

Guidelines regarding the declaration of types, i.e. default values, value range or units.

3.1 Protected

Declare variables and final parameters that are not of interest to users as protected.

3.2 Skipping Default Value

If a parameter value can range over a large region, do not provide a default value, i.e. nominal mass flow rates.

3.3 Using Default Value

If a parameter value does not vary significantly, provide a default by using its start attribute. Use parameter Real eps(start=0.8)"Heat exchanger effectiveness"; instead of parameter Real eps = 0.8 "Heat exchanger effectiveness";. Providing default values for all parameters can lead to errors that are difficult to detect, since a modeller may have forgotten to provide a meaningful value (the model simulates, but gives wrong results due to wrong parameter values).

3.4 Precomputed Default Value

If a parameter value can be precomputed based on other parameters, set its default value to this equation. Use parameter Medium.MassFlowRate m_flow_small(start = 1E-4*m_flow_nominal);.

3.5 Final

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

3.6 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 suppress these warnings.)

3.7 Start

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

3.8 SIUnits

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.

3.9 Order of public and protected

Declare all public parameters before protected ones.