packageTableBased

Incompressible medium properties based on tables

Extends from Modelica.Media.Interfaces.PartialMedium (Partial medium properties (base package of all media packages)).

Information

This is the base package for medium models of incompressible fluids based on tables. The minimal data to provide for a useful medium description is tables of density and heat capacity as functions of temperature.

It should be noted that incompressible media only have 1 state per control volume (usually T), but have both T and p as inputs for fully correct properties. The error of using only T-dependent properties is small, therefore a Boolean flag enthalpyOfT exists. If it is true, the enumeration Choices.IndependentVariables is set to Choices.IndependentVariables.T otherwise it is set to Choices.IndependentVariables.pT.

Using the package TableBased

To implement a new medium model, create a package that extends TableBased and provides one or more of the constant tables:

tableDensity        = [T, d];
tableHeatCapacity   = [T, Cp];
tableConductivity   = [T, lam];
tableViscosity      = [T, eta];
tableVaporPressure  = [T, pVap];

The table data is used to fit constant polynomials of order npol, the temperature data points do not need to be same for different properties. Properties like enthalpy, inner energy and entropy are calculated consistently from integrals and derivatives of d(T) and Cp(T). The minimal data for a useful medium model is thus density and heat capacity. Transport properties and vapor pressure are optional, if the data tables are empty the corresponding function calls can not be used.

Parameters

TypeNameDefaultDescription
Modelica.Media.Interfaces.Choices.IndependentVariablesThermoStates (from PartialMedium)Enumeration type for independent variables
StringmediumName (from PartialMedium)"unusablePartialMedium"Name of the medium
String[:]substanceNames (from PartialMedium){mediumName}Names of the mixture substances. Set substanceNames={mediumName} if only one substance.
String[:]extraPropertiesNames (from PartialMedium)fill("", 0)Names of the additional (extra) transported properties. Set extraPropertiesNames=fill("",0) if unused
BooleansingleState (from PartialMedium)= true, if u and d are not a function of pressure
BooleanreducedX (from PartialMedium)true= true, if medium contains the equation sum(X) = 1.0; set reducedX=true, if only one substance (see docu for details)
BooleanfixedX (from PartialMedium)false= true, if medium contains the equation X = reference_X
AbsolutePressurereference_p (from PartialMedium)101325Reference pressure of Medium: default 1 atmosphere
Temperaturereference_T (from PartialMedium)298.15Reference temperature of Medium: default 25 deg Celsius
MassFraction[nX]reference_X (from PartialMedium)fill(1/nX, nX)Default mass fractions of medium
AbsolutePressurep_default (from PartialMedium)101325Default value for pressure of medium (for initialization)
TemperatureT_default (from PartialMedium)Modelica.Units.Conversions.from_degC(20)Default value for temperature of medium (for initialization)
SpecificEnthalpyh_default (from PartialMedium)specificEnthalpy_pTX(p_default, T_default, X_default)Default value for specific enthalpy of medium (for initialization)
MassFraction[nX]X_default (from PartialMedium)reference_XDefault value for mass fractions of medium (for initialization)
ExtraProperty[nC]C_default (from PartialMedium)fill(0, nC)Default value for trace substances of medium (for initialization)
IntegernS (from PartialMedium)size(substanceNames, 1)Number of substances
IntegernX (from PartialMedium)nSNumber of mass fractions
IntegernXi (from PartialMedium)if fixedX then 0 else if reducedX then nS - 1 else nSNumber of structurally independent mass fractions (see docu for details)
IntegernC (from PartialMedium)size(extraPropertiesNames, 1)Number of extra (outside of standard mass-balance) transported properties
Real[nC]C_nominal (from PartialMedium)1.0e-6*ones(nC)Default for the nominal values for the extra properties
BooleanenthalpyOfTtrueTrue if enthalpy is approximated as a function of T only, (p-dependence neglected)
BooleandensityOfTsize(tableDensity, 1) > 1True if density is a function of temperature
SI.TemperatureT_minMinimum temperature valid for medium model
SI.TemperatureT_maxMaximum temperature valid for medium model
TemperatureT0273.15Reference Temperature
SpecificEnthalpyh00Reference enthalpy at T0, reference_p
SpecificEntropys00Reference entropy at T0, reference_p
MolarMassMM_const0.1Molar mass
Integernpol2Degree of polynomial used for fitting
IntegernpolDensitynpolDegree of polynomial used for fitting rho(T)
IntegernpolHeatCapacitynpolDegree of polynomial used for fitting Cp(T)
IntegernpolViscositynpolDegree of polynomial used for fitting eta(T)
IntegernpolVaporPressurenpolDegree of polynomial used for fitting pVap(T)
IntegernpolConductivitynpolDegree of polynomial used for fitting lambda(T)
Integernetasize(tableViscosity, 1)Number of data points for viscosity
RealtableDensityTable for rho(T)
RealtableHeatCapacityTable for Cp(T)
RealtableViscosityTable for eta(T)
RealtableVaporPressureTable for pVap(T)
RealtableConductivityTable for lambda(T)
BooleanTinKTrue if T[K],Kelvin used for table temperatures
BooleanhasDensitynot (size(tableDensity, 1) == 0)True if table tableDensity is present
BooleanhasHeatCapacitynot (size(tableHeatCapacity, 1) == 0)True if table tableHeatCapacity is present
BooleanhasViscositynot (size(tableViscosity, 1) == 0)True if table tableViscosity is present
BooleanhasVaporPressurenot (size(tableVaporPressure, 1) == 0)True if table tableVaporPressure is present
Real[neta]invTKif size(tableViscosity, 1) > 0 then (if TinK then 1./tableViscosity[:, 1] else 1./Cv.from_degC(tableViscosity[:, 1])) else fill(0, neta)
Real[:]poly_rhoif hasDensity then Polynomials.fitting(tableDensity[:, 1], tableDensity[:, 2], npolDensity) else zeros(npolDensity + 1)
Real[:]poly_Cpif hasHeatCapacity then Polynomials.fitting(tableHeatCapacity[:, 1], tableHeatCapacity[:, 2], npolHeatCapacity) else zeros(npolHeatCapacity + 1)
Real[:]poly_etaif hasViscosity then Polynomials.fitting(invTK, Math.log(tableViscosity[:, 2]), npolViscosity) else zeros(npolViscosity + 1)
Real[:]poly_pVapif hasVaporPressure then Polynomials.fitting(tableVaporPressure[:, 1], tableVaporPressure[:, 2], npolVaporPressure) else zeros(npolVaporPressure + 1)
Real[:]poly_lamif size(tableConductivity, 1) > 0 then Polynomials.fitting(tableConductivity[:, 1], tableConductivity[:, 2], npolConductivity) else zeros(npolConductivity + 1)

Contents

NameDescription
invertTempFunction to invert temperatures
BasePropertiesBase properties of T dependent medium
setState_pTXReturns state record, given pressure and temperature
setState_dTXReturns state record, given pressure and temperature
setState_pTReturns state record as function of p and T
setState_phXReturns state record, given pressure and specific enthalpy
setState_phReturns state record as function of p and h
setState_psXReturns state record, given pressure and specific entropy
setState_psReturns state record as function of p and s
setSmoothStateReturn thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b
specificHeatCapacityCvSpecific heat capacity at constant volume (or pressure) of medium
specificHeatCapacityCpSpecific heat capacity at constant volume (or pressure) of medium
dynamicViscosityReturn dynamic viscosity as a function of the thermodynamic state record
thermalConductivityReturn thermal conductivity as a function of the thermodynamic state record
s_TCompute specific entropy
specificEntropyReturn specific entropy as a function of the thermodynamic state record
h_TCompute specific enthalpy from temperature
h_T_derCompute specific enthalpy from temperature
h_pTCompute specific enthalpy from pressure and temperature
density_TReturn density as function of temperature
temperatureReturn temperature as a function of the thermodynamic state record
pressureReturn pressure as a function of the thermodynamic state record
densityReturn density as a function of the thermodynamic state record
specificEnthalpyReturn specific enthalpy as a function of the thermodynamic state record
specificInternalEnergyReturn specific internal energy as a function of the thermodynamic state record
T_phCompute temperature from pressure and specific enthalpy
T_psCompute temperature from pressure and specific enthalpy
specificEnthalpyOfTprotectedReturn specific enthalpy from pressure and temperature, taking the flag enthalpyOfT into account