Modelica.Media.Examples.TestOnly

examples for testing purposes: move for final version

Information



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

Package Content

NameDescription
Modelica.Media.Examples.TestOnly.MixIdealGasAir MixIdealGasAir Ideal gas air medium model
Modelica.Media.Examples.TestOnly.FlueGas FlueGas Ideal gas flue gas model
Modelica.Media.Examples.TestOnly.N2AsMix N2AsMix air and steam mixture (no condensation!, pseudo-mixture)
Modelica.Media.Examples.TestOnly.IdealGasN2 IdealGasN2 Test IdealGas.SingleMedia.N2 medium model
Modelica.Media.Examples.TestOnly.TestMedia TestMedia Test interfaces of media
Modelica.Media.Examples.TestOnly.IdealGasN2Mix IdealGasN2Mix Test IdealGas.SingleMedia.N2 medium model


Modelica.Media.Examples.TestOnly.MixIdealGasAir Modelica.Media.Examples.TestOnly.MixIdealGasAir

Ideal gas air medium model

Information


An example for using ideal gas properties and how to compute isentropic enthalpy changes. The function that is implemented is approximate, but usually very good: the second medium record medium2 is given to compare the approximation.

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

Modelica definition

model MixIdealGasAir "Ideal gas air medium model"
  extends Modelica.Icons.Example;
  package Medium = IdealGases.MixtureGases.CombustionAir "Medium model";
  Medium.BaseProperties medium(
     T(start = 200.0),
     X(start = {0.2,0.8}),
     p(start = 1.0e5));
  Medium.BaseProperties medium2(
     T(start = 300.0),
     X(start = {0.2,0.8}),
     p(start = 2.0e5));
  Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(medium.state);
  Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(medium.state);
  Medium.IsentropicExponent gamma=Medium.isentropicExponent(medium.state);
  Medium.SpecificEntropy s=Medium.specificEntropy(medium.state);
  Medium.SpecificEntropy s2=Medium.specificEntropy(medium2.state);
  Medium.VelocityOfSound a=Medium.velocityOfSound(medium.state);
  Medium.DynamicViscosity eta= Medium.dynamicViscosity(medium.state);
  Medium.ThermalConductivity lambda= Medium.thermalConductivity(medium.state);
  Real beta = Medium.isobaricExpansionCoefficient(medium.state);
  Real gamma2 = Medium.isothermalCompressibility(medium2.state);
  Medium.SpecificEnthalpy h_is = Medium.isentropicEnthalpyApproximation(2.0e5, medium);
equation 
  der(medium.p) = 1000.0;
  der(medium.T) = 1000;
  medium.X = {0.2,0.8};
  der(medium2.p) = 1.0e3;
  der(medium2.T) = 0.0;
  der(medium2.X) = {0.0,0.0};
//  s2 = s;
end MixIdealGasAir;

Modelica.Media.Examples.TestOnly.FlueGas Modelica.Media.Examples.TestOnly.FlueGas

Ideal gas flue gas model

Information


An example for using ideal gas properties and how to compute isentropic enthalpy changes. The function that is implemented is approximate, but usually very good: the second medium record medium2 is given to compare the approximation.

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

Parameters

TypeNameDefaultDescription
MolarMassMMx[4]Medium.data.MMMolar masses of flue gas [kg/mol]

Modelica definition

model FlueGas "Ideal gas flue gas  model"
  extends Modelica.Icons.Example;
  package Medium = IdealGases.MixtureGases.FlueGasLambdaOnePlus "Medium model";
  Medium.ThermodynamicState state(
     T(start = 200.0),
     X(start = {0.2,0.3,0.4,0.1}),
     p(start = 1.0e5));
  Medium.BaseProperties medium2(
     T(start = 300.0),
     X(start = {0.2,0.1,0.3,0.4}),
     p(start = 2.0e5));
  Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state);
  Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state);
  Medium.IsentropicExponent gamma=Medium.isentropicExponent(state);
  Medium.SpecificEntropy s=Medium.specificEntropy(state);
  Medium.SpecificEntropy s2=Medium.specificEntropy(medium2.state);
  Medium.VelocityOfSound a=Medium.velocityOfSound(state);
  Real beta = Medium.isobaricExpansionCoefficient(state);
  Real gamma2 = Medium.isothermalCompressibility(medium2.state);
  Medium.SpecificEnthalpy h_is = Medium.isentropicEnthalpyApproximation(2.0e5, medium2);
  parameter Medium.MolarMass[4] MMx = Medium.data.MM "Molar masses of flue gas";
  Medium.MolarMass MM =  1/sum(state.X[j]/MMx[j] for j in 1:4) "molar mass";
  Real[4] dddX=Medium.density_derX(medium2.state);
equation 
  der(state.p) = 1000.0;
  der(state.T) = 1000;
  state.X = {0.2,0.2,0.4,0.2};
  der(medium2.p) = 1.0e3;
  der(medium2.T) = 0.0;
  der(medium2.X[1:Medium.nX]) = {0.0,0.0,0.0,0.0};
end FlueGas;

Modelica.Media.Examples.TestOnly.IdealGasN2 Modelica.Media.Examples.TestOnly.IdealGasN2

Test IdealGas.SingleMedia.N2 medium model

Information



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

Parameters

TypeNameDefaultDescription
VolumeV1Size of fixed volume [m3]
MassFlowRatem_flow_ext0.01Mass flow rate into volume [kg/s]
EnthalpyFlowRateH_flow_ext5000Enthalpy flow rate into volume [W]

Modelica definition

model IdealGasN2 "Test IdealGas.SingleMedia.N2 medium model"
  extends Modelica.Icons.Example;

  parameter Modelica.SIunits.Volume V=1 "Size of fixed volume";
  parameter Medium.MassFlowRate m_flow_ext=0.01 "Mass flow rate into volume";
  parameter Medium.EnthalpyFlowRate H_flow_ext=5000 
    "Enthalpy flow rate into volume";

  package Medium = IdealGases.SingleGases.N2 "Medium model";
  // initType=Medium.Choices.Init.SteadyState,

  Medium.BaseProperties medium(preferredMediumStates=true,
    p(start=1.e5),
    T(start=300));

  Real m(quantity=Medium.mediumName, start = 1.0);
  SI.InternalEnergy U;

  Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(medium);
  Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(medium);
  Medium.IsentropicExponent gamma=Medium.isentropicExponent(medium);
  Medium.SpecificEntropy s=Medium.specificEntropy(medium);
  Medium.VelocityOfSound a=Medium.velocityOfSound(medium);
equation 

  m = medium.d*V;
  U = m*medium.u;

  // Mass balance
  der(m) = m_flow_ext;

  // Energy balance
  der(U) = H_flow_ext;
end IdealGasN2;

Modelica.Media.Examples.TestOnly.IdealGasN2Mix Modelica.Media.Examples.TestOnly.IdealGasN2Mix

Test IdealGas.SingleMedia.N2 medium model

Information



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

Parameters

TypeNameDefaultDescription
VolumeV1Size of volume [m3]
MassFlowRatem_flow_ext0.01Mass flow rate flowing into volume [kg/s]
EnthalpyFlowRateH_flow_ext5000Enthalpy flow rate flowing into volume [W]

Modelica definition

model IdealGasN2Mix "Test IdealGas.SingleMedia.N2 medium model"
  extends Modelica.Icons.Example;

  parameter Modelica.SIunits.Volume V=1 "Size of volume";
  parameter Medium.MassFlowRate m_flow_ext=0.01 
    "Mass flow rate flowing into volume";
  parameter Medium.EnthalpyFlowRate H_flow_ext=5000 
    "Enthalpy flow rate flowing into volume";

  package Medium = N2AsMix "Medium model";
  // initType=Medium.Choices.Init.SteadyState,

  Medium.BaseProperties medium(preferredMediumStates=true,
    p(start=1.e5),
    T(start=300));

  Real m(quantity=Medium.mediumName, start = 1.0);
  SI.InternalEnergy U;

  Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(medium);
  Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(medium);
  Medium.IsentropicExponent gamma=Medium.isentropicExponent(medium);
  Medium.SpecificEntropy s=Medium.specificEntropy(medium);
  Medium.VelocityOfSound a=Medium.velocityOfSound(medium);
equation 

  m = medium.d*V;
  U = m*medium.u;
  medium.X = {1.0};
  // Mass balance
  der(m) = m_flow_ext;

  // Energy balance
  der(U) = H_flow_ext;
end IdealGasN2Mix;

Automatically generated Fri Nov 12 16:31:26 2010.