| Name | Description | 
|---|---|
| MoistAirComparison | |
| MoistAirDerivativeCheck | |
This example compares the perfect medium model Buildings.Media.PerfectGases.MoistAir with the ideal gas model from Modelica.Media.Air.MoistAir
| Type | Name | Default | Description | 
|---|---|---|---|
| replaceable package PerfectMedium | Buildings.Media.PerfectGases... | ||
| replaceable package IdealMedium | Modelica.Media.Air.MoistAir | ||
| Pressure | P | 101325 | Pressure [Pa] | 
| Type | Name | Description | 
|---|---|---|
| replaceable package PerfectMedium | ||
| replaceable package IdealMedium | ||
model MoistAirComparison 
  
   package PerfectMedium = Buildings.Media.PerfectGases.MoistAir;
   package IdealMedium =   Modelica.Media.Air.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.CelsiusTemperature 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 = 100*time;
    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 * hLiqIde = hLiqIde - hLiqPer;
    errSte * hSteIde = hSteIde - hStePer;
    errAir * hAirIde = hAirIde - hAirPer;
    errMix * hMixIde = hMixIde - hMixPer;
  
    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) < 0.01, "Error too large. Check medium model.");
  
    errT * T = T - PerfectMedium.T_phX(P, PerfectMedium.h_pTX(P, T, X), X);
    assert( abs(errT) < 0.01, "Error too large. Check medium model.");
  
end MoistAirComparison;
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.
| Type | Name | Default | Description | 
|---|---|---|---|
| replaceable package Medium | Buildings.Media.PerfectGases... | ||
| Type | Name | Description | 
|---|---|---|
| replaceable package Medium | ||
model MoistAirDerivativeCheck 
  
   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";
  
initial equation 
     hLiqSym = hLiqCod;
     hSteSym = hSteCod;
     hAirSym = hAirCod;
equation 
    hLiqCod=Medium.enthalpyOfLiquid(time);
    der(hLiqCod)=der(hLiqSym);
    assert(abs(hLiqCod-hLiqSym) < 1E-2, "Model has an error");
  
    hSteCod=Medium.enthalpyOfCondensingGas(time);
    der(hSteCod)=der(hSteSym);
    assert(abs(hSteCod-hSteSym) < 1E-2, "Model has an error");
  
    hAirCod=Medium.enthalpyOfDryAir(time);
    der(hAirCod)=der(hAirSym);
    assert(abs(hAirCod-hAirSym) < 1E-2, "Model has an error");
  
end MoistAirDerivativeCheck;
Buildings.Media.PerfectGases.Examples.TestMoistAir
| Type | Name | Default | Description | 
|---|---|---|---|
| replaceable package Medium | PartialMedium | Medium model | |
| AbsolutePressure | p_start | Medium.p_default | Initial value of pressure [Pa] | 
| Temperature | T_start | Medium.T_default | Initial value of temperature [K] | 
| Density | h_start | Medium.h_default | Initial value of specific enthalpy [kg/m3] | 
| Real | X_start[Medium.nX] | Medium.X_default | Initial value of mass fractions | 
| Type | Name | Description | 
|---|---|---|
| replaceable package Medium | Medium model | |
model TestMoistAir 
  extends Modelica.Media.Examples.Tests.Components.PartialTestModel(
     redeclare package Medium = 
          Buildings.Media.PerfectGases.MoistAir);
  
end TestMoistAir;