Buildings.Media.Examples

Collection of models that test the media models

Information

This package contains examples that test the media packages in Buildings.Media.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Buildings.Media.Examples.AirDerivativeCheck AirDerivativeCheck Model that tests the derivative implementation
Buildings.Media.Examples.AirProperties AirProperties Model that tests the implementation of the fluid properties
Buildings.Media.Examples.AirTemperatureEnthalpyInversion AirTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.Examples.PropyleneGlycolWaterDerivativeCheck PropyleneGlycolWaterDerivativeCheck Model that tests the derivative implementation
Buildings.Media.Examples.PropyleneGlycolWaterProperties PropyleneGlycolWaterProperties Model that tests the implementation of the fluid properties
Buildings.Media.Examples.PropyleneGlycolWaterTemperatureEnthalpyInversion PropyleneGlycolWaterTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.Examples.SteamDerivativeCheck SteamDerivativeCheck Model that tests the derivative implementation
Buildings.Media.Examples.SteamProperties SteamProperties Model that tests the implementation of the steam superheated properties
Buildings.Media.Examples.SteamSaturationConsistencyCheck SteamSaturationConsistencyCheck Model that checks the consistency of saturated property functions
Buildings.Media.Examples.SteamTemperatureEnthalpyInversion SteamTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.Examples.WaterDerivativeCheck WaterDerivativeCheck Model that tests the derivative implementation
Buildings.Media.Examples.WaterProperties WaterProperties Model that tests the implementation of the fluid properties
Buildings.Media.Examples.WaterTemperatureEnthalpyInversion WaterTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.Examples.BaseClasses BaseClasses Package with base classes for Buildings.Media.Examples

Buildings.Media.Examples.AirDerivativeCheck Buildings.Media.Examples.AirDerivativeCheck

Model that tests the derivative implementation

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model AirDerivativeCheck "Model that tests the derivative implementation" extends Modelica.Icons.Example; package Medium = Buildings.Media.Air; Modelica.Units.SI.Temperature T "Temperature"; Modelica.Units.SI.MassFraction X[1] "Water vapor mass fraction"; Modelica.Units.SI.SpecificEnthalpy hLiqSym "Liquid phase enthalpy"; Modelica.Units.SI.SpecificEnthalpy hLiqCod "Liquid phase enthalpy"; Modelica.Units.SI.SpecificEnthalpy hSteSym "Water vapor enthalpy"; Modelica.Units.SI.SpecificEnthalpy hSteCod "Water vapor enthalpy"; Modelica.Units.SI.SpecificEnthalpy hAirSym "Dry air enthalpy"; Modelica.Units.SI.SpecificEnthalpy hAirCod "Dry air enthalpy"; Modelica.Units.SI.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvCod "Specific heat capacity"; constant Real convT(unit="K/s3") = 270 "Conversion factor to satisfy unit check"; constant Real convX(unit="1/s3") = 0.01 "Conversion factor to satisfy unit check"; initial equation hLiqSym = hLiqCod; hSteSym = hSteCod; hAirSym = hAirCod; cpSym = cpCod; cvSym = cvCod; equation T = 273.15+convT*time^3; X = {0.001}+convX*time^3*{1}; hLiqCod=Medium.enthalpyOfLiquid(T); der(hLiqCod)=der(hLiqSym); assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error"); hSteCod=Medium.enthalpyOfCondensingGas(T); der(hSteCod)=der(hSteSym); assert(abs(hSteCod-hSteSym) < 1E-2, "Model has an error"); hAirCod=Medium.enthalpyOfNonCondensingGas(T); der(hAirCod)=der(hAirSym); assert(abs(hAirCod-hAirSym) < 1E-2, "Model has an error"); cpCod=Medium.specificHeatCapacityCp( Medium.setState_pTX( p=1e5, T=T, X=X)); der(cpCod)=der(cpSym); assert(abs(cpCod-cpSym) < 1E-2, "Model has an error"); cvCod=Medium.specificHeatCapacityCv( Medium.setState_pTX( p=1e5, T=T, X=X)); der(cvCod)=der(cvSym); assert(abs(cvCod-cvSym) < 1E-2, "Model has an error"); end AirDerivativeCheck;

Buildings.Media.Examples.AirProperties Buildings.Media.Examples.AirProperties

Model that tests the implementation of the fluid properties

Information

This example checks thermophysical properties of the medium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.FluidProperties (Model that tests the implementation of the fluid properties).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureTMin273.15 - 30Minimum temperature for the simulation [K]
TemperatureTMax273.15 + 60Maximum temperature for the simulation [K]
PressurepMedium.p_defaultPressure [Pa]
MassFractionX[Medium.nX]Medium.X_defaultMass fraction [1]
RealerrAbs1E-8Absolute error used in the check of the state calculations

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model AirProperties "Model that tests the implementation of the fluid properties" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.FluidProperties( redeclare package Medium = Buildings.Media.Air, TMin=273.15-30, TMax=273.15+60); Modelica.Units.SI.SpecificEnthalpy hLiq "Specific enthalpy of liquid"; equation // Check the implementation of the base properties basPro.state.p=p; basPro.state.T=T; basPro.state.X[1]=X[1]; hLiq = Medium.enthalpyOfLiquid(T); if Medium.nX == 1 then assert(abs(h-hLiq) < 1e-8, "Error in enthalpy computation."); end if; end AirProperties;

Buildings.Media.Examples.AirTemperatureEnthalpyInversion Buildings.Media.Examples.AirTemperatureEnthalpyInversion

Model to check computation of h(T) and its inverse

Information

This model tests whether the inversion of temperature and enthalpy is implemented correctly. If T ≠ T(h(T)), the model stops with an error.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse with a controlleable tolerance).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 20Temperature [K]
Realtol1E-8Numerical tolerance

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model AirTemperatureEnthalpyInversion "Model to check computation of h(T) and its inverse" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion ( redeclare package Medium = Buildings.Media.Air); end AirTemperatureEnthalpyInversion;

Buildings.Media.Examples.PropyleneGlycolWaterDerivativeCheck Buildings.Media.Examples.PropyleneGlycolWaterDerivativeCheck

Model that tests the derivative implementation

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model PropyleneGlycolWaterDerivativeCheck "Model that tests the derivative implementation" extends Modelica.Icons.Example; package Medium = Buildings.Media.Antifreeze.PropyleneGlycolWater ( X_a=0.60, property_T=293.15); Modelica.Units.SI.Temperature T "Temperature"; Modelica.Units.SI.SpecificEnthalpy hLiqSym "Liquid phase enthalpy"; Modelica.Units.SI.SpecificEnthalpy hLiqCod "Liquid phase enthalpy"; Modelica.Units.SI.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvCod "Specific heat capacity"; constant Real convT(unit="K/s3") = 100 "Conversion factor to satisfy unit check"; initial equation hLiqSym = hLiqCod; cpSym = cpCod; cvSym = cvCod; equation T = 273.15+convT*time^3; hLiqCod=Medium.cp_const*(T-Medium.reference_T); der(hLiqCod)=der(hLiqSym); assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error"); cpCod=Medium.specificHeatCapacityCp( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cpCod)=der(cpSym); assert(abs(cpCod-cpSym) < 1E-2, "Model has an error"); cvCod=Medium.specificHeatCapacityCv( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cvCod)=der(cvSym); assert(abs(cvCod-cvSym) < 1E-2, "Model has an error"); end PropyleneGlycolWaterDerivativeCheck;

Buildings.Media.Examples.PropyleneGlycolWaterProperties Buildings.Media.Examples.PropyleneGlycolWaterProperties

Model that tests the implementation of the fluid properties

Information

This example checks thermophysical properties of the medium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.FluidProperties (Model that tests the implementation of the fluid properties).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureTMin273.15Minimum temperature for the simulation [K]
TemperatureTMax373.15Maximum temperature for the simulation [K]
PressurepMedium.p_defaultPressure [Pa]
MassFractionX[Medium.nX]Medium.X_defaultMass fraction [1]
RealerrAbs1E-8Absolute error used in the check of the state calculations

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model PropyleneGlycolWaterProperties "Model that tests the implementation of the fluid properties" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.FluidProperties( redeclare package Medium = Buildings.Media.Antifreeze.PropyleneGlycolWater ( X_a=0.60, property_T=293.15), TMin=273.15, TMax=373.15); equation // Check the implementation of the base properties basPro.state.p=p; basPro.state.T=T; end PropyleneGlycolWaterProperties;

Buildings.Media.Examples.PropyleneGlycolWaterTemperatureEnthalpyInversion Buildings.Media.Examples.PropyleneGlycolWaterTemperatureEnthalpyInversion

Model to check computation of h(T) and its inverse

Information

This model tests whether the inversion of temperature and enthalpy is implemented correctly. If T ≠ T(h(T)), the model stops with an error.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse with a controlleable tolerance).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 20Temperature [K]
Realtol1E-8Numerical tolerance

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model PropyleneGlycolWaterTemperatureEnthalpyInversion "Model to check computation of h(T) and its inverse" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion ( redeclare package Medium = Buildings.Media.Antifreeze.PropyleneGlycolWater ( X_a=0.60, property_T=293.15)); end PropyleneGlycolWaterTemperatureEnthalpyInversion;

Buildings.Media.Examples.SteamDerivativeCheck Buildings.Media.Examples.SteamDerivativeCheck

Model that tests the derivative implementation

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model SteamDerivativeCheck "Model that tests the derivative implementation" extends Modelica.Icons.Example; package Medium = Buildings.Media.Steam "Medim model"; Modelica.Units.SI.Temperature T "Temperature"; Modelica.Units.SI.SpecificEnthalpy hVapSym "Vapor phase specific enthalpy"; Modelica.Units.SI.SpecificEnthalpy hVapCod "Vapor phase specific enthalpy"; Modelica.Units.SI.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvCod "Specific heat capacity"; constant Real convT(unit="K/s3") = 270 "Conversion factor to satisfy unit check"; initial equation hVapSym = hVapCod; cpSym = cpCod; cvSym = cvCod; equation T = 273.15+110+convT*time^3; hVapCod=Medium.specificEnthalpy( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); assert(abs(hVapCod-hVapSym) < 1E-4 * (1+abs(hVapCod)), "Model has an error"); der(hVapCod)=der(hVapSym); cpCod=Medium.specificHeatCapacityCp( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cpCod)=der(cpSym); assert(abs(cpCod-cpSym) < 1E-4 * (1+abs(cpCod)), "Model has an error"); cvCod=Medium.specificHeatCapacityCv( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cvCod)=der(cvSym); assert(abs(cvCod-cvSym) < 1E-4 * (1+abs(cvCod)), "Model has an error"); end SteamDerivativeCheck;

Buildings.Media.Examples.SteamProperties Buildings.Media.Examples.SteamProperties

Model that tests the implementation of the steam superheated properties

Information

This example checks thermophysical properties of the medium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.PartialProperties (Partial model that contains common parameters of the fluid properties).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureTMin273.15 + 100Minimum temperature for the simulation [K]
TemperatureTMax273.15 + 160Maximum temperature for the simulation [K]
Pressurep200000Pressure [Pa]
MassFractionX[Medium.nX]Medium.X_defaultMass fraction [1]
RealerrAbs1E-8Absolute error used in the check of the state calculations

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model SteamProperties "Model that tests the implementation of the steam superheated properties" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.PartialProperties( redeclare package Medium = Buildings.Media.Steam ( p_default=200000), TMin=273.15 + 100, TMax=273.15 + 160, p=200000); Medium.ThermodynamicState state_phX "Medium state"; Medium.ThermodynamicState state_psX "Medium state"; Modelica.Media.Interfaces.Types.DerDensityByEnthalpy ddhp "Density derivative w.r.t. enthalpy"; Modelica.Media.Interfaces.Types.DerDensityByPressure ddph "Density derivative w.r.t. pressure"; equation // Check setting the states 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, errAbs, "state_phX"); checkState(state_pTX, state_psX, errAbs, "state_psX"); // Check the implementation of the functions ddhp = Medium.density_derh_p(state_pTX); ddph = Medium.density_derp_h(state_pTX); // Check the implementation of the base properties basPro.state.p=p; basPro.state.T=T; end SteamProperties;

Buildings.Media.Examples.SteamSaturationConsistencyCheck Buildings.Media.Examples.SteamSaturationConsistencyCheck

Model that checks the consistency of saturated property functions

Information

This example checks the consistency of satuated property functions across the steam and liquid water mediums. It also checks if the inversion of saturated temperature and saturated pressure is implemented correctly for the steam model.

Errors are presented as percent differences between the standard property functions - e.g medium.specificEnthalpy(saturatedState) - and the IF97 saturated property functions as the baseline.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
TemperatureTMin273.15 + 100Minimum temperature for the simulation [K]
TemperatureTMax273.15 + 179.886Maximum temperature for the simulation [K]
Realtol1E-8Numerical tolerance

Modelica definition

model SteamSaturationConsistencyCheck "Model that checks the consistency of saturated property functions" extends Modelica.Icons.Example; package MediumSte = Buildings.Media.Steam "Steam medium model"; package MediumWat = Buildings.Media.Water "Liquid water medium model"; parameter Modelica.Units.SI.Temperature TMin=273.15 + 100 "Minimum temperature for the simulation"; parameter Modelica.Units.SI.Temperature TMax=273.15 + 179.886 "Maximum temperature for the simulation"; parameter Real tol = 1E-8 "Numerical tolerance"; MediumSte.ThermodynamicState sat "Saturation state"; Modelica.Units.SI.Pressure pSat "Saturation pressure"; Modelica.Units.SI.Temperature TSat0 "Starting saturation temperature"; Modelica.Units.SI.Temperature TSat "Saturation temperature"; Modelica.Units.NonSI.Temperature_degC TSat_degC "Celsius saturation temperature"; Modelica.Units.SI.SpecificEnthalpy hlvIF97 "Enthalpy of vaporization, IF97 formulation"; Modelica.Units.SI.SpecificEnthalpy hlvWatSte "Enthalpy of vaporization, water and steam medium models"; Modelica.Units.SI.SpecificEnthalpy hlIF97 "Enthalpy of saturated liquid, IF97"; Modelica.Units.SI.SpecificEnthalpy hlWat "Enthalpy of saturated liquid, water medium"; Modelica.Units.SI.SpecificEnthalpy hvIF97 "Enthalpy of saturated vapor, IF97"; Modelica.Units.SI.SpecificEnthalpy hvSte "Enthalpy of saturated vapor, steam medium"; Real hlvErr "Enthalpy of vaporization percent error"; Real hlErr "Enthalpy of saturated liquid percent error"; Real hvErr "Enthalpy of saturated vapor percent error"; protected constant Real conv(unit="1/s") = 1 "Conversion factor to satisfy unit check"; function enthalpyOfSaturatedLiquid "Return enthalpy of saturated liquid" extends Modelica.Icons.Function; input Modelica.Units.SI.AbsolutePressure p "Pressure"; output Modelica.Units.SI.SpecificEnthalpy hl "Enthalpy of saturated liquid"; algorithm hl := Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.hl_p(p); end enthalpyOfSaturatedLiquid; function enthalpyOfSaturatedVapor "Return enthalpy of saturated liquid" extends Modelica.Icons.Function; input Modelica.Units.SI.AbsolutePressure p "Pressure"; output Modelica.Units.SI.SpecificEnthalpy hv "Enthalpy of saturated liquid"; algorithm hv := Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.hv_p(p); end enthalpyOfSaturatedVapor; function enthalpyOfVaporization "Return enthalpy of vaporization" extends Modelica.Icons.Function; input Modelica.Units.SI.AbsolutePressure p "Pressure"; output Modelica.Units.SI.SpecificEnthalpy r0 "Vaporization enthalpy"; algorithm r0 := Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.hv_p(p) - Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.hl_p(p); end enthalpyOfVaporization; equation // Compute temperatures that are used as input to the functions TSat0 = TMin + conv*time * (TMax-TMin); // Set saturation states pSat = MediumSte.saturationPressure(TSat0); TSat = MediumSte.saturationTemperature(pSat); if (time>0.1) then assert(abs(TSat-TSat0)<tol, "Error in implementation of functions.\n" + " TSat0 = " + String(TSat0) + "\n" + " TSat = " + String(TSat) + "\n" + " Absolute error: " + String(abs(TSat-TSat0)) + " K"); end if; TSat_degC =Modelica.Units.Conversions.to_degC(TSat); sat = MediumSte.setState_pTX(p=pSat, T=TSat, X=MediumSte.X_default); hlvIF97 = enthalpyOfVaporization(pSat); hlvWatSte = MediumSte.specificEnthalpy(sat) - MediumWat.specificEnthalpy(sat); hlIF97 = enthalpyOfSaturatedLiquid(pSat); hlWat = MediumWat.specificEnthalpy(sat); hvIF97 = enthalpyOfSaturatedVapor(pSat); hvSte = MediumSte.specificEnthalpy(sat); hlvErr = abs(hlvIF97 - hlvWatSte)/hlvIF97*100; hlErr = abs(hlIF97 - hlWat)/hlIF97*100; hvErr = abs(hvIF97 - hvSte)/hvIF97*100; end SteamSaturationConsistencyCheck;

Buildings.Media.Examples.SteamTemperatureEnthalpyInversion Buildings.Media.Examples.SteamTemperatureEnthalpyInversion

Model to check computation of h(T) and its inverse

Information

This model tests whether the inversion of temperature and enthalpy is implemented correctly for the steam model.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse with a controlleable tolerance).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 300Temperature [K]
Realtol1E-8Numerical tolerance

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model SteamTemperatureEnthalpyInversion "Model to check computation of h(T) and its inverse" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion ( redeclare package Medium = Buildings.Media.Steam, T0=273.15 + 300); end SteamTemperatureEnthalpyInversion;

Buildings.Media.Examples.WaterDerivativeCheck Buildings.Media.Examples.WaterDerivativeCheck

Model that tests the derivative implementation

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model WaterDerivativeCheck "Model that tests the derivative implementation" extends Modelica.Icons.Example; package Medium = Buildings.Media.Water; Modelica.Units.SI.Temperature T "Temperature"; Modelica.Units.SI.SpecificEnthalpy hLiqSym "Liquid phase enthalpy"; Modelica.Units.SI.SpecificEnthalpy hLiqCod "Liquid phase enthalpy"; Modelica.Units.SI.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.Units.SI.SpecificHeatCapacity cvCod "Specific heat capacity"; constant Real convT(unit="K/s3") = 270 "Conversion factor to satisfy unit check"; initial equation hLiqSym = hLiqCod; cpSym = cpCod; cvSym = cvCod; equation T = 273.15+convT*time^3; hLiqCod=Medium.enthalpyOfLiquid(T); der(hLiqCod)=der(hLiqSym); assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error"); cpCod=Medium.specificHeatCapacityCp( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cpCod)=der(cpSym); assert(abs(cpCod-cpSym) < 1E-2, "Model has an error"); cvCod=Medium.specificHeatCapacityCv( Medium.setState_pTX( p=1e5, T=T, X=Medium.X_default)); der(cvCod)=der(cvSym); assert(abs(cvCod-cvSym) < 1E-2, "Model has an error"); end WaterDerivativeCheck;

Buildings.Media.Examples.WaterProperties Buildings.Media.Examples.WaterProperties

Model that tests the implementation of the fluid properties

Information

This example checks thermophysical properties of the medium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.FluidProperties (Model that tests the implementation of the fluid properties).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureTMin273.15Minimum temperature for the simulation [K]
TemperatureTMax373.15Maximum temperature for the simulation [K]
PressurepMedium.p_defaultPressure [Pa]
MassFractionX[Medium.nX]Medium.X_defaultMass fraction [1]
RealerrAbs1E-8Absolute error used in the check of the state calculations

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model WaterProperties "Model that tests the implementation of the fluid properties" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.FluidProperties( redeclare package Medium = Buildings.Media.Water, TMin=273.15, TMax=373.15); equation // Check the implementation of the base properties basPro.state.p=p; basPro.state.T=T; end WaterProperties;

Buildings.Media.Examples.WaterTemperatureEnthalpyInversion Buildings.Media.Examples.WaterTemperatureEnthalpyInversion

Model to check computation of h(T) and its inverse

Information

This model tests whether the inversion of temperature and enthalpy is implemented correctly. If T ≠ T(h(T)), the model stops with an error.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse with a controlleable tolerance).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 20Temperature [K]
Realtol1E-8Numerical tolerance

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model WaterTemperatureEnthalpyInversion "Model to check computation of h(T) and its inverse" extends Modelica.Icons.Example; extends Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion ( redeclare package Medium = Buildings.Media.Water); end WaterTemperatureEnthalpyInversion;