Name |
Description |
FluidProperties
|
Model that tests the implementation of the fluid properties |
TestTemperatureEnthalpyInversion
|
Model to check computation of h(T) and its inverse |
This example checks thermophysical properties of the medium.
partial model FluidProperties
replaceable package Medium =
Modelica.Media.Interfaces.PartialMedium;
parameter Modelica.SIunits.Temperature TMin ;
parameter Modelica.SIunits.Temperature TMax ;
parameter Modelica.SIunits.Pressure p = Medium.p_default ;
parameter Modelica.SIunits.MassFraction X[Medium.nX]=
Medium.X_default ;
Medium.Temperature T ;
Modelica.SIunits.Conversions.NonSIunits.Temperature_degC T_degC ;
Medium.ThermodynamicState state_pTX ;
Medium.ThermodynamicState state_phX ;
Medium.ThermodynamicState state_psX ;
Modelica.SIunits.Density d ;
Modelica.SIunits.DynamicViscosity eta ;
Modelica.SIunits.SpecificEnthalpy h ;
Modelica.SIunits.SpecificInternalEnergy u ;
Modelica.SIunits.SpecificEntropy s ;
Modelica.SIunits.SpecificEnergy g ;
Modelica.SIunits.SpecificEnergy f ;
Modelica.SIunits.SpecificEnthalpy hIse ;
Modelica.Media.Interfaces.Types.IsobaricExpansionCoefficient beta ;
Modelica.SIunits.IsothermalCompressibility kappa ;
Modelica.Media.Interfaces.Types.DerDensityByPressure ddpT ;
Modelica.Media.Interfaces.Types.DerDensityByTemperature ddTp ;
Modelica.SIunits.Density[Medium.nX] dddX ;
Modelica.SIunits.SpecificHeatCapacity cp ;
Modelica.SIunits.SpecificHeatCapacity cv ;
Modelica.SIunits.ThermalConductivity lambda ;
Modelica.SIunits.AbsolutePressure pMed ;
Medium.Temperature TMed ;
Modelica.SIunits.MolarMass MM ;
Medium.BaseProperties basPro ;
protected
constant Real conv(unit="1/s") = 1 ;
function checkState
input Medium.ThermodynamicState state1 ;
input Medium.ThermodynamicState state2 ;
input String message ;
algorithm
assert(
abs(
Medium.temperature(state1)-
Medium.temperature(state2))
< 1e-8, "Error in temperature of " + message);
assert(
abs(
Medium.pressure(state1)-
Medium.pressure(state2))
< 1e-8, "Error in pressure of " + message);
end checkState;
equation
T = TMin + conv*time * (TMax-TMin);
T_degC =
Modelica.SIunits.Conversions.to_degC(T);
state_pTX =
Medium.setState_pTX(p=p, T=T, X=X);
state_phX =
Medium.setState_phX(p=p, h=h, X=X);
state_psX =
Medium.setState_psX(p=p, s=s, X=X);
checkState(state_pTX, state_phX, "state_phX");
checkState(state_pTX, state_psX, "state_psX");
d =
Medium.density(state_pTX);
eta =
Medium.dynamicViscosity(state_pTX);
h =
Medium.specificEnthalpy(state_pTX);
u =
Medium.specificInternalEnergy(state_pTX);
s =
Medium.specificEntropy(state_pTX);
g =
Medium.specificGibbsEnergy(state_pTX);
f =
Medium.specificHelmholtzEnergy(state_pTX);
hIse =
Medium.isentropicEnthalpy(p, state_pTX);
beta =
Medium.isobaricExpansionCoefficient(state_pTX);
kappa =
Medium.isothermalCompressibility(state_pTX);
ddpT =
Medium.density_derp_T(state_pTX);
ddTp =
Medium.density_derT_p(state_pTX);
dddX =
Medium.density_derX(state_pTX);
cp =
Medium.specificHeatCapacityCp(state_pTX);
cv =
Medium.specificHeatCapacityCv(state_pTX);
lambda =
Medium.thermalConductivity(state_pTX);
pMed =
Medium.pressure(state_pTX);
assert(
abs(p-pMed) < 1e-8, "Error in pressure computation.");
TMed =
Medium.temperature(state_pTX);
assert(
abs(T-TMed) < 1e-8, "Error in temperature computation.");
MM =
Medium.molarMass(state_pTX);
assert(
abs(h-basPro.h) < 1e-8, "Error in enthalpy computation in BaseProperties.");
assert(
abs(u-basPro.u) < 1e-8, "Error in internal energy computation in BaseProperties.");
end FluidProperties;