Standard Equations
- gas_dynamics.standard.standard.sonic_velocity(temperature=273.15, gas=<gas_dynamics.fluids.fluid object>) float
Returns the local speed of sound.
Notes
Given a ratio of specific heats, gas constant, and temperature this function returns the locoal speed of sound. Default fluid is air.
- Parameters
gas (fluid) – A user defined fluid object. Default is air
temperature (float) – The temperature
- Returns
The local speed of sound
- Return type
float
Examples
>>> import gas_dynamics as gd >>> gd.sonic_velocity(air, temperature=500) 448.2186966202994 >>> gd.sonic_velocity(gas=Argon, temperature=300)
- gas_dynamics.standard.standard.stagnation_pressure(stagnation_pressure=None, mach=None, pressure=None, gas=<gas_dynamics.fluids.fluid object>, output=False) float
Returns the stagnation pressure given pressure and Mach number.
Notes
Given a pressure, Mach number, and a ratio of specific heats return the stagnation pressure. Alternatively, provided two arguments the function will return the missing one. Default fluid is air.
- Parameters
stagnation_pressure (float) – The stagnation pressure.
pressure (float) – The pressure.
mach (float) – The Mach number
gas (fluid) – A user defined fluid object. Default is air
output (bool) – Print out a string to verify the output is the parameter desired
- Returns
The stagnation pressure, static pressure, or mach number
- Return type
float
Examples
>>> import gas_dynamics as gd >>> pt = gd.stagnation_pressure(pressure=10, mach=1) >>> pt 18.92929158737854 >>> M = gd.stagnation_pressure(pressure=10, stagnation_pressure=pt) >>> M 1.0 >>>
- gas_dynamics.standard.standard.stagnation_temperature(temperature=None, stagnation_temperature=None, mach=None, gas=<gas_dynamics.fluids.fluid object>, output=False) float
Returns the stagnation temperature given temperature and Mach number.
Notes
Given a temperature, Mach number, and a ratio of specific heats this function returns the stagnation temperature. Alternatively, provided two arguments the function will return the missing one. Default fluid is air.
- Parameters
stagnation_temperature (float) – The stagnation temperature
temperature (float) – The temperature
mach (float) – The Mach number
gas (fluid) – A user defined fluid object. Default is air
output (bool) – Print out a string to verify the output is the parameter desired
- Returns
The stagnation temperature, temperature, or mach number
- Return type
float
Examples
>>> Tt = gd.stagnation_temperature(temperature=300, mach=1) >>> Tt 360.0 >>> M = gd.stagnation_temperature(temperature=300, stagnation_temperature=Tt) >>> M 1.0 >>>
- gas_dynamics.standard.standard.stagnation_density(density=None, stagnation_density=None, mach=None, gas=<gas_dynamics.fluids.fluid object>, output=False) float
Returns the stagnation density given density and Mach number.
Notes
Given a density, Mach number, and a ratio of specific heats this function returns the stagnation density. Alternatively, provided two arguments the function will return the missing one. Default fluid is air.
- Parameters
stagnation_density (float) – The stagnation density
density (float) – The density
mach (float) – The Mach number
gas (fluid) – A user defined fluid object. Default is air
output (bool) – Print out a string to verify the output is the parameter desired
- Returns
The stagnation temperature, temperature, or mach number
- Return type
float
Examples
- gas_dynamics.standard.standard.stagnation_pressure_ratio(mach: float, gas=<gas_dynamics.fluids.fluid object>) float
Returns the pressure ratio of p / p_t
Notes
Given a Mach number and ratio of specific heats return the relation of pressure over stagnation pressure. Default fluid is air.
- Parameters
mach (float) – The Mach number
gas (fluid) – A user defined fluid object. Default is air
- Returns
The stagnation pressure ratio
- Return type
float
Examples
>>> import gas_dynamics as gd >>> p_pt = gd.stagnation_pressure_ratio(mach=3) >>> p_pt 0.027223683703862817 >>>
- gas_dynamics.standard.standard.stagnation_temperature_ratio(mach: float, gas=<gas_dynamics.fluids.fluid object>) float
Returns the temperature ratio of T / T_t
Notes
Given a Mach number and ratio of specific heats return the relation of temperature over stagnation temperature. Default fluid is air.
- Parameters
mach (float) – The Mach number
gas (fluid) – A user defined fluid object. Default is air
- Returns
The stagnation temperature ratio
- Return type
float
Examples
>>> import gas_dynamics as gd >>> T_Tt = gd.stagnation_temperature_ratio(mach=1.5) >>> T_Tt 0.6896551724137931 >>>
- gas_dynamics.standard.standard.stagnation_density_ratio(mach: float, gas=<gas_dynamics.fluids.fluid object>) float
Returns the density ratio rho / rho_t
Notes
Given a Mach number and ratio of specific heats, return the relation of density over stagnation density. Default fluid is air.
- Parameters
mach (float) – The Mach #
gas (fluid) – A user defined fluid object. Default is air
- Returns
The stagnation density ratio
- Return type
float
Examples
>>> import gas_dynamics as gd >>> rho_rho_t = gd.stagnation_density_ratio(mach=1.5) >>> rho_rho_t 0.39498444639115327 >>>
- gas_dynamics.standard.standard.stagnation_ratio(mach: float, gas=<gas_dynamics.fluids.fluid object>) list
Return stagnation pressure, temperature, density, and choked area ratio for a mach number
Notes
Given a mach number and the fluid, return the three stagnation ratios and the ratio of the area to the choked area. Default fluid is air.
- Parameters
mach (float) – The mach number
gas (fluid) – A user defined fluid object. Default is air
- Returns
The stagnation pressure, stagnation temperature, stagnation density ratio, and choked area ratio.
- Return type
list
Examples
>>> import gas_dynamics as gd
- gas_dynamics.standard.standard.stagnation_ratio_table(range=[0, 5], step=0.1, gas=<gas_dynamics.fluids.fluid object>) str
Returns the isentropic flow tables in the given range.
Notes
Given a ratio of specific heats, print out the stagnation temperature ratio, stagnation pressure ratio, the area to choked area ratio, and the stagnation density ratio for every incremental Mach number.
- Parameters
range (list) – The starting and ending Mach numbers in a list, ex: [0, 5]
step (float) – The step size between min and max mach number
gas (fluid) – A user defined fluid object. Default is air
- Returns
The isentropic flow table
- Return type
str
Examples
>>> import gas_dynamics as gd >>> gd.stagnation_ratios(range=[0,2], step=.2, gas='nitrogen') M: 0.000 | P/Pt: 1.000 | T/Tt: 1.000 | A/A*: inf M: 0.200 | P/Pt: 0.972 | T/Tt: 0.992 | A/A*: 2.964 M: 0.400 | P/Pt: 0.896 | T/Tt: 0.969 | A/A*: 1.590 M: 0.600 | P/Pt: 0.784 | T/Tt: 0.933 | A/A*: 1.188 M: 0.800 | P/Pt: 0.656 | T/Tt: 0.887 | A/A*: 1.038 M: 1.000 | P/Pt: 0.528 | T/Tt: 0.833 | A/A*: 1.000 M: 1.200 | P/Pt: 0.412 | T/Tt: 0.776 | A/A*: 1.030 M: 1.400 | P/Pt: 0.314 | T/Tt: 0.718 | A/A*: 1.115 M: 1.600 | P/Pt: 0.235 | T/Tt: 0.661 | A/A*: 1.250 M: 1.800 | P/Pt: 0.174 | T/Tt: 0.607 | A/A*: 1.439 M: 2.000 | P/Pt: 0.128 | T/Tt: 0.556 | A/A*: 1.688 >>>
- gas_dynamics.standard.standard.mach_from_pressure_ratio(pressure_initial: float, pressure_final: float, mach_initial: float, entropy=0, gas=<gas_dynamics.fluids.fluid object>) float
Return the Mach number given a Mach number and the local pressures
Notes
Given the local pressure in two regions and the Mach number in one, return the Mach number in the second region. Default arguments are for air and isentropic flow.
- Parameters
pressure_initial (float) – Pressure in region 1
pressure_final (float) – Pressure in region 2
mach_initial (float) – Mach number in region 1
entropy (float) – Change in entropy, if any
gas (fluid) – A user defined fluid object. Default is air
- Returns
The Mach number
- Return type
float
Examples
>>> import gas_dynamics as gd >>> M2 = gd.mach_from_pressure_ratio(pressure_initial=10, pressure_final=2, mach_initial=1) >>> M2 2.1220079294384067 >>>
- gas_dynamics.standard.standard.mach_from_temperature_ratio(temperature_initial: float, temperature_final: float, mach_initial: float, gas=<gas_dynamics.fluids.fluid object>) float
Return the Mach number given a Mach number and two local temperatures
Notes
Given the local temperatures in two regions and the mach number in one, return the Mach number in the second region. Default fluid is air.
- Parameters
temperature_initial (float) – Temperature in region 1
temperature_final (float) – Temperature in region 2
mach_final (float) – Mach number in region 1
gas (fluid) – A user defined fluid object. Default is air
- Returns
The mach number
- Return type
float
Examples
>>> import gas_dynamics as gd >>> mach_final = gd.mach_from_temperature_ratio(temperature_initial=300, temperature_final=150, mach_final=1) >>> mach_final 2.6457513110645907 >>>
- gas_dynamics.standard.standard.pressure_from_mach_ratio(mach_initial: float, mach_final: float, pressure_initial: float, entropy=0, gas=<gas_dynamics.fluids.fluid object>) float
Return the pressure given a pressure in one region and the two Mach numbers
Notes
Given the Mach numbers in two regions and the pressure in one, return the missing pressure from the second region. Default arguments are for air and isentropic flow.
- Parameters
mach_initial (float) – Mach number in region 1
mach_final (float) – Mach number in region 2
pressure_initial (float) – Pressure in region 1
entropy (float) – Change in entropy, if any
gas (fluid) – A user defined fluid object. Default is air
- Returns
The local pressure
- Return type
float
Examples
>>> import gas_dynamics as gd >>> p_final = gd.pressure_from_mach_ratio(mach_initial=1, mach_final=2, pressure_initial=10) >>> p_final 2.4192491286747444 >>>
- gas_dynamics.standard.standard.temperature_from_mach_ratio(mach_initial: float, mach_final: float, temperature_initial: float, gas=<gas_dynamics.fluids.fluid object>) float
Return the temperature given a temperature in one region and the two Mach numbers
Notes
Given the local Mach number in two regions and the temperature in one, return the missing temperature from the second region. Default fluid is air.
- Parameters
mach_initial (float) – Mach number in region 1
mach_final (float) – Mach number in region 2
temperature_initial (float) – Temperature in region 1
gas (fluid) – A user defined fluid object. Default is air
- Returns
The local temperature
- Return type
float
Examples
>>> import gas_dynamics as gd >>> T_final = gd.temperature_from_mach_ratio(mach_initial=1, mach_final=2, temperature_final=297.15) >>> T_final 198.10000000000002 >>>
- gas_dynamics.standard.standard.entropy_produced(stagnation_pressure_initial: float, stagnation_pressure_final: float, gas=<gas_dynamics.fluids.fluid object>) float
Return the change in specific entropy from the stagnation pressure ratio
Notes
Given two stagnation pressures and the fluid, determine the entropy produced per unit mass.
- Parameters
stagnation_pressure_initial (float) – Stagnation pressure in region 1
stagnation_pressure_final (float) – Stagnation pressure in region 2
gas (fluid) – A user defined fluid object. Default is air
- Returns
The specific entropy
- Return type
float
Examples
>>> import gas_dynamics as gd >>> gd.entropy_produced(pt_initial=10, pt_final=9, gas='air') 30.238467993796142 #J / kg K >>>
- gas_dynamics.standard.standard.mach_area_star_ratio(mach: float, gas=<gas_dynamics.fluids.fluid object>) float
Returns the ratio of A / A* given the Mach number.
Notes
Given the Mach number and the ratio of specific heats, return the area ratio of the Mach number given to the area where Mach number is equal to 1. Default fluid is air.
- Parameters
mach (float) – Mach Number
gas (fluid) – A user defined fluid object. Default is air
- Returns
The ratio of area over choked area
- Return type
float
Examples
>>> import gas_dynamics as gd >>> A_Astar =gd.mach_area_ratio_choked(mach=3) >>> A_Astar 4.23456790123457 >>>
- gas_dynamics.standard.standard.mach_area_ratio(mach_initial: float, mach_final: float, gas=<gas_dynamics.fluids.fluid object>, entropy=0) float
Return the area ratio given the two Mach numbers
Notes
Given two mach numbers, return the area ratio required to accelerate or deaccelerate the flow accordingly. Default fluid is air.
- Parameters
mach_initial (float) – Mach number in region 1
mach_final (float) – Mach number in region 2
gas (fluid) – A user defined fluid object. Default is air
ds (float) – Entropy produced, if any
- Returns
The area ratio
- Return type
float
Examples
>>> import gas_dynamics as gd >>> A2_A1 = gd.mach_area_ratio(mach_initial=1.5, mach_final=2.5) >>> A2_A1 2.241789331255894 #area ratio >>>
- gas_dynamics.standard.standard.mach_from_area_ratio(area_ratio: float, gas=<gas_dynamics.fluids.fluid object>) list
Return the possible mach numbers given a choked area ratio A / A*
Notes
Given a ratio of area over an area where Mach = 1, return the subsonic and supersonic Mach numbers for the change area.
- Parameters
area_ratio (float) – The ratio of area over choked area
gas (fluid) – A user defined fluid object. Default is air
- Returns
The subsonic and supersonic mach numbers for the area ratio
- Return type
list
Examples
>>> import gas_dynamics as gd >>> gd.mach_from_area_ratio(2) [0.30590383418910816, 2.197198121652187] >>>
- gas_dynamics.standard.standard.mass_flux_max(stagnation_pressure: float, stagnation_temperature: float, gas=<gas_dynamics.fluids.fluid object>) float
Returns the maximum flow rate per unit choked area
Notes
Given stagnation pressure, stagnation temperature, and the fluid, return the flow rate for a Mach number equal to 1. Default fluid is air.
Units:
J / kg-K and Pa return kg/m^2
kJ / kg-K and kPa returns kg/m^2
ft-lbf / lbm-R and psi returns lbm/in^2
- Parameters
stagnation_pressure (float) – The stagnation pressure.
stagnation_temperature (float) – The stagnation temperature.
gas (fluid) – A user defined fluid object. Default is air
metric (bool) – Use metric or US standard.
- Returns
The maximum mass flux
- Return type
float
Examples
>>> mdot = 5 #kg/s >>> mdot_per_area = gd.choked_mdot(1000000, 300) #units are in Pascals >>> mdot_per_area 2333.558560606226 >>> throat_area = mdot / mdot_per_area >>> throat_area #units are in meters squared 0.0021426503214477164 >>> #alternatively, we can use the english system; psi, rankine and get lbm/s/in^2 >>> from gas_dynamics.fluids import air_us >>> air_us.units 'Btu / lbm-R' >>> flux = gd.mass_flux_max( stagnation_pressure=500, stagnation_temperature=500, gas=air_us) >>> flux 2.097208828890205 >>>
- gas_dynamics.standard.standard.mass_flux(mach: float, stagnation_pressure: float, stagnation_temperature: float, gas=<gas_dynamics.fluids.fluid object>) float
Determine mass flow rate for a mach number up to 1
Notes
Given stagnation pressure, stagnation temperature, and the fluid, return the flow rate per unit area for the given Mach number. Default fluid is air.
Units:
J / kg-K and Pa return kg/s/m^2
kJ / kg-K and kPa returns kg/s/m^2
ft-lbf / lbm-R and psi returns lbm/s/in^2
Btu / lbm-R and psi returns lbm/s/in^2
- Parameters
mach (float) – The mach number. Should not exceed 1
stagnation_pressure (float) – The stagnation pressure
stagnation_temperature (float) – The stagnation temperature
gas (fluid) – A user defined fluid object. Default is air
- Returns
The mass flux
- Return type
float
Examples
>>> #metric, input units are Pa, K, output is kg/s/m^2 >>> flux = gd.mass_flux(mach=.8, stagnation_pressure=1e6, stagnation_temperature=500) >>> flux 1741.3113452036841 >>> #us standard, input units are psi and Rankine, output units are lbm/s/in^2 >>> from gas_dynamics.fluids import air_us >>> air_us.units 'Btu / lbm-R' >>> flux = gd.mass_flux(mach=.8, stagnation_pressure=500, stagnation_temperature=500, gas=air_us) >>> flux 2.01998480961849 >>>
- gas_dynamics.standard.standard.plot_stagnation_ratios(range=[0.1, 5], step=0.01, gasses=[<gas_dynamics.fluids.fluid object>, <gas_dynamics.fluids.fluid object>, <gas_dynamics.fluids.fluid object>], dark=True)
Plot the isentropic stagnation relationships for different gasses
Notes
Plots Mach number vs T/T, P/Pt, A/A*, rho/rho_t, for a list of specific heat ratios.
- Parameters
range (list) – The starting and ending Mach # in a list, ex: [.01,5]
step (float) – The increment between min and max
gasses (list) –
A list of the user defined gas objects to be plotted
ex: gasses = [air, methane, argon]
dark (bool) – Use a dark mode plot. Default true.
Examples
>>> import gas_dynamics as gd >>> gd.plot_stagnation_ratios() >>>