packageTableBased
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
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Media.Interfaces.Choices.IndependentVariables | ThermoStates (from PartialMedium) | Enumeration type for independent variables | |
| String | mediumName (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 |
| Boolean | singleState (from PartialMedium) | = true, if u and d are not a function of pressure | |
| Boolean | reducedX (from PartialMedium) | true | = true, if medium contains the equation sum(X) = 1.0; set reducedX=true, if only one substance (see docu for details) |
| Boolean | fixedX (from PartialMedium) | false | = true, if medium contains the equation X = reference_X |
| AbsolutePressure | reference_p (from PartialMedium) | 101325 | Reference pressure of Medium: default 1 atmosphere |
| Temperature | reference_T (from PartialMedium) | 298.15 | Reference temperature of Medium: default 25 deg Celsius |
| MassFraction[nX] | reference_X (from PartialMedium) | fill(1/nX, nX) | Default mass fractions of medium |
| AbsolutePressure | p_default (from PartialMedium) | 101325 | Default value for pressure of medium (for initialization) |
| Temperature | T_default (from PartialMedium) | Modelica.Units.Conversions.from_degC(20) | Default value for temperature of medium (for initialization) |
| SpecificEnthalpy | h_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_X | Default 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) |
| Integer | nS (from PartialMedium) | size(substanceNames, 1) | Number of substances |
| Integer | nX (from PartialMedium) | nS | Number of mass fractions |
| Integer | nXi (from PartialMedium) | if fixedX then 0 else if reducedX then nS - 1 else nS | Number of structurally independent mass fractions (see docu for details) |
| Integer | nC (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 |
| Boolean | enthalpyOfT | true | True if enthalpy is approximated as a function of T only, (p-dependence neglected) |
| Boolean | densityOfT | size(tableDensity, 1) > 1 | True if density is a function of temperature |
| SI.Temperature | T_min | Minimum temperature valid for medium model | |
| SI.Temperature | T_max | Maximum temperature valid for medium model | |
| Temperature | T0 | 273.15 | Reference Temperature |
| SpecificEnthalpy | h0 | 0 | Reference enthalpy at T0, reference_p |
| SpecificEntropy | s0 | 0 | Reference entropy at T0, reference_p |
| MolarMass | MM_const | 0.1 | Molar mass |
| Integer | npol | 2 | Degree of polynomial used for fitting |
| Integer | npolDensity | npol | Degree of polynomial used for fitting rho(T) |
| Integer | npolHeatCapacity | npol | Degree of polynomial used for fitting Cp(T) |
| Integer | npolViscosity | npol | Degree of polynomial used for fitting eta(T) |
| Integer | npolVaporPressure | npol | Degree of polynomial used for fitting pVap(T) |
| Integer | npolConductivity | npol | Degree of polynomial used for fitting lambda(T) |
| Integer | neta | size(tableViscosity, 1) | Number of data points for viscosity |
| Real | tableDensity | Table for rho(T) | |
| Real | tableHeatCapacity | Table for Cp(T) | |
| Real | tableViscosity | Table for eta(T) | |
| Real | tableVaporPressure | Table for pVap(T) | |
| Real | tableConductivity | Table for lambda(T) | |
| Boolean | TinK | True if T[K],Kelvin used for table temperatures | |
| Boolean | hasDensity | not (size(tableDensity, 1) == 0) | True if table tableDensity is present |
| Boolean | hasHeatCapacity | not (size(tableHeatCapacity, 1) == 0) | True if table tableHeatCapacity is present |
| Boolean | hasViscosity | not (size(tableViscosity, 1) == 0) | True if table tableViscosity is present |
| Boolean | hasVaporPressure | not (size(tableVaporPressure, 1) == 0) | True if table tableVaporPressure is present |
| Real[neta] | invTK | if size(tableViscosity, 1) > 0 then (if TinK then 1./tableViscosity[:, 1] else 1./Cv.from_degC(tableViscosity[:, 1])) else fill(0, neta) | |
| Real[:] | poly_rho | if hasDensity then Polynomials.fitting(tableDensity[:, 1], tableDensity[:, 2], npolDensity) else zeros(npolDensity + 1) | |
| Real[:] | poly_Cp | if hasHeatCapacity then Polynomials.fitting(tableHeatCapacity[:, 1], tableHeatCapacity[:, 2], npolHeatCapacity) else zeros(npolHeatCapacity + 1) | |
| Real[:] | poly_eta | if hasViscosity then Polynomials.fitting(invTK, Math.log(tableViscosity[:, 2]), npolViscosity) else zeros(npolViscosity + 1) | |
| Real[:] | poly_pVap | if hasVaporPressure then Polynomials.fitting(tableVaporPressure[:, 1], tableVaporPressure[:, 2], npolVaporPressure) else zeros(npolVaporPressure + 1) | |
| Real[:] | poly_lam | if size(tableConductivity, 1) > 0 then Polynomials.fitting(tableConductivity[:, 1], tableConductivity[:, 2], npolConductivity) else zeros(npolConductivity + 1) |
Contents
| Name | Description |
|---|---|
| Function to invert temperatures | |
| Base properties of T dependent medium | |
| Returns state record, given pressure and temperature | |
| Returns state record, given pressure and temperature | |
| Returns state record as function of p and T | |
| Returns state record, given pressure and specific enthalpy | |
| Returns state record as function of p and h | |
| Returns state record, given pressure and specific entropy | |
| Returns state record as function of p and s | |
| Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b | |
| Specific heat capacity at constant volume (or pressure) of medium | |
| Specific heat capacity at constant volume (or pressure) of medium | |
| Return dynamic viscosity as a function of the thermodynamic state record | |
| Return thermal conductivity as a function of the thermodynamic state record | |
| Compute specific entropy | |
| Return specific entropy as a function of the thermodynamic state record | |
| Compute specific enthalpy from temperature | |
| Compute specific enthalpy from temperature | |
| Compute specific enthalpy from pressure and temperature | |
| Return density as function of temperature | |
| Return temperature as a function of the thermodynamic state record | |
| Return pressure as a function of the thermodynamic state record | |
| Return density as a function of the thermodynamic state record | |
| Return specific enthalpy as a function of the thermodynamic state record | |
| Return specific internal energy as a function of the thermodynamic state record | |
| Compute temperature from pressure and specific enthalpy | |
| Compute temperature from pressure and specific enthalpy | |
| Return specific enthalpy from pressure and temperature, taking the flag enthalpyOfT into account |