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.Obsolete.Media.PerfectGases.
Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).
Package Content
Information
This example compares the perfect medium model
Buildings.Obsolete.Media.PerfectGases.MoistAir
with the ideal gas model
from Modelica.Media.Air.MoistAir
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
Pressure | P | 101325 | Pressure [Pa] |
Modelica definition
model MoistAirComparison
extends Modelica.Icons.Example;
package PerfectMedium =
Buildings.Obsolete.Media.PerfectGases.MoistAir;
//package IdealMedium = Modelica.Media.Air.MoistAir;
package IdealMedium =
Buildings.Obsolete.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;
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 to check computation of h(T) and its inverse
Information
Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.Media.Examples.BaseClasses.TestTemperatureEnthalpyInversion (Model to check computation of h(T) and its inverse).
Parameters
Connectors
Type | Name | Description |
replaceable package Medium | |
Modelica definition
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
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] |
SpecificEnthalpy | h_start | Medium.h_default | Initial value of specific enthalpy [J/kg] |
Real | X_start[Medium.nX] | Medium.X_default | Initial value of mass fractions |
Connectors
Type | Name | Description |
replaceable package Medium | Medium model |
Modelica definition
Automatically generated Mon Jul 13 14:36:32 2015.