A small library of generic volume, pipe, pump and ambient models is provided in Modelica.Media.Examples.Tests.Components to demonstrate how fluid components should be implemented that are using Modelica.Media models. This library is also used to test all media models in Modelica.Media.Examples.Tests.MediaTestModels.
Extends from Modelica.Icons.Library (Icon for library).
Name | Description |
---|---|
SimpleLiquidWater | Example for Water.SimpleLiquidWater medium model |
IdealGasH2O | IdealGas H20 medium model |
WaterIF97 | WaterIF97 medium model |
MixtureGases | Test gas mixtures |
MoistAir | Ideal gas flue gas model |
TwoPhaseWater | extension of the StandardWater package |
TestOnly | examples for testing purposes: move for final version |
Tests | Library to test that all media models simulate and fulfill the expected structural properties |
SolveOneNonlinearEquation | Demonstrate how to solve one non-linear algebraic equation in one unknown |
Extends from Modelica.Icons.Example (Icon for an example model).
Type | Name | Default | Description |
---|---|---|---|
Volume | V | 1 | Volume [m3] |
EnthalpyFlowRate | H_flow_ext | 1.e6 | Constant enthalpy flow rate into the volume [W] |
model SimpleLiquidWater "Example for Water.SimpleLiquidWater medium model" import SI = Modelica.SIunits; extends Modelica.Icons.Example; parameter SI.Volume V=1 "Volume"; parameter SI.EnthalpyFlowRate H_flow_ext=1.e6 "Constant enthalpy flow rate into the volume"; package Medium = Water.ConstantPropertyLiquidWater (SpecificEnthalpy(max=1e6)) "Medium model"; Medium.BaseProperties medium( T(start=300,fixed=true)); Medium.BaseProperties medium2; Medium.ThermodynamicState state; Real m_flow_ext2; Real der_p; Real der_T; SI.Mass m(start = 1.0); SI.InternalEnergy U; // Use type declarations from the Medium Medium.MassFlowRate m_flow_ext; Medium.DynamicViscosity eta=Medium.dynamicViscosity(medium); Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(medium); equation medium.p = 1.0e5; m = medium.d*V; U = m*medium.u; // Mass balance der(m) = m_flow_ext; // Energy balance der(U) = H_flow_ext; // Smooth state medium2.p = 1e5*time/10; medium2.T = 330; m_flow_ext2 = time - 30; state = Medium.setSmoothState(m_flow_ext2, medium.state, medium2.state, 10); der_p = der(state.p); der_T = der(state.T);end SimpleLiquidWater;
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 an example model).
model IdealGasH2O "IdealGas H20 medium model" extends Modelica.Icons.Example; package Medium = IdealGases.SingleGases.H2O "Medium model"; Medium.ThermodynamicState state "thermodynamic state record"; Medium.ThermodynamicState state2; Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state); Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state); Medium.IsentropicExponent k=Medium.isentropicExponent(state); Medium.SpecificEntropy s=Medium.specificEntropy(state); // Medium.SpecificEntropy s2=Medium.specificEntropy(state2); Medium.VelocityOfSound a=Medium.velocityOfSound(state); Real beta = Medium.isobaricExpansionCoefficient(state); Real gamma = Medium.isothermalCompressibility(state); Medium.SpecificEnthalpy h_is = Medium.isentropicEnthalpyApproximation(2.0, state); Medium.ThermodynamicState smoothState; Real m_flow_ext; Real der_p; Real der_T; equation state.p = 100000.0; state.T = 200 + 1000*time; state2.p = 2.0e5; state2.T = 500.0; // s2 = s; // Smooth state m_flow_ext = time - 0.5; smoothState = Medium.setSmoothState(m_flow_ext, state, state2, 0.1); der_p = der(smoothState.p); der_T = der(smoothState.T);end IdealGasH2O;
Extends from Modelica.Icons.Example (Icon for an example model).
Type | Name | Default | Description |
---|---|---|---|
VolumeFlowRate | dV | 0.0 | Fixed time derivative of volume [m3/s] |
MassFlowRate | m_flow_ext | 0 | Fixed mass flow rate into volume [kg/s] |
EnthalpyFlowRate | H_flow_ext | 10000 | Fixed enthalpy flow rate into volume [W] |
model WaterIF97 "WaterIF97 medium model" extends Modelica.Icons.Example; package Medium = Water.StandardWater "Medium model"; Medium.BaseProperties medium( p(start=1.e5, stateSelect=StateSelect.prefer), h(start=1.0e5, stateSelect=StateSelect.prefer), T(start = 275.0), d(start = 999.0)); Modelica.SIunits.Volume V(start = 0.1); parameter Modelica.SIunits.VolumeFlowRate dV = 0.0 "Fixed time derivative of volume"; parameter Medium.MassFlowRate m_flow_ext=0 "Fixed mass flow rate into volume"; parameter Medium.EnthalpyFlowRate H_flow_ext=10000 "Fixed enthalpy flow rate into volume"; Modelica.SIunits.Mass m "Mass of volume"; Modelica.SIunits.InternalEnergy U "Internal energy of volume"; Medium.ThermodynamicState state2; Medium.ThermodynamicState state; Real m_flow_ext2; Real der_p; Real der_T; equation der(V) = dV; m = medium.d*V; U = m*medium.u; // Mass balance der(m) = m_flow_ext; // Energy balance der(U) = H_flow_ext; // smooth states m_flow_ext2 = time - 0.5; state2 = Medium.setState_pT(1e5*(1+time), 300+200*time); state = Medium.setSmoothState(m_flow_ext2, medium.state, state2, 0.05); der_p = der(state.p); der_T = der(state.T);end WaterIF97;
Extends from Modelica.Icons.Example (Icon for an example model).
Type | Name | Default | Description |
---|---|---|---|
Volume | V | 1 | Fixed size of volume 1 and volume 2 [m3] |
MassFlowRate | m_flow_ext | 0.01 | Fixed mass flow rate in to volume 1 and in to volume 2 [kg/s] |
EnthalpyFlowRate | H_flow_ext | 5000 | Fixed enthalpy flow rate in to volume and in to volume 2 [W] |
model MixtureGases "Test gas mixtures" extends Modelica.Icons.Example; parameter Modelica.SIunits.Volume V=1 "Fixed size of volume 1 and volume 2"; parameter Modelica.SIunits.MassFlowRate m_flow_ext=0.01 "Fixed mass flow rate in to volume 1 and in to volume 2"; parameter Modelica.SIunits.EnthalpyFlowRate H_flow_ext=5000 "Fixed enthalpy flow rate in to volume and in to volume 2"; package Medium1 = Modelica.Media.IdealGases.MixtureGases.CombustionAir "Medium model"; Medium1.BaseProperties medium1(p(start=1.e5, stateSelect=StateSelect.prefer), T(start=300, stateSelect=StateSelect.prefer), X(start={0.8,0.2})); Real m1(quantity=Medium1.mediumName, start = 1.0); SI.InternalEnergy U1; Medium1.SpecificHeatCapacity cp1=Medium1.specificHeatCapacityCp(medium1.state); Medium1.DynamicViscosity eta1= Medium1.dynamicViscosity(medium1.state); Medium1.ThermalConductivity lambda1= Medium1.thermalConductivity(medium1.state); package Medium2 = Modelica.Media.IdealGases.MixtureGases.SimpleNaturalGas "Medium model"; Medium2.BaseProperties medium2(p(start=1.e5, stateSelect=StateSelect.prefer), T(start=300, stateSelect=StateSelect.prefer), X(start={0.1,0.1,0.1,0.2,0.2,0.3})); Real m2(quantity=Medium2.mediumName, start = 1.0); SI.InternalEnergy U2; Medium2.SpecificHeatCapacity cp2=Medium2.specificHeatCapacityCp(medium2.state); Medium2.DynamicViscosity eta2= Medium2.dynamicViscosity(medium2.state); Medium2.ThermalConductivity lambda2= Medium2.thermalConductivity(medium2.state); Medium2.ThermodynamicState state2 = Medium2.setState_pTX(1.005e5, 302, {0.3,0.2,0.2,0.1,0.1,0.1}); Medium2.ThermodynamicState smoothState; Real m_flow_ext2; Real der_p; Real der_T; equation medium1.X = {0.8,0.2}; m1 = medium1.d*V; U1 = m1*medium1.u; der(m1) = m_flow_ext; der(U1) = H_flow_ext; medium2.X ={0.1,0.1,0.1,0.2,0.2,0.3}; m2 = medium2.d*V; U2 = m2*medium2.u; der(m2) = m_flow_ext; der(U2) = H_flow_ext; // Smooth state m_flow_ext2 = time - 0.5; smoothState = Medium2.setSmoothState(m_flow_ext2, medium2.state, state2, 0.2); der_p = der(smoothState.p); der_T = der(smoothState.T);end MixtureGases;
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 an example model).
Type | Name | Default | Description |
---|---|---|---|
MolarMass | MMx[2] | {Medium.dryair.MM,Medium.ste... | Vector of molar masses (consisting of dry air and of steam) [kg/mol] |
model MoistAir "Ideal gas flue gas model" extends Modelica.Icons.Example; package Medium = Air.MoistAir "Medium model"; Medium.BaseProperties medium( T(start = 274.0), X(start = {0.95,0.05}), p(start = 1.0e5)); // Medium.SpecificEntropy s=Medium.specificEntropy(medium); // Medium.SpecificEnthalpy h_is = Medium.isentropicEnthalpyApproximation(medium, 2.0e5); parameter Medium.MolarMass[2] MMx = {Medium.dryair.MM,Medium.steam.MM} "Vector of molar masses (consisting of dry air and of steam)"; Medium.MolarMass MM = 1/((1-medium.X[1])/MMx[1]+medium.X[1]/MMx[2]) "Molar mass of gas part of mixture"; // Real[4] dddX=Medium.density_derX(medium,MM); Medium.ThermodynamicState state1; Medium.ThermodynamicState state2; Medium.ThermodynamicState smoothState; Real m_flow_ext; Real der_p; Real der_T; equation der(medium.p) = 0.0; der(medium.T) = 90; medium.X[Medium.Air] = 0.95; // medium.X[Medium.Water] = 0.05; // one simple assumption only for quick testing: // medium.X_liquidWater = if medium.X_sat < medium.X[2] then medium.X[2] - medium.X_sat else 0.0; // Smooth state m_flow_ext = time - 0.5; state1.p = 1.e5*(1+time); state1.T = 300 + 10*time; state1.X = {time, 1-time}; state2.p = 1.e5*(1+time/2); state2.T = 340 - 20*time; state2.X = {0.5*time, 1-0.5*time}; smoothState = Medium.setSmoothState(m_flow_ext, state1, state2, 0.2); der_p = der(smoothState.p); der_T = der(smoothState.T);end MoistAir;