Basic Tools for Quasi-1D Steady Compressible Flow

This notebook demonstrates the basic syntax for some tools for computing quasi-1d steady compressible flow.

Set up the module

using Gasdynamics1D

Setting basic properties and states

We can set thermodynamic properties and states in a straightforward manner. However, it is important to remember that we have to explicitly define the type of property or state we are setting. Examples below will show how this works.

Let's say we wish to set the pressure to 10000 Pa. Pascals are the default units of pressure, as can be verified by using the default_unit function:

default_unit(Pressure)
Pa

So if we do not specify the unit, it is automatically set to the default unit:

Pressure(10000)
Pressure = 10000.0 Pa

We can set a quantity with another unit using the syntax u"[unit]". For example, if we set pressure to 1 atm, it will still convert it to the default unit.

p = Pressure(1u"atm")
Pressure = 101325.0 Pa

However, we can always report the quantity in some desired units with the value function:

value(p,u"atm")
1.0 atm
value(p,u"psi")
14.695948775513449 psi
value(p,u"kPa")
101.325 kPa

Other thermodynamic quantities

We can set most any other thermodynamic quantity in similar fashion:

T = Temperature(20u"°C")
Temperature = 293.15 K
T0 = StagnationTemperature(20)
StagnationTemperature = 20.0 K
MachNumber(2.0)
MachNumber = 2.0
Enthalpy(50)
Enthalpy = 50.0 J kg^-1
Entropy(10)
Entropy = 10.0 J kg^-1 K^-1
Area(50u"cm^2")
Area = 0.005 m^2
Length(5)
Length = 5.0 m

and others...

Gas properties

We can set the properties of the gas that we are analyzing. (Note: It is assumed that the gas is perfect.)

SpecificHeatRatio(1.3)
SpecificHeatRatio = 1.3
GasConstant(320)
GasConstant = 320.0 J kg^-1 K^-1

and we can define a gas with these values:

gas = PerfectGas(γ=SpecificHeatRatio(1.3),R=GasConstant(320))
Perfect gas with
   Density = 1.0988742842269652 kg m^-3
   Viscosity = 1.79e-5 kg m^-1 s^-1
   Specific heat ratio = 1.3
   Gas constant = 320.0 J kg^-1 K^-1
   cp = 1386.6666666666665 J kg^-1 K^-1
   cv = 1066.6666666666665 J kg^-1 K^-1
   at reference temp 288.15 K

We have pre-defined gases (at standard conditions), as well, for convenience:

Air
Perfect gas with
   Density = 1.225225682761773 kg m^-3
   Viscosity = 1.79e-5 kg m^-1 s^-1
   Specific heat ratio = 1.4
   Gas constant = 287.0 J kg^-1 K^-1
   cp = 1004.5000000000001 J kg^-1 K^-1
   cv = 717.5000000000001 J kg^-1 K^-1
   at reference temp 288.15 K
He
Perfect gas with
   Density = 0.1663929559017017 kg m^-3
   Viscosity = 1.94e-5 kg m^-1 s^-1
   Specific heat ratio = 1.6666666666666667
   Gas constant = 2077.26439404998 J kg^-1 K^-1
   cp = 5193.160985124951 J kg^-1 K^-1
   cv = 3115.8965910749703 J kg^-1 K^-1
   at reference temp 293.15 K
O2
Perfect gas with
   Density = 1.330236729981785 kg m^-3
   Viscosity = 2.04e-5 kg m^-1 s^-1
   Specific heat ratio = 1.395
   Gas constant = 259.83507666343445 J kg^-1 K^-1
   cp = 917.645397330357 J kg^-1 K^-1
   cv = 657.8103206669226 J kg^-1 K^-1
   at reference temp 293.15 K
CO2
Perfect gas with
   Density = 1.8295483760898261 kg m^-3
   Viscosity = 1.47e-5 kg m^-1 s^-1
   Specific heat ratio = 1.289
   Gas constant = 188.9221226574242 J kg^-1 K^-1
   cp = 842.631889638131 J kg^-1 K^-1
   cv = 653.7097669807068 J kg^-1 K^-1
   at reference temp 293.15 K
H2
Perfect gas with
   Density = 0.08380753297425789 kg m^-3
   Viscosity = 8.84e-6 kg m^-1 s^-1
   Specific heat ratio = 1.405
   Gas constant = 4124.237409798234 J kg^-1 K^-1
   cp = 14307.539656213627 J kg^-1 K^-1
   cv = 10183.302246415391 J kg^-1 K^-1
   at reference temp 293.15 K
N2
Perfect gas with
   Density = 1.164550567569978 kg m^-3
   Viscosity = 1.76e-5 kg m^-1 s^-1
   Specific heat ratio = 1.4
   Gas constant = 296.80305204485137 J kg^-1 K^-1
   cp = 1038.81068215698 J kg^-1 K^-1
   cv = 742.0076301121286 J kg^-1 K^-1
   at reference temp 293.15 K
Ar
Perfect gas with
   Density = 1.6227671732556135 kg m^-3
   Viscosity = 2.27e-5 kg m^-1 s^-1
   Specific heat ratio = 1.6666666666666667
   Gas constant = 208.1321372322329 J kg^-1 K^-1
   cp = 520.3303430805823 J kg^-1 K^-1
   cv = 312.1982058483494 J kg^-1 K^-1
   at reference temp 300.0 K

Equations of state

We can apply the equation of state for a perfect gas to determine other quantities. For example, suppose we have carbon dioxide at 1.2 kg/m^3 and 80 kPa. What is the temperature?

T = Temperature(Density(1.2),Pressure(80u"kPa"),gas=CO2)
Temperature = 352.87908969535823 K

You can switch the order of the arguments and it will still work:

T = Temperature(Pressure(80u"kPa"),Density(1.2),gas=CO2)
Temperature = 352.87908969535823 K

Then we can calculate the enthalpy, for example:

Enthalpy(T,gas=CO2)
Enthalpy = 297347.17416378326 J kg^-1

What is the speed of sound of air at 20 degrees Celsius? Let's find out:

SoundSpeed(Temperature(20u"°C"),gas=Air)
SoundSpeed = 343.20208332701003 m s^-1

How about oxygen?

SoundSpeed(Temperature(20u"°C"),gas=O2)
SoundSpeed = 325.97248434464626 m s^-1

Note: the default gas is air. So if you do not put the gas= argument in, it will assume air at standard conditions.


This page was generated using Literate.jl.