Gas Dynamics Tools.
billig.py: Fred Billig’s correlations for hypersonic shockwave shapes.
These are a direct implementation of equations 5.36, 5.37 and 5.38 from J.D. Anderson’s text Hypersonic and High Temperature Gas Dynamics
Calculates the normalised standoff distance.
Calculates the normalised radius of curvature of the shock.
Determine the xcoordinate of a point on the shock wave.
Parameters: 


It is assumed that, for the ideal gas, gamma=1.4. That’s the only value relevant to the data used for Billig’s correlations.
Determine the ycoordinate of a point on the shock wave.
Parameters: 


It is assumed that, for the ideal gas, gamma=1.4. That’s the only value relevant to the data used for Billig’s correlations.
ideal_gas_flow.py: Onedimensional steady flow of an ideal gas.
Contents:
Onedimensional flows:
 Isentropic flow relations. State zero (0) refers to the stagnation condition. State star is the sonic (throat) condition.
 1D (Normal) Shock Relations State 1 is before the shock and state 2 after the shock. Velocities are in a shockstationary frame.
 1D flow with heat addition (Rayleighline) State star is the (hypothetical) sonic condition.
Twodimensional flows:
 PrandtlMeyer functions
 Obliqueshock relations
 TaylorMaccoll conical flow
Area ratio A/Astar for an isentropic, quasionedimensional flow.
Parameters: 


Returns:  A/Astar 
Total to static temperature ratio for an adiabatic flow.
Parameters: 


Returns:  T0/T 
Total to static pressure ratio for an isentropic flow.
Parameters: 


Returns:  p0/p 
Stagnation to freestream density ratio for an isentropic flow.
Parameters: 


Returns:  r0/r 
Mach number M2 after a normal shock.
Parameters: 


Returns:  M2 
Density ratio r2/r1 across a normal shock.
Parameters: 


Returns:  r2/r1 
Velocity ratio u2/u1 across a normal shock.
Parameters: 


Returns:  u2/u1 
Static pressure ratio p2/p1 across a normal shock.
Parameters: 


Returns:  p2/p1 
Static temperature ratio T2/T1 across a normal shock.
Parameters: 


Returns:  T2/T1 
Stagnation pressure ratio p02/p01 across a normal shock.
Parameters: 


Returns:  p02/p01 
Nodimensional entropy change ds across a normal shock.
Parameters: 


Returns:  ds/Cv 
Total temperature ratio for flow with heat addition.
Parameters: 


Returns:  T0/T0star where T0 is the total temperature of the initial flow and T0star is the total temperature that would be achieved if enough heat is added to get to sonic conditions. 
Computes M from Total Temperature ratio for Rayleighline flow.
Parameters: 


Returns:  initial Mach number of flow 
Note that supersonic flow is assumed for the initial guess.
Static temperature ratio T/Tstar for Rayleighline flow.
Parameters: 


Returns:  T/Tstar where T is the static temperature of the initial flow and Tstar is the static temperature that would be achieved if enough heat is added to get to sonic conditions. 
Static pressure ratio p/pstar for Rayleighline flow.
Parameters: 


Returns:  p/pstar where p is the static pressure of the initial flow and pstar is the static pressure that would be achieved if enough heat is added to get to sonic conditions. 
Density ratio r/rstar for Rayleighline flow.
Parameters: 


Returns:  r/rstar where r is the density of the initial flow and rstar is the density that would be achieved if enough heat is added to get to sonic conditions. 
Stagnation pressure ratio p0/p0star for Rayleighline flow.
Parameters: 


Returns:  p0/p0star where p0 is the total pressure of the initial flow and p0star is the total pressure that would be achieved if enough heat is added to get to sonic conditions. 
PrandtlMeyer function.
Parameters: 


Returns:  PrandtlMeyer function value (in radians) 
Inverse PrandtlMeyer function.
Parameters: 


Returns:  Mach number 
Solves the equation PM1(m, g)  nu = 0, assuming supersonic flow.
Oblique shock wave angle.
Parameters: 


Returns:  shock angle with respect to initial flow direction (radians) 
Compute the deflection angle given the shock wave angle.
Parameters: 


Returns:  theta, flow deflection angle (radians) 
Mach number after an oblique shock.
Parameters: 


Returns:  M2, Mach number in flow after the shock 
Density ratio r2/r1 across an oblique shock.
Parameters: 


Returns:  r2/r1 
Flowspeed ratio u2/u1 across an oblique shock.
Parameters: 


Returns:  u2/u1 
Static pressure ratio p2/p1 across an oblique shock.
Parameters: 


Returns:  p2/p1 
Static temperature ratio T2/T1 across an oblique shock.
Parameters: 


Returns:  T2/T1 
Ratio of stagnation pressures p02/p01 across an oblique shock.
Parameters: 


Returns:  p02/p01 
Compute the conesurface angle and conditions given the shock wave angle.
Parameters: 


Returns:  tuple of theta_c, V_c, p_c, T_c: theta_c is stream deflection angle in radians V_c is the conesurface speed of gas in m/s p_c is the conesurface pressure T_c is the conesurface static temperature 
The computation starts with the obliqueshock jump and then integrates across theta until V_theta goes through zero. The cone surface corresponds to V_theta == 0.
Compute the conical shock wave angle given the conesurface deflection angle.
Parameters: 


Returns:  shock wave angle wrt incoming stream direction (in radians) 
Compute the conical shock wave angle given the conesurface deflection angle and free stream Mach number.
Parameters: 


Returns:  shock wave angle wrt incoming stream direction (in radians) 
cea2_gas.py: Thermodynamic properties of a gas mixture in chemical equilibrium.
It interfaces to the CEA code by writing a small input file, running the CEA code as a child process and then reading the results from the CEA plot file.
See the report:
Bonnie J. McBride and Sanford Gordon
Computer Program for Calculation of Complex Chemical Equilibrium
Compositions and Applications II. Users Manual and Program
Description. NASA Reference Publication 1311, June 1996.
for details of the input and output file formats.
Locates an executable file, if available somewhere on the PATH.
Parameters:  name – may be a simple file name or fullyqualified path. 

Returns:  the full program name, if is is found and is executable, else None. 
Runs the CEA program on the specified job.
Parameters: 


Clean up the CEA2 shorthand notation for exponential format.
CEA2 seems to write exponentialformat numbers in a number of ways:
Provides the equation of state for the gas.
Computes the gas state, taking into account the hightemperature effects.
It does this by writing a suitable input file for the CEA code, calling that code and then extracting the relevant results from the CEA output or plot file.
Parameters: 


Returns:  None, but does update the contents of the gas state as a sideeffect. 
Set up a new object, from either a name of species list.
Parameters: 


Clone the current Gas object to make another, just the same.
Returns:  the new Gas object. 

Gets a list of mole or massfractions for the specified species.
Parameters:  speciesList – the species names for which we want a list of fractions. 

Returns:  list of floats representing the fractions of each species in the mix Note that the massfractions or molefractions are returned, based on the value of outputUnits in the Gas object. 
Fills out gas state from given pressure and temperature.
Parameters: 


Fills out gas state from given pressure and enthalpy.
Parameters: 


Fills out gas state from given pressure and specific entropy.
Parameters: 


Fills out gas state from given density and temperature.
Parameters: 


Fills out gas state from given density and internal energy.
Parameters: 


Compute the gas state after being processed by an incident shock.
Parameters:  Us – shock speed into quiescent gas, m/s 

Returns:  a reference to the postshock gas state (self) 
Writes the gas state data to the specified stream.
Manufacture a Gas object from a small library of options.
Parameters:  gasName – one of the names for the special cases set out below 

Returns:  a Gas object 
Returns:  the list of gases available in make_gas_from_name() 

Creates the CEA reactants dictionary from a list of species in the lib/gas format :param species_list: lib/gas species list
Creates a list of mass or mole fractions for a species in lib/gas form from the CEA species_data dictionary :param sp: a single lib/gas species :param species_data: the CEA species_data dictionary
Determines the ‘with_ions’ flag from a list of species in the lib/gas format :param species_list: lib/gas species list
libgas_gas.py: access the gas models from the libgas library using the cfpylib/gasdyn interface.
Provides the place to hold the libgas gas data object and gas model object.
Set up the libgas model from the generic input file.
Parameters: 


Rowan’s thermochemistry module uses the Lua file to define the gas model, in detail. There are so many options for this input file that we whimp out and delegate the construction of a suitable file to other tools. One such tool is gasmodel.py which, in turn, delegates all of it’s work to Rowan’s Lua program gasfile.lua.
Clone the current Gas object to make another, just the same.
Returns:  the new Gas object. 

Compute the thermodynamic state from given pressure and temperature.
Parameters: 


Compute the thermodynamic state from given pressure and entropy
Parameters: 


Compute the thermodynamic state from given density and temperature.
Parameters: 


Writes the gas state data to the specified stream.
Manufacture a Gas object from a small library of options.
Parameters:  gasName – one of the names for the special cases set out below. We might also specify the details of the gas via a Lua gasmodel file or via a compressed lookup table, again in Lua format. 

Returns:  the list of gases available in make_gas_from_name() 

ideal_gas.py: Thermodynamic properties of an ideal gas.
This module provides a lookalike Gas class for use in the gas flow functions. Whereever cea2_gas works, so should this.
Provides the place to keep property data for the ideal gas.
Set up a new object, from either a name of species list.
Parameters: 


Clone the current Gas object to make another, just the same.
Returns:  the new Gas object. 

Fills out gas state from given pressure and temperature.
Parameters: 


Fills out gas state from given pressure and enthalpy.
Parameters: 


Fills out gas state from given pressure and specific entropy.
Parameters: 


Fills out gas state from given density and temperature.
Parameters: 


Writes the gas state data to the specified stream.
Manufacture a Gas object from a small library of options.
Parameters:  gasName – one of the names for the special cases set out below 

Returns:  the list of gases available in make_gas_from_name() 

gas_flow.py – Gas flow calculations using CEA2 or ideal Gas objects.
Computes postshock conditions in the shock frame, assuming ideal gas.
Parameters: 


Returns:  the postshock gas speed, V2 in the shockreference frame, Vg in the lab frame. 
Computes postshock conditions, using hightemperature gas properties and a shockstationary frame.
Parameters: 


Returns:  the postshock gas speed, V2 in the shockreference frame, Vg in the lab frame. 
Computes postshock conditions, using hightemperature gas properties and a shockstationary frame.
Parameters: 


Returns:  a tuple of the incident shock speed, V1; the postshock gas speed, V2 in the shockreference frame; Vg in the lab frame; and the post shock state state2. 
Computes state5 which has brought the gas to rest at the end of the shock tube.
Parameters: 


Returns:  Vr, the reflected shock speed in the lab frame. 
Given a stagnation condition state0, expand to a new pressure.
Parameters: 


Returns:  new gas state and the corresponding velocity (in m/s) of the expanded stream. 
Given a freestream condition and velocity, compute the corresponding stagnant condition at which the gas is brought to rest isentropically.
Parameters: 


Returns:  Gas object specifying gas total conditions (isentropic, stagnant) 
Given a freestream condition, compute the corresponding Pitot condition at which the gas is brought to rest, possibly through a shock.
Parameters: 


Returns:  Gas object specifying gas impact conditions, possibly after processing be a normal shock. 
Given station 1 condition, velocity and arearatio A2/A1, compute the steady, isentropic condition at station 2.
Parameters: 


Returns:  tuple (V2, state2) of conditions at station 2 
Process the gas isentropically, following a characteristic line.
See Section 7.6 Finite Nonlinear Waves in JD Anderson’s text Modern Compressible Flow.
Parameters: 


Returns:  flow condition after processing, as tuple (V2, state2) 
Process the gas isentropically, following a characteristic line.
See Section 7.6 Finite Nonlinear Waves in JD Anderson’s text Modern Compressible Flow.
Parameters: 


Returns:  flow condition after processing, as tuple (V2, state2) 
Compute the deflection angle and postshock conditions given the shock wave angle.
Parameters: 


Returns:  tuple of theta, V2 and state2: theta is stream deflection angle in radians V2 is postshock speed of gas in m/s state2 is postshock gas state 
Compute the oblique shock wave angle given the deflection angle.
Parameters: 


Returns:  shock wave angle wrt incoming stream direction (in radians) 
Compute the conesurface angle and conditions given the shock wave angle.
Parameters: 


Returns:  tuple of theta_c, V_c and state_c: theta_c is stream deflection angle in radians V_c is conesurface speed of gas in m/s state_c is conesurface gas state 
The computation starts with the obliqueshock jump and then integrates across theta until V_theta goes through zero. The cone surface corresponds to V_theta == 0.
Compute the conical shock wave angle given the conesurface deflection angle.
Parameters: 


Returns:  shock wave angle wrt incoming stream direction (in radians) 
sutherland.py – Sutherland form of viscosity and thermal conductivity for a few gases.
Species available: Air, N2, O2, H2, CO2, CO, Ar.
Reference for coefficients: White FM (2006) Viscous Fluid Flow, pp.28
Sutherland’s expression relating the quantity, at temperature T, to the value at the reference temperature.
Parameters: 


Returns:  ratio of property at temperature T to reference value. 
Coefficient of dynamic viscosity.
Parameters: 


Returns:  coefficient of dynamic viscosity, in Pa.s. 
Coefficient of thermal conductivity.
Parameters: 


Returns:  thermal conductivity, in W/(m.K) 