.Modelica.Media.UsersGuide.MediumDefinition.BasicDefinition

Information

Let's now walk through the definition of a new medium model. Please refer to Modelica.Media.Interfaces.TemplateMedium to obtain a template of the new medium model code. For the moment being, consider a single-substance medium model.

The new medium model is obtained by extending Modelica.Media.Interfaces.PartialMedium, and setting the following package constants:

It is also possible to change the default min, max, nominal, and start attributes of Medium-defined types (see TemplateMedium).

All other package constants, such as nX, nXi, nS, are automatically set by the declarations of the base package Interfaces.PartialMedium.

The second step is to provide an implementation to the BaseProperties model, partially defined in the base class Interfaces.PartialMedium. In the case of single-substance media, two independent state variables must be selected among p, T, d, u, h, and three equations must be written to provide the values of the remaining variables. Two equations must then be added to compute the molar mass MM and the gas constant R.

The third step is to consider the optional functions that are going to be implemented, among the partial functions defined by the base class PartialMedium. A minimal set of state variables that could be provided as an input to all those functions must be selected, and included in the redeclaration of the ThermodynamicState record. Subsequently, equations must be added to BaseProperties in order that the instance of that record inside BaseProperties (named "state") is kept updated. For example, assume that all additional properties can be computed as a function of p and T. Then, ThermodynamicState should be redeclared as follows:

  redeclare replaceable record ThermodynamicState
    AbsolutePressure p "Absolute pressure of medium";
    Temperature T "Temperature of medium";
  end ThermodynamicState;

and the following equations should be added to BaseProperties:

  state.p = p;
  state.T = T;

The additional functions can now be implemented by redeclaring the functions defined in the base class and adding their algorithms, e.g.:

    redeclare function extends dynamicViscosity "Return dynamic viscosity"
    algorithm
      eta := 10 - state.T*0.3 + state.p*0.2;
    end dynamicViscosity;

Generated at 2020-06-05T07:38:22Z by OpenModelica 1.16.0~dev-420-gc007a39