LBL logo

Buildings.Media.PerfectGases.Examples

Collection of models that illustrate model use and test models

Information

This package contains examples for the use of models that can be found in Buildings.Media.PerfectGases.

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

Package Content

NameDescription
Buildings.Media.PerfectGases.Examples.MoistAirTemperatureEnthalpyInversion MoistAirTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedTemperatureEnthalpyInversion MoistAirUnsaturatedTemperatureEnthalpyInversion Model to check computation of h(T) and its inverse
Buildings.Media.PerfectGases.Examples.MoistAirComparison MoistAirComparison  
Buildings.Media.PerfectGases.Examples.MoistAirDerivativeCheck MoistAirDerivativeCheck  
Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedDerivativeCheck MoistAirUnsaturatedDerivativeCheck  
Buildings.Media.PerfectGases.Examples.TestMoistAir TestMoistAir  
Buildings.Media.PerfectGases.Examples.TestMoistAirUnsaturated TestMoistAirUnsaturated  

Buildings.Media.PerfectGases.Examples.MoistAirTemperatureEnthalpyInversion Buildings.Media.PerfectGases.Examples.MoistAirTemperatureEnthalpyInversion

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

Information

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

Parameters

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

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

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

Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedTemperatureEnthalpyInversion Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedTemperatureEnthalpyInversion

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

Information

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

Parameters

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

Connectors

TypeNameDescription
replaceable package Medium 

Modelica definition

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

Buildings.Media.PerfectGases.Examples.MoistAirComparison Buildings.Media.PerfectGases.Examples.MoistAirComparison

Information

This example compares the perfect medium model Buildings.Media.PerfectGases.MoistAir with the ideal gas model from Modelica.Media.Air.MoistAir

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

Parameters

TypeNameDefaultDescription
PressureP101325Pressure [Pa]

Modelica definition

model MoistAirComparison
  extends Modelica.Icons.Example;

   package PerfectMedium = Buildings.Media.PerfectGases.MoistAir;
   //package IdealMedium =   Modelica.Media.Air.MoistAir;
   package IdealMedium =   Buildings.Media.GasesConstantDensity.MoistAir;

    Modelica.SIunits.SpecificEnthalpy hLiqPer "Liquid phase enthalpy";
    Modelica.SIunits.SpecificEnthalpy hLiqIde "Liquid phase enthalpy";
    Modelica.SIunits.SpecificEnthalpy hStePer "Water vapor enthalpy";
    Modelica.SIunits.SpecificEnthalpy hSteIde "Water vapor enthalpy";
    Modelica.SIunits.SpecificEnthalpy hAirPer "Air enthalpy";
    Modelica.SIunits.SpecificEnthalpy hAirIde "Air enthalpy";

    Modelica.SIunits.SpecificEnthalpy hMixPer "Mixture specific enthalpy";
    Modelica.SIunits.SpecificEnthalpy hMixIde "Mixture specific enthalpy";

    Modelica.SIunits.MassFraction X[2] = {0.01, 0.09};
    Modelica.SIunits.Temperature T "Temperature";
    Modelica.SIunits.Conversions.NonSIunits.Temperature_degC T_degC 
    "Temperature";

    Real errLiq "Error liquid phase";
    Real errSte "Error steam phase";
    Real errAir "Error gas mixture";
    Real errMix "Error gas mixture";
    Real errT 
    "Error in temperature when enthalpy-temperature relation is inverted";

    parameter Modelica.SIunits.Pressure P = 101325 "Pressure";

equation 
    T_degC = 1+99*time; // exclude 0, to avoid large relative error
    T = 273.15 + T_degC;
    hLiqPer=PerfectMedium.enthalpyOfLiquid(T);
    hStePer=PerfectMedium.enthalpyOfCondensingGas(T);
    hAirPer=PerfectMedium.enthalpyOfGas(T, X);
    hLiqIde=IdealMedium.enthalpyOfLiquid(T);
    hSteIde=IdealMedium.enthalpyOfCondensingGas(T);
    hAirIde=IdealMedium.enthalpyOfGas(T, X);

    hMixPer=PerfectMedium.h_pTX(P, T, X);
    hMixIde=IdealMedium.h_pTX(P, T, X);

    errLiq * abs(hLiqIde+1E-3) = hLiqIde - hLiqPer;
    errSte * abs(hSteIde+1E-3) = hSteIde - hStePer;
    errAir * abs(hAirIde+1E-3) = hAirIde - hAirPer;
    errMix * abs(hMixIde+1E-3) = hMixIde - hMixPer;
    errT * T = T - PerfectMedium.T_phX(P, PerfectMedium.h_pTX(P, T, X), X);

    assert( abs(errLiq) < 0.09, "Error too large. Check medium model.");
    assert( abs(errSte) < 0.01, "Error too large. Check medium model.");
    assert( abs(errAir) < 0.01, "Error too large. Check medium model.");
    assert( abs(errMix) < 2.01, "Error too large. Check medium model.");
    assert( abs(errT) < 0.01, "Error too large. Check medium model.");

end MoistAirComparison;

Buildings.Media.PerfectGases.Examples.MoistAirDerivativeCheck Buildings.Media.PerfectGases.Examples.MoistAirDerivativeCheck

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 MoistAirDerivativeCheck
  extends Modelica.Icons.Example;

   package Medium = Buildings.Media.PerfectGases.MoistAir;

    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";
    constant Real conv(unit="K/s") = 1 
    "Conversion factor to satisfy unit check";
initial equation 
     hLiqSym = hLiqCod;
     hSteSym = hSteCod;
     hAirSym = hAirCod;
equation 
    hLiqCod=Medium.enthalpyOfLiquid(conv*time);
    der(hLiqCod)=der(hLiqSym);
    assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error");

    hSteCod=Medium.enthalpyOfCondensingGas(conv*time);
    der(hSteCod)=der(hSteSym);
    assert(abs(hSteCod-hSteSym) < 1E-2, "Model has an error");

    hAirCod=Medium.enthalpyOfDryAir(conv*time);
    der(hAirCod)=der(hAirSym);
    assert(abs(hAirCod-hAirSym) < 1E-2, "Model has an error");

end MoistAirDerivativeCheck;

Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedDerivativeCheck Buildings.Media.PerfectGases.Examples.MoistAirUnsaturatedDerivativeCheck

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 MoistAirUnsaturatedDerivativeCheck
  extends Modelica.Icons.Example;

   package Medium = Buildings.Media.PerfectGases.MoistAirUnsaturated;

    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";
    constant Real conv(unit="K/s") = 1 
    "Conversion factor to satisfy unit check";
initial equation 
     hLiqSym = hLiqCod;
     hSteSym = hSteCod;
     hAirSym = hAirCod;
equation 
    hLiqCod=Medium.enthalpyOfLiquid(conv*time);
    der(hLiqCod)=der(hLiqSym);
    assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error");

    hSteCod=Medium.enthalpyOfCondensingGas(conv*time);
    der(hSteCod)=der(hSteSym);
    assert(abs(hSteCod-hSteSym) < 1E-2, "Model has an error");

    hAirCod=Medium.enthalpyOfDryAir(conv*time);
    der(hAirCod)=der(hAirSym);
    assert(abs(hAirCod-hAirSym) < 1E-2, "Model has an error");

end MoistAirUnsaturatedDerivativeCheck;

Buildings.Media.PerfectGases.Examples.TestMoistAir Buildings.Media.PerfectGases.Examples.TestMoistAir

Buildings.Media.PerfectGases.Examples.TestMoistAir

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 TestMoistAir
  extends Modelica.Icons.Example;
  extends Modelica.Media.Examples.Tests.Components.PartialTestModel(
     redeclare package Medium =
          Buildings.Media.PerfectGases.MoistAir);

end TestMoistAir;

Buildings.Media.PerfectGases.Examples.TestMoistAirUnsaturated Buildings.Media.PerfectGases.Examples.TestMoistAirUnsaturated

Buildings.Media.PerfectGases.Examples.TestMoistAirUnsaturated

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 TestMoistAirUnsaturated
  extends Modelica.Icons.Example;
  extends Modelica.Media.Examples.Tests.Components.PartialTestModel(
     redeclare package Medium =
          Buildings.Media.PerfectGases.MoistAirUnsaturated);

end TestMoistAirUnsaturated;

Automatically generated Wed Feb 12 08:17:58 2014.