Shockwaves

Normal Shock Waves

pygasflow.shockwave.pressure_ratio(M1, gamma=1.4)[source]

Compute the static pressure ratio P2/P1.

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 P2/P1

pygasflow.shockwave.temperature_ratio(M1, gamma=1.4)[source]

Compute the static temperature ratio T2/T1.

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 T2/T1

pygasflow.shockwave.density_ratio(M1, gamma=1.4)[source]

Compute the density ratio rho2/rho1.

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 rho2/rho1

pygasflow.shockwave.total_pressure_ratio(M1, gamma=1.4)[source]

Compute the total pressure ratio P02/P01.

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 P02/P01

pygasflow.shockwave.total_temperature_ratio(M1, gamma=1.4)[source]

Compute the total temperature ratio T02/T01.

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 T02/T01 (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

  • “Hypersonic and High-Temperature Gas Dynamics”, Third Edition, John D. Anderson

pygasflow.shockwave.m1_from_rayleigh_pitot_pressure_ratio(ratio, gamma=1.4)[source]

Compute the upstream Mach number of a normal shock wave starting from the pressure ratio \(\frac{P_{t2}}{P_{1}}\), where Pt2 is the stagnation pressure behind a normal shock wave and the static pressure ahead of the shock wave.

Parameters:
prfloat or array_like

Pressure ratio.

gammafloat, optional

Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).

Returns:
M1float or ndarray

Upstream Mach number.

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 P2/P1. If float, list, tuple is given as input, a conversion will be attempted. Must be P2/P1 >= 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 T2/T1. If float, list, tuple is given as input, a conversion will be attempted. Must be T2/T1 >= 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 rho2/rho1. 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:
thetandarray

Flow angle Theta [degrees]. If detachment is detected, np.nan will be returned and a warning message will be raised.

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

Possible options: 'weak', 'strong', 'both'. 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': P2/P1

  • 'temperature': T2/T1

  • 'density': rho2/rho1

  • 'total_pressure': P02/P01

  • 'mnd': 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:
Max_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.detachment_point_oblique_shock(M1, gamma=1.4)[source]

Compute the detachment point, ie 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.

theta_maxarray_like

The maximum deflection angle in degrees associated to the provided upstream Mach number.

pygasflow.shockwave.sonic_point_oblique_shock(M1, gamma=1.4)[source]

Compute the wave angle, beta, and the shock deflection angle, theta, corresponding to the unitary downstream Mach number, \(M_{2} = 1\).

This function is useful to compute the location of the sonic line. It relies on root-finding algorithms: if a root can’t be found, np.nan will be used as the result.

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\).

thetaarray_like

The 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.mach_beta_from_theta_ratio(theta, ratio_name, ratio_value, gamma=1.4)[source]

Compute the upstream Mach numbers and the shockwave angles starting from a ratio across the oblique shock wave the the flow deflection angle. Usually, there are two solutions.

Parameters:
thetafloat
ratio_namestr

Can be either one of: ‘pressure’, ‘temperature’, ‘density’, ‘total_pressure’.

ratio_valuefloat
gammafloat, optional

Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).

Returns:
Mulist

List of upstream Mach numbers.

betalist

List of shockwave angles associated to the upstream Mach numbers.

pygasflow.shockwave.oblique_mach_downstream(M1, beta=None, theta=None, gamma=1.4, flag='weak')[source]

Compute the downstream Mach number M2 accordingly from 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, 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

Downstream Mach Number M2

pygasflow.shockwave.shock_polar_equation(Vx_as_ratio, M1s, gamma=1.4)[source]

Analytical equation for the shock polar.

Parameters:
Vx_as_ratiofloat or array_like

This is Vx/a*

M1sfloat

Characteristic upstream Mach number.

gammafloat, optional

Specific heats ratio. Default to 1.4. Must be \(\gamma > 1\).

Returns:
Vy/a*float
pygasflow.shockwave.shock_polar(M1, gamma=1.4, N=100, include_mirror=True)[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 [0, pi]. Must be > 1.

include_mirrorbool

If True, return results for polar angle in [0, 2*pi]. Otherwise, return results for polar angle in [0, pi].

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

class pygasflow.shockwave.PressureDeflectionLocus(*, M, _shockwave_at_theta, detachment_point, dr_to_fs_at_origin, gamma, label, pr_to_fs_at_origin, sonic_point, theta_max, theta_origin, tpr_to_fs_at_origin, tr_to_fs_at_origin, upstream_locus, name)[source]

Represent the locus of all possible static pressure values behind oblique shock wave for given upstream conditions.

This class implements the logic to deal with pressure-deflection locus from a numerical standpoint. It is meant to be used together with PressureDeflectionDiagram in order to draw pressure-deflection locuses.

Parameters:
labelString
default:

Name to be shown on the legend of the plot.

MNumber
bounds:

\(M \ge 1\)

default:

1

Upstream Mach number for which the pressure-deflection locus should be computed.

gammaNumber
bounds:

\(\gamma > 1\)

default:

1.4

Specific heats ratio.

theta_originNumber
default:

0

Deflection angle at which M occurs.

pr_to_fs_at_originNumber
bounds:

pr_to_fs_at_origin >= 1

default:

1

Pressure ratio multiplier between the pressure at the current locus origin and the free-stream pressure.

tr_to_fs_at_originNumber
bounds:

tr_to_fs_at_origin >= 1

default:

1

Temperature ratio multiplier between the temperature at the current locus origin and the free-stream temperature.

dr_to_fs_at_originNumber
bounds:

dr_to_fs_at_origin >= 1

default:

1

Density ratio multiplier between the density at the current locus origin and the free-stream density.

tpr_to_fs_at_originNumber
bounds:

0 <= tpr_to_fs_at_origin <= 1

default:

1

Total pressure ratio multiplier between the total pressure at the current locus origin and the free-stream total pressure.

theta_maxNumber
read only:

True

The maximum deflection angle possible with this pressure-deflection locus. Note that theta_max is considered relative to theta_origin along the left-running branch.

upstream_locuspygasflow.shockwave._BasePDLocus
allow_None:

True

constant:

True

The locus associated with the upstream condition.

sonic_pointTuple
constant:

True

default:

(0, 0)

length:

2

Coordinates (theta, pr_to_fs) where the Mach downstream of the shock wave is sonic. theta (in degrees) is considered relative to theta_origin.

detachment_pointTuple
constant:

True

default:

(0, 0)

length:

2

Coordinates (theta_max, pr_to_fs) indicating the maximum deflection by which a given supersonic flow can be deflected by an oblique shock wave. theta (in degrees) is considered relative to theta_origin.

static create_path(*segments, concatenate=True, **kwargs)[source]

Create a path connecting one or more segments.

Parameters:
segmentstuple

2-elements tuple where the first element is a PressureDeflectionLocus and the second element is the deflection angle [degrees] of the end of the segment.

concatenatebool

If True, concatenate the results of each segments, thus returning two numpy arrays. If False, returns two lists where each element is the result for each segment.

**kwargs

Keyword arguments passed to pressure_deflection_segment().

Returns:
thetanp.ndarray or list

Array of deflection angles [degrees] or list of arrays of deflection angles [degrees], depending on concatenate.

prnp.ndarray or list

Array of pressure ratios to freestream, or list of arrays of pressure ratios, depending on concatenate.

Examples

from pygasflow.shockwave import PressureDeflectionLocus
import matplotlib.pyplot as plt

gamma = 1.4
M1 = 3
theta = 25
locus1 = PressureDeflectionLocus(M=M1, gamma=gamma)
locus2 = locus1.new_locus_from_shockwave(theta)

theta1, pr1 = locus1.pressure_deflection(include_mirror=True)
theta2, pr2 = locus2.pressure_deflection(include_mirror=True)
theta_segment, pr_segment = locus1.create_path(
    (locus1, locus2.theta_origin),
    (locus2, 15)
)

fig, ax = plt.subplots()
ax.plot(theta1, pr1, ":", label="M1")
ax.plot(theta2, pr2, ":", label="M2")
ax.plot(theta_segment, pr_segment, label="segment")
ax.set_xlabel(r"Deflection Angle $  heta$ [deg]")
ax.set_ylabel("Pressure Ratio to Freestream")
ax.legend()
ax.minorticks_on()
ax.grid(which='major', linestyle='-', alpha=0.7)
ax.grid(which='minor', linestyle=':', alpha=0.5)
plt.show()

(Source code, png, hires.png, pdf)

../_images/shockwave-1.png
flow_quantities_after_shockwave(theta, p_fs=None, T_fs=None, rho_fs=None, region='weak')[source]

Compute the flow quantities after a shock wave.

Parameters:
thetafloat

The flow deflection angle in degrees. This quantity is not relative to the origin of the current locus. Instead, it must be an angle taken from a pressure-deflection diagram.

p_fsfloat or None

Freestream pressure.

T_fsfloat or None

Freestream temperature.

rho_fsfloat or None

Freestream density.

regionstr

Possible values are "weak", "strong".

Returns:
resdict

Contains the quantities just downstream of the specified shock wave. The following keys will be used:

  • "M": Mach number downstream of the shock wave.

  • "T": Temperature downstream of the shock wave.

  • "p": Pressure downstream of the shock wave.

  • "rho": Density downstream of the shock wave.

  • "T0": Total temperature downstream of the shock wave.

  • "p0": Total pressure downstream of the shock wave.

  • "rho0": Total density downstream of the shock wave.

Examples

Consider a simple regular reflection from a solid boundary:

>>> from pygasflow.shockwave import PressureDeflectionLocus
>>> gamma = 1.4
>>> M1 = 2.8
>>> theta1 = 16  # deg
>>> T1 = 519     # °R
>>> p1 = 1       # atm
>>> l1 = PressureDeflectionLocus(M=M1, gamma=gamma, label="1")
>>> l2 = l1.new_locus_from_shockwave(theta1, label="2")

To compute quantities downstream of the second shock wave:

>>> region3 = l2.flow_quantities_after_shockwave(0, p1, T1, None)
flow_quantities_at_locus_origin(p_fs=None, T_fs=None, rho_fs=None)[source]

Compute the flow quantities at a locus origin, using isentropic relations, which represent a state of the flow. Note that the locus origin corresponds to a situation in which the flow state behind the oblique shock wave is identical to the flow state ahead of it.

Parameters:
p_fsfloat or None

Freestream pressure.

T_fsfloat or None

Freestream temperature.

rho_fsfloat or None

Freestream density.

Returns:
resdict

Contains the quantities just downstream of the specified shock wave. The following keys will be used:

  • "M": Mach number downstream of the shock wave.

  • "T": Temperature downstream of the shock wave.

  • "p": Pressure downstream of the shock wave.

  • "rho": Density downstream of the shock wave.

  • "T0": Total temperature downstream of the shock wave.

  • "p0": Total pressure downstream of the shock wave.

  • "rho0": Total density downstream of the shock wave.

Examples

Consider a simple regular reflection from a solid boundary:

>>> from pygasflow.shockwave import PressureDeflectionLocus
>>> gamma = 1.4
>>> M1 = 2.8
>>> theta1 = 16  # deg
>>> T1 = 519     # °R
>>> p1 = 1       # atm
>>> l1 = PressureDeflectionLocus(M=M1, gamma=gamma, label="1")
>>> l2 = l1.new_locus_from_shockwave(theta1, label="2")

To compute the missing flow quantities in the free stream region:

>>> region1 = l1.flow_quantities_at_locus_origin(p1, T1, None)
>>> region1["M"]
2.8
>>> region1["T"]
519
>>> region1["p"]
1
>>> region1["p0"]
np.float64(27.13829555269978)
>>> region1["T0"]
np.float64(1332.7919999999997)

To compute the missing flow quantities after the first shock wave:

>>> region2 = l2.flow_quantities_at_locus_origin(p1, T1, None)
>>> region2["M"]
np.float64(2.0585267649107384)
>>> region2["T"]
np.float64(721.4004347373847)
>>> region2["p"]
np.float64(2.830893893824571)
>>> region2["p0"]
np.float64(24.26467588950667)
>>> region2["T0"]
np.float64(1332.7919999999997)
intersection(other, region='weak', a=None, b=None)[source]

Find the intersection point of this locus with another one.

Note: this is an experimental function.

Parameters:
otherPressureDeflectionLocus
regionstr

Can be "weak" or "strong".

Returns:
theta_intersectionfloat

The deflection angle [degrees] of the intersection point. If there is no intersection, None will be returned.

pr_intersectionfloat

The pressure ratio of the intersection point. If there is no intersection, None will be returned.

Examples

Example of the intersection of shocks of opposite families:

>>> from pygasflow.shockwave import PressureDeflectionLocus
>>> gamma = 1.4
>>> M1 = 3
>>> theta2 = 20
>>> theta3 = -15
>>> locus1 = PressureDeflectionLocus(M=M1, gamma=1.4, label="1")
>>> locus2 = locus1.new_locus_from_shockwave(theta2, label="2")
>>> locus3 = locus1.new_locus_from_shockwave(theta3, label="2")
>>> phi, p4_p1 = locus2.intersection(locus3)
>>> phi
4.795958931693682
>>> p4_p1
np.float64(8.352551913417367)
new_locus_from_shockwave(theta, label='')[source]

Create a new PressureDeflectionLocus object using the upstream conditions of this instance.

Parameters:
thetafloat

Deflection angle [degrees] of the oblique shockwave.

labelstr

Label to be assigned to the new instance, which will later be shown on plots.

Returns:
objPressureDeflectionLocus
pressure_deflection(N=100, include_mirror=True)[source]

Helper function to build Pressure-Deflection plots. Computes the locus of all possible static pressure values behind oblique shock wave for given upstream conditions.

Parameters:
Nint, optional

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. If include_mirror=False, the length of the returned arrays is 2*N, otherwise is 4*N.

include_mirrorbool

If False, return numerical arrays for 0 <= theta <= theta_max. If True, mirror the arrays in order to get data from -theta_max <= theta <= theta_max.

Returns:
thetaarray_like

Deflection angles

prarray_like

Pressure ratios computed for the given Mach and the above deflection angles.

Examples

Plot half locus for the upstream condition, and the full locus for the downstream condition:

from pygasflow.shockwave import PressureDeflectionLocus
import matplotlib.pyplot as plt

gamma = 1.4
M1 = 3
theta = 25
locus1 = PressureDeflectionLocus(M=M1, gamma=gamma)
locus2 = locus1.new_locus_from_shockwave(theta)

theta_1, pr_1 = locus1.pressure_deflection(include_mirror=False)
theta_2, pr_2 = locus2.pressure_deflection(include_mirror=True)

fig, ax = plt.subplots()
ax.plot(theta_1, pr_1, label=f"M = {locus1.M}")
ax.plot(theta_2, pr_2, label=f"M = {locus2.M}")
ax.set_xlabel(r"Deflection Angle $  heta$ [deg]")
ax.set_ylabel("Pressure Ratio to Freestream")
ax.legend()
ax.minorticks_on()
ax.grid(which='major', linestyle='-', alpha=0.7)
ax.grid(which='minor', linestyle=':', alpha=0.5)
plt.show()

(Source code, png, hires.png, pdf)

../_images/shockwave-2.png
pressure_deflection_segment(theta, region='weak', N=100)[source]

Helper function to build Pressure-Deflection plots. Computes the static pressure values behind oblique shock wave for given upstream conditions, in a specified deflection angle range [0, theta].

Parameters:
thetafloat

The deflection angle up to which the segment has to be computed.

regionstring

Can be 'weak' or 'strong'. If the latter is chosen, the segment starts from theta=0, goes to theta=theta_max and then it proceeds to the user provided value.

Nint, optional

Number of points discretizing the range [0, theta].

Returns:
thetaarray_like

Deflection angles

prarray_like

Pressure ratios computed for the given Mach and the above deflection angles.

Examples

Segment connecting the upstream condition to the downstream condition:

from pygasflow.shockwave import PressureDeflectionLocus
import matplotlib.pyplot as plt

gamma = 1.4
M1 = 3
theta = 25
locus1 = PressureDeflectionLocus(M=M1, gamma=gamma)
locus2 = locus1.new_locus_from_shockwave(theta)

theta1, pr1 = locus1.pressure_deflection(include_mirror=True)
theta2, pr2 = locus2.pressure_deflection(include_mirror=True)
theta_segment, pr_segment = locus1.pressure_deflection_segment(theta)

fig, ax = plt.subplots()
ax.plot(theta1, pr1, ":", label="M1")
ax.plot(theta2, pr2, ":", label="M2")
ax.plot(theta_segment, pr_segment, label="segment")
ax.set_xlabel(r"Deflection Angle $  heta$ [deg]")
ax.set_ylabel("Pressure Ratio to Freestream")
ax.legend()
ax.minorticks_on()
ax.grid(which='major', linestyle='-', alpha=0.7)
ax.grid(which='minor', linestyle=':', alpha=0.5)
plt.show()

(Source code, png, hires.png, pdf)

../_images/shockwave-3.png
pressure_deflection_split(N=100, include_mirror=False, mode='region')[source]

Helper function to build Pressure-Deflection plots. Computes the locus of all possible static pressure values behind oblique shock wave for given upstream conditions, and split them according to the user selected mode.

Parameters:
Nint, optional

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. If include_mirror=False, the length of the returned arrays is 2*N, otherwise is 4*N.

include_mirrorbool

If False, return numerical arrays for 0 <= theta <= theta_max. If True, mirror the arrays in order to get data from -theta_max <= theta <= theta_max.

modestr

Split the locus at some point. It can be:

  • "region": the locus is splitted at the detachment point, where theta=theta_max.

  • "sonic": the locus is splitted at the sonic point (where the downstream Mach number is 1).

Returns:
theta_split_1array_like
pr_split_1array_like
theta_split_2array_like
pr_split_2array_like

Examples

Consider a simple regular reflection process, in which there are two shock waves. Plot half locus for the upstream condition and split it between the weak and strong regions. Also plot another full locus, splitted between the subsonic and supersonic region:

from pygasflow.shockwave import PressureDeflectionLocus
import matplotlib.pyplot as plt

gamma = 1.4
M1 = 3
theta = 25
locus1 = PressureDeflectionLocus(M=M1, gamma=gamma)
locus2 = locus1.new_locus_from_shockwave(theta)

theta_1w, pr_1w, theta_1s, pr_1s = locus1.pressure_deflection_split(
    include_mirror=False, mode="region")
theta_2sup, pr_2sup, theta_2sub, pr_2sub = locus2.pressure_deflection_split(
    include_mirror=True, mode="sonic")

fig, ax = plt.subplots()
ax.plot(theta_1w, pr_1w, label="M1 weak")
ax.plot(theta_1s, pr_1s, label="M1 strong")
ax.plot(theta_2sup, pr_2sup, label="M2 (M3 supersonic)")
ax.plot(theta_2sub, pr_2sub, label="M2 (M3 subsonic)")
ax.set_xlabel(r"Deflection Angle $  heta$ [deg]")
ax.set_ylabel("Pressure Ratio to Freestream")
ax.legend()
ax.minorticks_on()
ax.grid(which='major', linestyle='-', alpha=0.7)
ax.grid(which='minor', linestyle=':', alpha=0.5)
plt.show()

(Source code, png, hires.png, pdf)

../_images/shockwave-4.png
shockwave_at_theta(theta, region='weak')[source]

Evaluates the current pression-deflection locus at a specified flow-deflection angle in the specified region for the current locus.

Parameters:
thetafloat

The flow deflection angle in degrees. This quantity is not relative to the origin of the current locus. Instead, it must be an angle taken from a pressure-deflection diagram.

regionstr

Possible values are "weak", "strong".

Returns:
resdict

Contains the the ratios and mach numbers across the shockwave. The following keys will be used:

  • "mu": upstream Mach number.

  • "mnu": upstream normal Mach number.

  • "md": downstream Mach number.

  • "mnd": downstream normal Mach number.

  • "beta": shock wave angle [degrees] relative to the upstream locus.

  • "theta": flow deflection angle [degrees] relative to the locus’ origin. Note that this value can be negative.

  • "pr": pressure ratio to freestream.

  • "tr": temperature ratio to freestream.

  • "dr": density ratio to freestream.

  • "tpr": total pressure ratio to freestream.

Examples

This is a simple regular reflection from a solid boundary (refer to figure 4.18 of “Modern Compressible Flow, Anderson”):

>>> gamma = 1.4
>>> M1 = 2.8
>>> theta1 = 16  # deg
>>> T1 = 519     # °R
>>> p1 = 1       # atm
>>> l1 = PressureDeflectionLocus(M=M1, gamma=gamma, label="1")
>>> l2 = l1.new_locus_from_shockwave(theta1, label="2")

First shock wave:

>>> shock_1 = l1.shockwave_at_theta(theta1)
>>> shock_1["theta"]
16
>>> shock_1["beta"]
np.float64(34.9226304011263)

Reflected shock wave:

>>> shock_2 = l2.shockwave_at_theta(0)
>>> shock_2["theta"]
-16
>>> shock_2["beta"]
np.float64(45.33424941323747)

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.

See also

taylor_maccoll
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.detachment_point_conical_shock(M1, gamma=1.4)[source]

Compute the maximum cone angle and the corresponding shockwave angle for a given upstream Mach number.

Note: this is a wrapper function to max_theta_c_from_mach().

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:
betandarray

Shockwave angle corresponding to the maximum cone angle and provided Mach number.

theta_c_maxndarray

Maximum cone angle theta_c in degrees

pygasflow.shockwave.sonic_point_conical_shock(M1, gamma=1.4)[source]

Given an upstream Mach number, compute the point (beta, theta_c) where the downstream Mach number is sonic. This function is useful to compute the location of the sonic line.

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:
betandarray

Shockwave angle corresponding in degrees.

theta_cndarray

Cone angle theta_c in degrees.

pygasflow.shockwave.load_data(gamma=1.4)[source]

The sonic_point_conical_shock() 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