Shockwaves
Normal Shock Waves
- pygasflow.shockwave.pressure_ratio(M1, gamma=1.4)[source]
Compute the static pressure ratio \(\frac{P_{2}}{P_{1}}\).
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Pressure Ratio \(\frac{P_{2}}{P_{1}}\)
- pygasflow.shockwave.temperature_ratio(M1, gamma=1.4)[source]
Compute the static temperature ratio \(\frac{T_{2}}{T_{1}}\).
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Temperature Ratio \(\frac{T_{2}}{T_{1}}\)
- pygasflow.shockwave.density_ratio(M1, gamma=1.4)[source]
Compute the density ratio \(\frac{\rho_{2}}{\rho_{1}}\).
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Density Ratio \(\frac{\rho_{2}}{\rho_{1}}\)
- pygasflow.shockwave.total_pressure_ratio(M1, gamma=1.4)[source]
Compute the total pressure ratio \(\frac{P_{2}^{0}}{P_{1}^{0}}\).
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Total Pressure Ratio \(\frac{P_{2}^{0}}{P_{1}^{0}}\)
- pygasflow.shockwave.total_temperature_ratio(M1, gamma=1.4)[source]
Compute the total temperature ratio \(\frac{T_{2}^{0}}{T_{1}^{0}}\).
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Total Temperature Ratio \(\frac{T_{2}^{0}}{T_{1}^{0}}\) (spoiler: always equal to 1 :P )
- pygasflow.shockwave.rayleigh_pitot_formula(M1, gamma=1.4)[source]
Compute the ratio \(\frac{P_{t2}}{P_{1}}\), between the stagnation pressure behind a normal shock wave and the static pressure ahead of the shock wave.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Ratio \(\frac{P_{t2}}{P_{1}}\)
References
“Equations, Tables and Charts for compressible flow”, NACA R-1135, 1953
- pygasflow.shockwave.entropy_difference(M1, gamma=1.4)[source]
Compute the dimensionless entropy difference, \(\frac{s_{2} - s_{1}}{C_{p}}\). Eq (3.60) Anderson’s.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Dimensionless Entropy Difference, \(\frac{s_{2} - s_{1}}{C_{p}}\)
- pygasflow.shockwave.mach_downstream(M1, gamma=1.4)[source]
Compute the downstream Mach number M2. Note that this function can also be used to compute M1 given M2.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Because this function can be used to compute M1 given M2, it will not perform a check wheter \(M_{1} \ge 1\). Be careful on your use!
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Downstream Mach Number M2
- pygasflow.shockwave.m1_from_pressure_ratio(ratio, gamma=1.4)[source]
Compute M1 from the pressure ratio.
- Parameters
- ratioarray_like
Pressure Ratio \(\frac{P_{2}}{P_{1}}\). If float, list, tuple is given as input, a conversion will be attempted. Must be \(\frac{P_{2}}{P_{1}}\) >= 1.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Upstream Mach number M1.
- pygasflow.shockwave.m1_from_temperature_ratio(ratio, gamma=1.4)[source]
Compute M1 from the temperature ratio.
- Parameters
- ratioarray_like
Temperature Ratio \(\frac{T_{2}}{T_{1}}\). If float, list, tuple is given as input, a conversion will be attempted. Must be \(\frac{T_{2}}{T_{1}}\) >= 1.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Upstream Mach number M1.
- pygasflow.shockwave.m1_from_density_ratio(ratio, gamma=1.4)[source]
Compute M1 from the density ratio.
- Parameters
- ratioarray_like
Density Ratio \(\frac{\rho_{2}}{\rho_{1}}\). If float, list, tuple is given as input, a conversion will be attempted. Must be \(1 \le \frac{\rho_{2}}{\rho_{1}} < \frac{\gamma + 1}{\gamma - 1}\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Upstream Mach number M1.
- pygasflow.shockwave.m1_from_total_pressure_ratio(ratio, gamma=1.4)[source]
Compute M1 from the total pressure ratio.
- Parameters
- ratioarray_like
Total Pressure Ratio. If float, list, tuple is given as input, a conversion will be attempted. Must be \(0 \le \frac{P_{2}^{0}}{P_{1}^{0}} \le 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Upstream Mach number M1.
- pygasflow.shockwave.m1_from_m2(M2, gamma=1.4)[source]
Compute M1 from the downstream Mach number M2.
- Parameters
- M2array_like
Downstream Mach Number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(\frac{\gamma - 1}{2 \gamma} < M_{2} < 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Upstream Mach number M1.
Oblique Shock Waves
- pygasflow.shockwave.theta_from_mach_beta(M1, beta, gamma=1.4)[source]
Compute the flow turning angle Theta accordingly to the input parameters.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- betafloat
Shock wave angle in degrees.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Flow angle Theta [degrees]
- pygasflow.shockwave.beta_from_mach_theta(M1, theta, gamma=1.4)[source]
Compute the shock angle Beta accordingly to the input parameters.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- thetafloat
Flow turning angle in degrees.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
Dictionary of Shock angle beta [degrees] if it exists, else NaN:
{"weak": beta_weak, "strong": beta_strong}
.
- pygasflow.shockwave.beta_from_upstream_mach(M1, MN1)[source]
Compute the shock wave angle beta from the upstream Mach number and its normal component.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- MN1array_like
Normal Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be
MN1.shape == M1.shape
.
- Returns
- outndarray
Shock angle Beta [degrees]
- pygasflow.shockwave.normal_mach_upstream(M1, beta=None, theta=None, gamma=1.4, flag='weak')[source]
Compute the upstream normal Mach Number, which can then be used to evaluate all other ratios.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- betafloat, optional
The shock wave angle in degrees. If beta=None you must give in theta.
- thetafloat, optional
The flow deflection angle in degrees. If theta=None you must give in beta.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- flagstring, optional
Can be either
'weak'
or'strong'
. Default to'weak'
. Chose what value to compute if theta is provided.
- Returns
- outndarray
Normal Mach number upstream of the shock wave. If theta is given, and
flag="both"
it returns a dictionary of Normal Mach numbers:{"weak":weak_MN1, "strong":strong_MN1}
.
- pygasflow.shockwave.get_upstream_normal_mach_from_ratio(ratioName, ratio, gamma=1.4)[source]
Compute the upstream Mach number given a ratio as an argument.
- Parameters
- ratioNamestring
Name of the ratio given in input. Can be either one of:
'pressure'
: \(\frac{P_{2}}{P_{1}}\)'temperature'
: \(\frac{T_{2}}{T_{1}}\)'density'
: \(\frac{\rho_{2}}{\rho_{1}}\)'total_pressure'
: \(\frac{P_{2}^{0}}{P_{1}^{0}}\)'mn2'
: Normal Mach downstream of the shock wave
- ratioarray_like
Actual value of the ratio. If float, list, tuple is given as input, a conversion will be attempted.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- outndarray
The upstream Mach number.
- pygasflow.shockwave.get_ratios_from_normal_mach_upstream(Mn, gamma=1.4)[source]
Compute the ratios of the quantities across a Shock Wave given the Normal Mach number.
- Parameters
- Mnarray_like
Normal Mach number upstream of the shock wave. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- prarray_like
Pressure ratio across the shock wave.
- drarray_like
Density ratio across the shock wave.
- trarray_like
Temperature ratio across the shock wave.
- tprarray_like
Total Pressure ratio across the shock wave.
- mn2array_like
Normal Mach number dowstream of the shock wave.
- pygasflow.shockwave.maximum_mach_from_deflection_angle(theta, gamma=1.4)[source]
Compute the maximum Mach number from a given Deflection angle theta.
- Parameters
- thetafloat
Deflection angle in degrees. Must be \(0 \le \theta \le 90\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Mfloat
The maximum Mach number for the specified theta.
- pygasflow.shockwave.mimimum_beta_from_mach(M1)[source]
Compute the minimum shock wave angle for a given upstream Mach number.
- Parameters
- Marray_like
Upstream Mach number. Must be >= 1.
- Returns
- beta: float
Shock wave angle in degrees
- pygasflow.shockwave.max_theta_from_mach(M1, gamma=1.4)[source]
Compute the maximum deflection angle for a given upstream Mach number.
- Parameters
- M1array_like
Upstream Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Theta_maxndarray
Maximum deflection angle theta in degrees
- pygasflow.shockwave.beta_from_mach_max_theta(M1, gamma=1.4)[source]
Compute the shock wave angle beta corresponding to the maximum deflection angle theta given an upstream Mach number.
- Parameters
- M1array_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Betaarray_like
The shock angle in degrees.
- pygasflow.shockwave.beta_theta_max_for_unit_mach_downstream(M1, gamma=1.4)[source]
Compute the shock maximum deflection angle, theta_max, as well as the wave angle beta corresponding to the unitary downstream Mach number, \(M_{2} = 1\).
- Parameters
- M1array_like
Upstream Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Betaarray_like
The shock angle in degrees corresponding to \(M_{2} = 1\).
- Theta maxarray_like
The maximum deflection angle in degrees corresponding to \(M_{2} = 1\).
- pygasflow.shockwave.mach_from_theta_beta(theta, beta, gamma=1.4)[source]
Compute the upstream Mach number given the flow deflection angle and the shock wave angle.
- Parameters
- thetaarray_like
Flow deflection angle in degrees. If float, list, tuple is given as input, a conversion will be attempted. Must be \(0 \le \theta \le 90\).
- betaarray_like
Shock wave angle in degrees. If float, list, tuple is given as input, a conversion will be attempted. Must be \(0 \le \beta \le 90\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Machndarray
The upstream Mach number.
- pygasflow.shockwave.shock_polar(M1, gamma=1.4, N=100)[source]
Compute the ratios (Vx/a*), (Vy/a*) for plotting a Shock Polar.
- Parameters
- M1float
Upstream Mach number of the shock wave. Must be > 1.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Nint, optional
Number of discretization steps in the range [2, 2*pi]. Must be > 1.
- Returns
- (Vx/a*)ndarray [1 x N]
x-coordinate for the shock polar plot
- (Vy/a*)ndarray [1 x N]
y-coordinate for the shock polar plot
- pygasflow.shockwave.pressure_deflection(M1, gamma=1.4, N=100)[source]
Helper function to build Pressure-Deflection plots.
- Parameters
- M1float
Upstream Mach number. Must be > 1.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Nint, optional
Half number of points discretizing the range [0, theta_max]. This function compute N points in the range [0, theta_max] for the ‘weak’ solution, then compute N points in the range [theta_max, 0] for the ‘strong’ solution.
- Returns
- thetaarray_like
Deflection angles
- prarray_like
Pressure ratios computed for the given Mach and the above deflection angles.
Conical Flow
- pygasflow.shockwave.taylor_maccoll(theta, V, gamma=1.4)[source]
Taylor-Maccoll differential equation for conical shock wave.
- Parameters
- thetafloat
Polar coordinate, angle in radians.
- Vlist
Velocity Vector with components:
\(V_{r}\): velocity along the radial direction
\(V_{\theta}\): velocity along the polar direction
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- dV_dthetalist
Taylor-Maccoll differential equation.
- pygasflow.shockwave.nondimensional_velocity(M, gamma=1.4)[source]
Compute the Nondimensional Velocity given the Mach number.
- Parameters
- Marray_like
Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be M >= 0.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Varray_like
Nondimensional Velocity
- pygasflow.shockwave.mach_from_nondimensional_velocity(V, gamma=1.4)[source]
Compute the Mach number given the Nondimensional Velocity.
- Parameters
- Varray_like
Nondimensional Velocity. If float, list, tuple is given as input, a conversion will be attempted. Must be V > 0.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Marray_like
Mach number
- pygasflow.shockwave.mach_cone_angle_from_shock_angle(M, beta, gamma=1.4)[source]
Compute the half-cone angle and the Mach number at the surface of the cone. NOTE: this function is undecorated, hence no check is performed to assure the validity of the input parameters. It’s up to the user to assure that.
- Parameters
- Mfloat
Upstream Mach number. Must be > 1.
- betafloat
Shock Angle in degrees. Must be \(\mu \, \text(Mach Angle) \le beta \le 90\). NOTE: no check is done over beta. If an error is raised during the computation, make sure beta is at least ever so slightly bigger than the mach angle.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Mcfloat
Mach number at the surface of the cone
- theta_cfloat
Half-cone angle in degrees.
- pygasflow.shockwave.shock_angle_from_mach_cone_angle(M1, theta_c, gamma=1.4, flag='weak')[source]
Compute the shock wave angle given the upstream mach number and the half-cone angle.
- Parameters
- M1array_like
Upstream Mach number. Must be > 1.
- theta_cfloat
Half cone angle in degrees. Must be \(0 < \theta_{c} < 90\)
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- flagstring, optional
Can be either
'weak'
or'strong'
. Default to'weak'
(in conical shockwaves, the strong solution is rarely encountered).
- Returns
- Mcfloat
Mach number at the surface of the cone, computed.
- theta_cfloat
Half cone angle of the cone in degrees (which was provided in input).
- betafloat
Shock wave angle in degrees.
- pygasflow.shockwave.shock_angle_from_machs(M1, Mc, gamma=1.4, flag='weak')[source]
Compute the shock wave angle given the upstream mach number and the mach number at the surface of the cone.
- Parameters
- M1array_like
Upstream Mach number. Must be > 1.
- Mcfloat
Mach number at the surface of the cone.
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- flagstring, optional
Can be either
'weak'
or ‘strong’. Default to'weak'
(in conical shockwaves, the strong solution is rarely encountered).
- Returns
- Mcfloat
Mach number at the surface of the cone, computed.
- theta_cfloat
Half cone angle of the cone in degrees.
- betafloat
Shock wave angle in degrees.
- pygasflow.shockwave.max_theta_c_from_mach(M1, gamma=1.4)[source]
Compute the maximum cone angle and the corresponding shockwave angle for a given upstream Mach number.
- Parameters
- M1array_like
Upstream Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- Mcndarray
Mach number at the cone surface
- Theta_c_maxndarray
Maximum cone angle theta_c in degrees
- betandarray
Shockwave angle corresponding to the maximum cone angle and provided Mach number.
- pygasflow.shockwave.beta_theta_c_for_unit_mach_downstream(M1, gamma=1.4)[source]
Given an upstream Mach number, compute the point (beta, theta_c) where the downstream Mach number is sonic. WARNING: this procedure is really slow!
- Parameters
- M1array_like
Upstream Mach number. If float, list, tuple is given as input, a conversion will be attempted. Must be \(M_{1} \ge 1\).
- gammafloat, optional
Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).
- Returns
- theta_cndarray
Cone angle theta_c in degrees.
- betandarray
Shockwave angle corresponding in degrees.
- pygasflow.shockwave.load_data(gamma=1.4)[source]
The
beta_theta_c_for_unit_mach_downstream
function is really slow in computing the data. Often, that data is needed in a plot. Here, a few precomputed tables has been provided.- Parameters
- gammafloat, optional
The specific heat ratio.
- Returns
- M1ndarray
The precomputed upstream Mach numbers
- betandarray
The shockwave angle associate to \(M_{2} = 1\) for the precomputed M1
- theta_cndarray
The half-cone angle associate to \(M_{2} = 1\) for the precomputed M1