When a medium model is used in a balance volume, differential equations for the independent medium variables are present and therefore initial conditions have to be provided. The following possibilities exist:
Modelica has currently no language element to define steady state initialization. In the Modelica simulation environment Dymola, the option
Advanced.DefaultSteadyStateInitialization = true
can be set before translation. Then, missing initial conditions are provided by automatically setting appropriate state derivatives to zero.
Explicit start values can be defined with the "start" and "fixed" attributes. The number of independent variables nx need to be known which can be deduced from the medium constants (nx = nXi + if singleState then 1 else 2). Then, start values or initial equations can be defined for nx variables (= p, T, d, u, h, Xi) from Medium.BaseProperties, e.g., in the form:
replaceable package Medium = Medium.Interfaces.PartialMedium; Medium.BaseProperties medium1 (p(start=1e5, fixed=not Medium.singleState), T(start=300, fixed=true)); Medium.BaseProperties medium2; initial equation if not Medium.singleState then medium2.p = 1e5; end if; medium2.T = 300; equation
If initial conditions are not provided for the independent medium variables, non-linear systems of equations may occur to compute the initial values of the independent medium variables from the provided initial conditions.
If non-linear systems of equations occur during initialization, e.g., in case of steady state initialization, guess values for the iteration variables of the non-linear system of equations have to be provided via the "start" attribute (and fixed=false). Unfortunately, it is usually not known in advance which variables are selected as iteration variables of a non-linear system of equations. One of the following possibilities exist:
Advanced.OutputModelicaCode = true
and by inspection of the file "dsmodel.mof" that is generated
when this option is set (search for "nonlinear").