- Index
- » Programming
- » Modelica Language
- » Modelica Media Database
Modelica Media Database
Modelica Media Database
Hello Modelica Community,
i'm studiing in the seventh Semester of mechanical engineering and because of an University Project, I just started programming in Modelica. In the end it should be possible to solve different heat-transfer problems. At first I programmed a horizontal surface with natural convection.
The Programm works like I have expected. In a first step I used a medium with constant properties, but it’s not from the Modelica-database. I created one by my own.
But now I want to implement a medium that works with the ideal-gas-equation. I’ve seen there are some in the Modelica-Media-Database.
I tried to understand how to integrate such a medium, but I wasn’t very succesful.
I would be pleased, if somebody could help me with my problem.
Kind regards,
Alexander
Re: Modelica Media Database
Hello,
There are only two concepts you need to understand - BaseProperties and ThermodynamicState.
To start with you call the fluid medium first
Code:
package SomeName = Modelica.Media.IdealGases.SingleGases.FluidName;
SomeName is of your choice but the FluidName must be in the Modelica Media database.
BaseProperties: To compute the basic thermodynamic properties of the fluid
You give any two inputs to compute a bunch of basic properties[pressure, enthalpy,density, temperature,internal energy,gas constant, molar mass, vapour fraction].
Usage: To get basic properties at p=2e5 Pa, T = 298.15K of CO2
Code:
model test
parameter Real pressure=2e5, temperature=298.15;
package CO2 = Modelica.Media.IdealGases.SingleGases.CO2;
CO2.BaseProperties medium;
Real density;
equation
medium.p = pressure;
medium.T = temperature;
density = medium.d;
end test
This will calculate [medium.p, medium.h, medium.d, medium.T, medium.u, medium.R, medium.MM, medium.X]
Read the documentation to understand what other combination of inputs are allowed
ThermodynamicState: To compute additional properties that are not present in BaseProperties
You give any two inputs and compute properties you require
Usage: To get Cp and Cv at p=2e5 Pa, T=298.15 of CO2
Code:
model test
parameter Real pressure=2e5, temperature=298.15;
package CO2 = Modelica.Media.IdealGases.SingleGases.CO2;
CO2.ThermodynamicState state;
Real Cp, Cv;
equation
state = CO2.setState_pT(pressure,temperature);
Cp = CO2.specificHeatCapacityCp(state);
Cv = CO2.specificHeatCapacityCv(state);
end test
Read the documentation to understand what other functions are available for property calculation eg: dynamicViscosity(state), isentropicExponent(state), etc. and the combination of input allowed eg: setState_ps(pressure, entropy), setState_dT(density,Temperature), etc.
BaseProperties is used to calculate a bunch of basic properties at once, but ThermodynamicState is used to calculate only the properties you want
Hope this helps
- Index
- » Programming
- » Modelica Language
- » Modelica Media Database