WOLFRAM SYSTEM MODELER

BasicDefinition

Basic definition

Wolfram Language

In[1]:=
SystemModel["Modelica.Media.UsersGuide.MediumDefinition.BasicDefinition"]
Out[1]:=

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

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:

  • mediumName is a String containing the name of the medium.
  • substanceNames is a vector of strings containing the names of the substances that make up the medium. In this case, it will contain only mediumName.
  • singleState can be set to true if u and d in BaseProperties do not depend on pressure. In other words, density does not depend on pressure (incompressible fluid), and it is assumed that also u does not depend on pressure. This setting can be useful for fluids having high density and low compressibility (e.g., liquids at moderate pressure); fast states resulting from the low compressibility effects are automatically avoided.
  • reducedX = true for single-substance media, which do not need mass fractions at all.

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_s.

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;