In some cases additional medium properties are needed. A component that needs these optional properties has to call one of the functions listed in the following table. They are defined as partial functions within package PartialMedium, and then (optionally) implemented in actual medium packages. If a component calls such an optional function and the medium package does not provide a new implementation for this function, an error message is printed at translation time, since the function is "partial", i.e., incomplete. The argument of all functions is the state record, automatically defined by the BaseProperties model or specifically computed using the setState_XXX functions, which contains the minimum number of thermodynamic variables needed to compute all the additional properties. In the table it is assumed that there is a declaration of the form:
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium; Medium.ThermodynamicState state;
Function call | Unit | Description |
Medium.dynamicViscosity(state) | Pa.s | dynamic viscosity |
Medium.thermalConductivity(state) | W/(m.K) | thermal conductivity |
Medium.prandtlNumber(state) | 1 | Prandtl number |
Medium.specificEntropy(state) | J/(kg.K) | specific entropy |
Medium.specificHeatCapacityCp(state) | J/(kg.K) | specific heat capacity at constant pressure |
Medium.specificHeatCapacityCv(state) | J/(kg.K) | specific heat capacity at constant density |
Medium.isentropicExponent(state) | 1 | isentropic exponent |
Medium.isentropicEnthatlpy(pressure, state) | J/kg | isentropic enthalpy |
Medium.velocityOfSound(state) | m/s | velocity of sound |
Medium.isobaricExpansionCoefficient(state) | 1/K | isobaric expansion coefficient |
Medium.isothermalCompressibility(state) | 1/Pa | isothermal compressibility |
Medium.density_derp_h(state) | kg/(m3.Pa) | derivative of density by pressure at constant enthalpy |
Medium.density_derh_p(state) | kg2/(m3.J) | derivative of density by enthalpy at constant pressure |
Medium.density_derp_T(state) | kg/(m3.Pa) | derivative of density by pressure at constant temperature |
Medium.density_derT_p(state) | kg/(m3.K) | derivative of density by temperature at constant pressure |
Medium.density_derX(state) | kg/m3 | derivative of density by mass fraction |
Medium.molarMass(state) | kg/mol | molar mass |
There are also some short forms provided for user convenience that allow the computation of certain thermodynamic state variables without using the ThermodynamicState record explicitly. Those short forms are for example useful to compute consistent start values in the initial equation section. Let's consider the function temperature_phX(p,h,X) as an example. This function computes the temperature from pressure, specific enthalpy, and composition X (or Xi) and is a short form for writing
temperature(setState_phX(p,h,X))
The following functions are predefined in PartialMedium (other functions can be added in the actual medium implementation package if they are useful)
Medium.specificEnthalpy_pTX(p,T,X) | J/kg | Specific enthalpy at p, T, X |
Medium.temperature_phX(p,h,X) | K | Temperature at p, h, X |
Medium.density_phX(p,h,X) | kg/m3 | Density at p, h, X |
Medium.temperature_psX(p,s,X) | K | Temperature at p, s, X |
Medium.specificEnthalpy_psX(p,s,X) | J/(kg.K) | Specific entropy at p, s, X |
Assume for example that the dynamic viscosity eta is needed in the pressure drop equation of a short pipe. Then, the model of a short pipe has to be changed to:
model ShortPipe ... Medium.BaseProperties medium_a "Medium properties in port_a"; Medium.BaseProperties medium_b "Medium properties in port_b"; ... Medium.DynamicViscosity eta; ... eta = if port_a.m_flow > 0 then Medium.dynamicViscosity(medium_a.state) else Medium.dynamicViscosity(medium_b.state); // use eta in the pressure drop equation: port_a.m_flow = f(dp, eta) end ShortPipe;
Note, "Medium.DynamicViscosity" is a type defined in Modelica.Interfaces.PartialMedium as
import SI = Modelica.SIunits; type DynamicViscosity = SI.DynamicViscosity ( min=0, max=1.e8, nominal=1.e-3, start=1.e-3);
Every medium model may modify the attributes, to provide, e.g., min, max, nominal, and start values adapted to the medium. Also, other types, such as AbsolutePressure, Density, MassFlowRate, etc. are defined in PartialMedium. Whenever possible, these medium specific types should be used in a model in order that medium information, e.g., about nominal or start values, are automatically utilized.