IEA EBC Annex 60 EBC logo

Annex60.Media.Examples

Collection of models that test the media models

Information

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

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

Package Content

Name Description
Annex60.Media.Examples.AirDerivativeCheck AirDerivativeCheck Model that tests the derivative implementation
Annex60.Media.Examples.AirProperties AirProperties Model that tests the implementation of the fluid properties
Annex60.Media.Examples.AirTemperatureEnthalpyInversion AirTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Annex60.Media.Examples.AirTestImplementation AirTestImplementation Model that tests the medium implementation
Annex60.Media.Examples.WaterDerivativeCheck WaterDerivativeCheck Model that tests the derivative implementation
Annex60.Media.Examples.WaterProperties WaterProperties Model that tests the implementation of the fluid properties
Annex60.Media.Examples.WaterTemperatureEnthalpyInversion WaterTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Annex60.Media.Examples.WaterTestImplementation WaterTestImplementation Model that tests the medium implementation
Annex60.Media.Examples.BaseClasses BaseClasses Package with base classes for Annex60.Media.Examples

Annex60.Media.Examples.AirDerivativeCheck Annex60.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 = Annex60.Media.Air; Modelica.SIunits.Temperature T "Temperature"; Modelica.SIunits.MassFraction X[1] "Water vapor mass fraction"; Modelica.SIunits.SpecificEnthalpy hLiqSym "Liquid phase enthalpy"; Modelica.SIunits.SpecificEnthalpy hLiqCod "Liquid phase enthalpy"; Modelica.SIunits.SpecificEnthalpy hSteSym "Water vapor enthalpy"; Modelica.SIunits.SpecificEnthalpy hSteCod "Water vapor enthalpy"; Modelica.SIunits.SpecificEnthalpy hAirSym "Dry air enthalpy"; Modelica.SIunits.SpecificEnthalpy hAirCod "Dry air enthalpy"; Modelica.SIunits.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.SIunits.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.SIunits.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.SIunits.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;

Annex60.Media.Examples.AirProperties Annex60.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), Annex60.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]

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model AirProperties "Model that tests the implementation of the fluid properties" extends Modelica.Icons.Example; extends Annex60.Media.Examples.BaseClasses.FluidProperties( redeclare package Medium = Annex60.Media.Air, TMin=273.15-30, TMax=273.15+60); Modelica.SIunits.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;

Annex60.Media.Examples.AirTemperatureEnthalpyInversion Annex60.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), Annex60.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 20Temperature [K]

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

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

Annex60.Media.Examples.AirTestImplementation Annex60.Media.Examples.AirTestImplementation

Model that tests the medium implementation

Annex60.Media.Examples.AirTestImplementation

Information

This is a simple test for the medium model. It uses the test model described in Modelica.Media.UsersGuide.MediumDefinition.TestOfMedium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Modelica.Media.Examples.Tests.Components.PartialTestModel (Basic test model to test a medium).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model
AbsolutePressurep_startMedium.p_defaultInitial value of pressure [Pa]
TemperatureT_startMedium.T_defaultInitial value of temperature [K]
SpecificEnthalpyh_startMedium.h_defaultInitial value of specific enthalpy [J/kg]
RealX_start[Medium.nX]Medium.X_defaultInitial value of mass fractions

Connectors

TypeNameDescription
replaceable package MediumMedium model

Modelica definition

model AirTestImplementation "Model that tests the medium implementation" extends Modelica.Icons.Example; extends Modelica.Media.Examples.Tests.Components.PartialTestModel( redeclare package Medium = Annex60.Media.Air); end AirTestImplementation;

Annex60.Media.Examples.WaterDerivativeCheck Annex60.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 = Annex60.Media.Water; Modelica.SIunits.Temperature T "Temperature"; Modelica.SIunits.SpecificEnthalpy hLiqSym "Liquid phase enthalpy"; Modelica.SIunits.SpecificEnthalpy hLiqCod "Liquid phase enthalpy"; Modelica.SIunits.SpecificHeatCapacity cpSym "Specific heat capacity"; Modelica.SIunits.SpecificHeatCapacity cpCod "Specific heat capacity"; Modelica.SIunits.SpecificHeatCapacity cvSym "Specific heat capacity"; Modelica.SIunits.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;

Annex60.Media.Examples.WaterProperties Annex60.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), Annex60.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]

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

model WaterProperties "Model that tests the implementation of the fluid properties" extends Modelica.Icons.Example; extends Annex60.Media.Examples.BaseClasses.FluidProperties( redeclare package Medium = Annex60.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;

Annex60.Media.Examples.WaterTemperatureEnthalpyInversion Annex60.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), Annex60.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMedium 
TemperatureT0273.15 + 20Temperature [K]

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

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

Annex60.Media.Examples.WaterTestImplementation Annex60.Media.Examples.WaterTestImplementation

Model that tests the medium implementation

Annex60.Media.Examples.WaterTestImplementation

Information

This is a simple test for the medium model. It uses the test model described in Modelica.Media.UsersGuide.MediumDefinition.TestOfMedium.

Extends from Modelica.Icons.Example (Icon for runnable examples), Modelica.Media.Examples.Tests.Components.PartialTestModel (Basic test model to test a medium).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model
AbsolutePressurep_startMedium.p_defaultInitial value of pressure [Pa]
TemperatureT_startMedium.T_defaultInitial value of temperature [K]
SpecificEnthalpyh_startMedium.h_defaultInitial value of specific enthalpy [J/kg]
RealX_start[Medium.nX]Medium.X_defaultInitial value of mass fractions

Connectors

TypeNameDescription
replaceable package MediumMedium model

Modelica definition

model WaterTestImplementation "Model that tests the medium implementation" extends Modelica.Icons.Example; extends Modelica.Media.Examples.Tests.Components.PartialTestModel( redeclare package Medium = Annex60.Media.Water); end WaterTestImplementation;

http://iea-annex60.org