g3d.calc.calculators package

Submodules

g3d.calc.calculators.acoustics module

Acoustic relations calculator

class g3d.calc.calculators.acoustics.G3DAcousticsCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to acoustic evaluations

Attributes:
gas

Gas object

newton

Newton-Raphson solver

pref

Reference pressure [Pa] (default value: 2.e-5 Pa)

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_SPL_from_dp(*args, **kwargs)

Calculates sound pressure level (SPL [dB]) from pressure fluctuation (dP [Pa], RMS)

get_dB_from_dp(*args, **kwargs)

get_dp_from_SPL(*args, **kwargs)

Calculates pressure fluctuation (dP [Pa], RMS) from sound pressure level (SPL [dB])

get_dp_from_dB(*args, **kwargs)

get_dro(*args, **kwargs)

Calculates sound wave induced density fluctuation (dRO [kg/m^3]) input: far-field speed of sound (Cinf [m/s]) and RMS pressure fluctuation (dP [Pa]) example: dRO = get_dro(Cinf=Cinf, dP=dP)

get_du(*args, **kwargs)

Calculates sound wave induced flow velocity (dU [m/s])

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_SPL_from_dp(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound pressure level (SPL [dB]) from pressure fluctuation (dP [Pa], RMS)

input: pressure fluctuation (dP [Pa], RMS)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    pressure fluctuation RMS [Pa] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘dP’

Returns:

sound pressure level [dB]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> SPL = cflow.acoustics.get_SPL_from_dp(dP=10.)

get_dB_from_dp(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_SPL_from_dp()

get_dp_from_SPL(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates pressure fluctuation (dP [Pa], RMS) from sound pressure level (SPL [dB])

input: sound pressure level (SPL [dB])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    sound pressure level [dB] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘SPL’

Returns:

pressure fluctuation (RMS dP) [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dP = cflow.acoustics.get_dp_from_SPL(SPL=70.)

get_dp_from_dB(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_dp_from_SPL()

get_dro(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound wave induced density fluctuation (dRO [kg/m^3]) input: far-field speed of sound (Cinf [m/s]) and RMS pressure fluctuation (dP [Pa]) example: dRO = get_dro(Cinf=Cinf, dP=dP)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. far-field speed of sound [m/s]

    2. pressure fluctuation [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘Cinf’, ‘dP’

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dRO = cflow.acoustics.get_dro(Cinf=340., dP=10.)

get_du(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound wave induced flow velocity (dU [m/s])

input: far-field speed of sound (Cinf [m/s]), far-field density (ROinf [kg/m^3]), and RMS pressure fluctuation (dP [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. far-field speed of sound [m/s]

    2. far field density [kg/m^3]

    3. pressure fluctuation [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘Cinf’, ‘ROinf’, ‘dP’

Returns:

induced velocity (u) [m/s]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dU = cflow.acoustics.get_du(Cinf=340., ROinf=1.2, dP=10.)

property pref: float

2.e-5 Pa)

Type:

Reference pressure [Pa] (default value

g3d.calc.calculators.calculator module

Base calculator class

class g3d.calc.calculators.calculator.G3DCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DGenericCalculator

Class definition of base class G3DCalculator

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

g3d.calc.calculators.channel_flow module

Channel flow calculator

class g3d.calc.calculators.channel_flow.G3DChannelFlowCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to compressible channel flow

Attributes:
H

Channel height [m]

L

Channel length [m]

M

Mach number based on freestream velocity []

Re

Reynolds number based on freestream velocity []

Re_tau

Reynolds number based on friction velocity []

T

Temperature [K]

W

Channel width [m]

delta

Channel half height [m]

gas

Gas object

mu

Dynamic viscosity [kg/(m s)]

newton

Newton-Raphson solver

p

Pressure [Pa]

rho

Density [kg/s]

tag

tag (string) used for identification

tau_w

Wall-shear stress [N/m^2]

u

Velocity [m/s]

u_tau

Friction velocity [m/s]

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

print channel flow stats based on previously provided input

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

property H: float

Channel height [m]

Returns:

channel height

Return type:

float

property L: float

Channel length [m]

Returns:

channel length

Return type:

float

property M: float

Mach number based on freestream velocity []

Returns:

Mach number

Return type:

float

property Re: float

Reynolds number based on freestream velocity []

Returns:

Reynolds number

Return type:

float

property Re_tau: float

Reynolds number based on friction velocity []

Returns:

Reynolds number

Return type:

float

property T: float

Temperature [K]

Returns:

temperature

Return type:

float

property W: float

Channel width [m]

Returns:

channel width

Return type:

float

property delta: float

Channel half height [m]

Returns:

channel half height

Return type:

float

property mu: float

Dynamic viscosity [kg/(m s)]

Returns:

dynamic viscosity

Return type:

float

property p: float

Pressure [Pa]

Returns:

pressure

Return type:

float

print() → None[source]

print channel flow stats based on previously provided input

property rho: float

Density [kg/s]

Returns:

density

Return type:

float

property tau_w: float

Wall-shear stress [N/m^2]

Returns:

wall-shear stress

Return type:

float

property u: float

Velocity [m/s]

Returns:

velocity

Return type:

float

property u_tau: float

Friction velocity [m/s]

Returns:

friction velocity

Return type:

float

g3d.calc.calculators.expansion_wave module

Expansion wave calculator

class g3d.calc.calculators.expansion_wave.G3DExpansionWaveCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to Prandtl-Meyer expansions

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

analyze_expansion_region(*args, **kwargs)

Calculate pressure ratio (PR21 []), temperature ratio (TR21 []), and downstream Mach number (M2 []) for specified upstream Mach number (M1 []) and flow deflection (theta) flow deflection should be given in radians unless angle_type=AngleType.DEGREES is specified

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach(*args, **kwargs)

get_Mach(*args, **kwargs)

Finds Mach number corresponding to specified Prandtl-Meyer function value using the built-in Newton-Raphson solver the Prandtl-Meyer function value should be specified in radians unless angle_type=AngleType.DEGREES is specified

get_Prandtl_Meyer_function(*args, **kwargs)

Evaluates Prandtl-Meyer function for specified Mach number the value calculated is given in radians unless angle_type=AngleType.DEGREES is specified

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

analyze_expansion_region(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculate pressure ratio (PR21 []), temperature ratio (TR21 []), and downstream Mach number (M2 []) for specified upstream Mach number (M1 []) and flow deflection (theta) flow deflection should be given in radians unless angle_type=AngleType.DEGREES is specified

input: upstream Mach number (M1 []) and flow deflection (theta [rad or deg])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. flow deflection [rad or deg]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘theta’, ‘angle_type’

Returns:

flow expansion properties: downstream Mach number, pressure ratio, temperature ratio

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2, PR21, TR21 = cflow.expansion.analyze_expansion_region(M1=2.5, theta=10., angle_type=AngleType.DEGREES)

find_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach()

get_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds Mach number corresponding to specified Prandtl-Meyer function value using the built-in Newton-Raphson solver the Prandtl-Meyer function value should be specified in radians unless angle_type=AngleType.DEGREES is specified

input: Prandtl-Meyer value (theta [rad or deg])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    Prandtl-Meyer [rad or deg] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘theta’, ‘angle_type’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.expansion.get_Mach(theta=10., angle_type=AngleType.DEGREES)

get_Prandtl_Meyer_function(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Evaluates Prandtl-Meyer function for specified Mach number the value calculated is given in radians unless angle_type=AngleType.DEGREES is specified

input: Mach number (M [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    Mach number value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘angle_type’

Returns:

Prandtl-Meyer function value (nu) [rad or deg]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> nu = cflow.expansion.get_Prandtl_Meyer_function(M=2.5, angle_type=AngleType.DEGREES)

g3d.calc.calculators.friction module

One-dimensional flow with friction calculator

class g3d.calc.calculators.friction.G3DFrictionCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to one-dimensional flow with friction

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

choked_supersonic_find_shock_Mach(*args, ...)

choked_supersonic_get_shock_Mach(*args, **kwargs)

Finds Mach number (M []) upstream of shock in an over-choked (length longer than choked length) supersonic one-dimensional flow with friction.

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_L_star(*args, **kwargs)

find_Mach_from_pressure_ratio(*args, **kwargs)

find_Mach_from_temperature_ratio(*args, **kwargs)

find_Mach_from_total_pressure_ratio(*args, ...)

find_pipe_diameter_from_massflow(*args, **kwargs)

get_L_star(*args, **kwargs)

Calculates choke length (L* [m]) for specified Mach number

get_L_star_from_diameter_and_massflow(*args, ...)

Get choked length (Ls [m]) from pipe diameter (D [m]) and massflow (mp [kg/s])

get_Mach_from_L_star(*args, **kwargs)

Finds the Mach number (M []) matching the specified choked length (L* [m])

get_Mach_from_pressure_ratio(*args, **kwargs)

Finds the Mach number (M []) matching the specified pressure ratio (given by a local pressure (P [Pa]) and a choked pressure (Ps [Pa]))

get_Mach_from_temperature_ratio(*args, **kwargs)

Finds the Mach number (M []) matching the specified temperature ratio (given by a local temperature (T [K]) and a choked temperature (Ts [K]))

get_Mach_from_total_pressure_ratio(*args, ...)

Finds the Mach number (M []) matching the specified total pressure ratio

get_P(*args, **kwargs)

Calculates pressure (P [Pa]) for specified Mach number (M) and choke pressure (P* [Pa], P*=1.

get_P0(*args, **kwargs)

get_P0_star(*args, **kwargs)

get_PR_from_Mach(*args, **kwargs)

Get pressure ratio (PR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_P_star(*args, **kwargs)

Calculates choke pressure (P* [Pa]) for specified Mach number (M []) and pressure (P [Pa], P=1.

get_Po(*args, **kwargs)

Calculates total pressure (Po [Pa]) for specified Mach number (M []) and choked flow total pressure (Po* [Pa], Po*=1.

get_PoR_from_Mach(*args, **kwargs)

Get total pressure ratio (PoR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_Po_star(*args, **kwargs)

Calculates choke density (Po* [Pa]) for specified Mach number (M []) and total pressure (Po [Pa], Po=1.

get_RO(*args, **kwargs)

Calculates density (RO [kg/m^3]) for specified Mach number (M []) and choke density (RO* [kg/m^3], RO*=1.

get_RO_star(*args, **kwargs)

Calculates choke density (RO* [kg/m^3]) for specified Mach number (M []) and density (RO [kg/m^3], RO=1.

get_RR_from_Mach(*args, **kwargs)

Get density ratio (RR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_T(*args, **kwargs)

Calculates temperature (T [K]) for specified Mach number (M []) and choke temperature (T* [K], T*=1.

get_TR_from_Mach(*args, **kwargs)

Get temperature ratio (TR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_T_star(*args, **kwargs)

Calculates choke temperature (T* [K]) for specified Mach number (M) and temperature (T [K], T=1.

get_downstream_Mach(*args, **kwargs)

Two-station problem:

get_downstream_Mach_from_PR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and pressure ratio (PR [])

get_downstream_Mach_from_RR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and density ratio (RR [])

get_downstream_Mach_from_TR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and temperature ratio (TR [])

get_downstream_flow_state(*args, **kwargs)

Two-station problem:

get_downstream_pressure(*args, **kwargs)

Two-station problem:

get_downstream_temperature(*args, **kwargs)

Two-station problem:

get_friction_factor(*args, **kwargs)

Calculates friction factor (4fL/D []) for specified Mach number

get_pipe_diameter_from_massflow(*args, **kwargs)

Finds pipe diameter (D [m]) from specified massflow (mp [kg/s]).

get_upstream_Mach(*args, **kwargs)

Two-station problem:

get_upstream_Mach_from_PR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and pressure ratio (PR [])

get_upstream_Mach_from_RR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and density ratio (RR [])

get_upstream_Mach_from_TR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and temperature ratio (TR [])

get_upstream_flow_state(*args, **kwargs)

Two-station problem:

get_upstream_flow_state_after_overchoking(...)

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

get_upstream_flow_state_after_overchoking_2(...)

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

get_upstream_pressure(*args, **kwargs)

Two-station problem:

get_upstream_temperature(*args, **kwargs)

Two-station problem:

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

process_diagram_get_HS(M)

Extract HS-diagram data for one dimensional flow with friction

process_diagram_get_TS(T1, S1, M1, Ds, N)

Extract Ts-diagram data for one dimensional flow with friction

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

choked_supersonic_find_shock_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to choked_supersonic_get_shock_Mach()

choked_supersonic_get_shock_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds Mach number (M []) upstream of shock in an over-choked (length longer than choked length) supersonic one-dimensional flow with friction. The Mach number is estimated using the built-in Newton-Raphson solver.

input: inlet Mach number (M1 []), inlet temperature (T1 [K]), pipe length (L [m]), average Darcy friction factor (f []), and pipe diameter (D [m])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet Mach number

    2. inlet temperature [K]

    3. pipe length [m]

    4. average Darcy friction factor

    5. pipe diameter [m]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘f’, ‘D’

Returns:

shock Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.choked_supersonic_get_shock_Mach(M1=0.7, T1=300., f=0.005, D=0.1)

find_Mach_from_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_L_star()

find_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_pressure_ratio()

find_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_temperature_ratio()

find_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_total_pressure_ratio()

find_pipe_diameter_from_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_pipe_diameter_from_massflow()

get_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke length (L* [m]) for specified Mach number

input: Mach number (M []), average Darcy friction factor (f []), pipe diameter (D [m])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. average Darcy friction factor

    3. pipe diameter [m]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘f’, ‘D’

Returns:

choking length [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> L_star = cflow.friction.get_L_star(M=2.0, f=0.005, D=0.1)

get_L_star_from_diameter_and_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get choked length (Ls [m]) from pipe diameter (D [m]) and massflow (mp [kg/s])

input: pipe diameter (D [m]), massflow (mp [kg/s]), inlet pressure (P1 [Pa]), inlet temperature (T1 [K]), and average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. pipe diameter [m]

    2. massflow [kg/s]

    3. inlet pressure [Pa]

    4. inlet temperature [K]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘D’, ‘mp’, ‘P1’, ‘T1’, ‘f’

Returns:

choked length [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> L_star = cflow.friction.get_L_star_from_diameter_and_massflow(D=0.1, mp=4.75, P1=1.e5, T1=300., f=0.005)

get_Mach_from_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds the Mach number (M []) matching the specified choked length (L* [m])

The Mach number is estimated using the built-in Newton-Raphson solver

input: choke length (Ls [m]), average Darcy friction factor (f []), pipe diameter (D [m])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
*argsAny

arguments (optional input):

  1. choke length [m]

  2. average Darcy friction factor

  3. pipe diameter [m]

variable value(s) in above-listed order

**kwargsAny

keyword-value pairs (optional input):

valid keywords: ‘Ls’, ‘f’, ‘D’, ‘mode’

Returns:
float, ndarray

Mach number

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_L_star(Ls=10., f=0.005, D=0.1, mode=’subsonic’)

get_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds the Mach number (M []) matching the specified pressure ratio (given by a local pressure (P [Pa]) and a choked pressure (Ps [Pa]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local pressure (P [Pa]) and choked pressure (Ps [Pa])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. pressure [Pa]

    2. choked pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘P’, ‘Ps’, ‘mode’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_pressure_ratio(P=1.e5, Ps=1.6e5, mode=’subsonic’)

get_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds the Mach number (M []) matching the specified temperature ratio (given by a local temperature (T [K]) and a choked temperature (Ts [K]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local temperature (T [K]) and choked temperature (Ts [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. temperature [K]

    2. choked temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘T’, ‘Ts’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_temperature_ratio(T=300., Ts=600.)

get_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]
Finds the Mach number (M []) matching the specified total pressure ratio

(given by a local total pressure (Po [Pa]) and a choked total pressure (Pos [Pa]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local total pressure (Po [Pa]) and choked total pressure (Pos [Pa])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
*argsAny

arguments (optional input):

  1. total pressure [Pa]

  2. choked total pressure [Pa]

variable value(s) in above-listed order

**kwargsAny

keyword-value pairs (optional input):

valid keywords: ‘Po’, ‘Pos’, ‘mode’

Returns:
float, ndarray

Mach number

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_total_pressure_ratio(Po=1.e5, Pos=8.5e4, mode=’subsonic’)

get_P(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates pressure (P [Pa]) for specified Mach number (M) and choke pressure (P* [Pa], P*=1. if omitted)

input: Mach number (M []), choke pressure (P* [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Ps’

Returns:

flow pressure [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P = cflow.friction.get_P(M=2.0, Ps=1.e5)

get_P0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po()

get_P0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po_star()

get_PR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get pressure ratio (PR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

pressure ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> PR = cflow.friction.get_PR_from_Mach(M1=2.0, M2=1.5)

get_P_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke pressure (P* [Pa]) for specified Mach number (M []) and pressure (P [Pa], P=1. if omitted)

input: Mach number (M []), pressure (P [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘P’

Returns:

choked flow pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P_star = cflow.friction.get_P_star(M=2.0, P=1.e5)

get_Po(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates total pressure (Po [Pa]) for specified Mach number (M []) and choked flow total pressure (Po* [Pa], Po*=1. if omitted)

input: Mach number (M), choke total pressure (Po*) [Pa]

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked total pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Pos’

Returns:

total pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> Po = cflow.friction.get_Po(M=2.0, Pos=1.e5)

get_PoR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get total pressure ratio (PoR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

total pressure ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> PoR = cflow.friction.get_PoR_from_Mach(M1=2.0, M2=1.5)

get_Po_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke density (Po* [Pa]) for specified Mach number (M []) and total pressure (Po [Pa], Po=1. if omitted)

input: Mach number (M []), total pressure (Po [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. total pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Po’

Returns:

choked flow total pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> Po_star = cflow.friction.get_Po_star(M=2.0, Po=1.e5)

get_RO(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates density (RO [kg/m^3]) for specified Mach number (M []) and choke density (RO* [kg/m^3], RO*=1. if omitted)

input: Mach number (M []), choke density (RO* [kg/m^3])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked density [kg/m^3]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘ROs’

Returns:

flow density [kg/m^3]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RO = cflow.friction.get_RO(M=2.0, ROs=1.2)

get_RO_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke density (RO* [kg/m^3]) for specified Mach number (M []) and density (RO [kg/m^3], RO=1. if omitted)

input: Mach number (M []), density (RO [kg/m^3])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. density [kg/m^3]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘RO’

Returns:

choked flow density [kg/m^3]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RO_star = cflow.friction.get_RO_star(M=2.0, RO=1.2)

get_RR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get density ratio (RR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

density ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RR = cflow.friction.get_RR_from_Mach(M1=2.0, M2=1.5)

get_T(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates temperature (T [K]) for specified Mach number (M []) and choke temperature (T* [K], T*=1. if omitted)

input: Mach number (M []), choke temperature (T* [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Ts’

Returns:

flow temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T = cflow.friction.get_T(M=2.0, Ts=300.)

get_TR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get temperature ratio (TR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

temperature ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> TR = cflow.friction.get_TR_from_Mach(M1=2.0, M2=1.5)

get_T_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke temperature (T* [K]) for specified Mach number (M) and temperature (T [K], T=1. if omitted)

input: Mach number (M []), temperature (T [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘T’

Returns:

choked flow temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T_star = cflow.friction.get_T_star(M=2.0, T=300.)

get_downstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream Mach number (M2 []) based on upstream Mach number (M1 []) and pipe length (L [m])

input: upstream Mach number (M1 []), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. pipe length [m]

    3. pipe diameter [m]

    4. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach(M1=2.0, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_Mach_from_PR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and pressure ratio (PR [])

input: upstream Mach number (M1 []) and pressure ratio (PR []) example: M2 = get_downstream_Mach_from_PR(M1=M1, PR=PR)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. pressure ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘PR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_PR(M1=2.0, PR=0.2)

get_downstream_Mach_from_RR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and density ratio (RR [])

input: upstream Mach number (M1 []) and density ratio (RR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. density ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘RR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_RR(M1=2.0, RR=0.25)

get_downstream_Mach_from_TR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and temperature ratio (TR [])

input: upstream Mach number (M1 []) and temperature ratio (TR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. temperature ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘TR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_TR(M1=2.0, TR=0.9)

get_downstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Two-station problem:

Calculates downstream flow state (Mach number (M2 []), temperature (T2 [K]), and pressure (P2 [Pa])) based on upstream flow state (Mach number (M1 []), temperature (T1 [K]), and pressure (P1 [Pa])), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static temperature [K]

    3. upstream static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘P1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream flowstate: Mach number, temperature [K], pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2, T2, P2 = cflow.friction.get_downstream_flow_state(M1=2.0, T1=300., P1=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream pressure (P2 [Pa]) based on upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static pressure [Pa]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘P1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P2 = cflow.friction.get_downstream_pressure(M1=2.0, P1=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static temperature [K]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T2 = cflow.friction.get_downstream_temperature(M1=0.8, T1=300., L=10., D=0.1, f=0.005, mode=’subsonic’)

get_friction_factor(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates friction factor (4fL/D []) for specified Mach number

input: Mach number (M [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) – arguments (optional input): Mach number value(s)

  • **kwargs (Any) – keyword-value pairs (optional input): valid keywords: ‘M’

Returns:

friction factor

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> ff = cflow.friction.get_friction_factor(M=2.0)

get_pipe_diameter_from_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds pipe diameter (D [m]) from specified massflow (mp [kg/s]). The pipe diameter is estimated using the built-in Newton-Raphson solver

input: inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), pipe length (L [m]), massflow (mp [kg/s]), and average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet temperature [K]

    2. inlet pressure [Pa]

    3. pipe length [m]

    4. massflow [kg/s]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘T1’, ‘P1’, ‘L’, ‘mp’, ‘f’

Returns:

diameter [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> D = cflow.friction.get_pipe_diameter_from_massflow(T1=300, P1=1.e5, L=2.0, mp=3.0, f=0.005)

get_upstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream Mach number (M1 []) based on downstream Mach number (M2 []) and pipe length (L [m])

input: downstream Mach number (M2 []), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. pipe length [m]

    3. pipe diameter [m]

    4. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach(M2=0.8, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_Mach_from_PR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and pressure ratio (PR [])

input: downstream Mach number (M2 []) and pressure ratio (PR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. pressure ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘PR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach_from_PR(M2=0.8, PR=0.2)

get_upstream_Mach_from_RR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and density ratio (RR [])

input: downstream Mach number (M2 []) and density ratio (RR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. density ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘RR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_downstream_Mach_from_RR(M2=0.8, RR=0.25)

get_upstream_Mach_from_TR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and temperature ratio (TR [])

input: downstream Mach number (M2 []) and temperature ratio (TR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. temperature ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘TR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach_from_TR(M2=0.8, TR=0.9)

get_upstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Two-station problem:

Calculates upstream flow state (Mach number (M1 []), temperature (T1 [K]), and pressure (P1 [Pa])) based on downstream flow state (Mach number (M2 []), temperature (T2 [K]), and pressure (P2 [Pa])), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static temperature [K]

    3. downstream static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘T2’, ‘P2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream flowstate: Mach number, temperature [K], pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state(M2=0.8, T2=300., P2=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_flow_state_after_overchoking(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

The upstream flow state is calculated based on prescribed total conditions at the upstream flow station (To [K], Po [Pa]), exit static pressure (P2 [Pa]), pipe length (L [m])

input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet total temperature [K]

    2. inlet total pressure [Pa]

    3. exit static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘To’, ‘Po’, ‘P2’, ‘L’, ‘D’, ‘f’

Returns:

upstream flow state: Mach number, temperature and pressure

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state_after_overchoking(To=300., Po=1.e5, P2=7.5e4, L=3., D=0.1, f=0.005)

get_upstream_flow_state_after_overchoking_2(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

The upstream flow state is calculated based on prescribed total conditions at the upstream flow station (To [K], Po [Pa]), exit static pressure (P2 [Pa]), pipe length (L [m])

input: inlet mach number (M1 []), inlet static temperature (T1 [K]), inlet static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet mach number

    2. inlet static temperature [K]

    3. inlet static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘P1’, ‘L’, ‘D’, ‘f’

Returns:

upstream flow state: Mach number, temperature [K] and pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state_after_overchoking_2(M1=2.0, T1=300., P1=1.e5, L=10., D=0.1, f=0.005)

get_upstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream pressure (P1 [Pa]) based on downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static pressure (P2 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static pressure [Pa]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘P2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P1 = cflow.friction.get_upstream_pressure(M2=0.8, P2=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static temperature [K]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘T2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T1 = cflow.friction.get_upstream_temperature(M2=0.8, T2=300., L=10., D=0.1, f=0.005, mode=’subsonic’)

process_diagram_get_HS(M: float | list[float] | ndarray) → Tuple[float, float] | Tuple[list[float], list[float]] | Tuple[ndarray, ndarray][source]

Extract HS-diagram data for one dimensional flow with friction

input: Mach number (M [])

Parameters:

M (float, list[float], or ndarray :) – Mach number(s)

Returns:

H, Ds tuple[float, float], tuple[list[float], list[float]], tuple[ndarray, ndarray]

Return type:

tuple

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> H, Ds = cflow.friction.process_diagram_get_HS(M)

process_diagram_get_TS(T1: float, S1: float, M1: float, Ds: float, N: int) → Tuple[ndarray, ...][source]

Extract Ts-diagram data for one dimensional flow with friction

input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), entropy increment (Ds [J/K]), number of points (N)

Parameters:
  • T1 (float :) – temperature (T1) [K]

  • S1 (float :) – entropy (S1) [J/K]

  • M1 (float :) – Mach number

  • Ds (float :) – entropy change [J/K]

  • N (int :) – number of points

Returns:

T, S tuple[ndarray, …]

Return type:

tuple

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T, S = cflow.friction.process_diagram_get_TS(T1, S1, M1, Ds, N)

g3d.calc.calculators.generic module

Generic calculator class

class g3d.calc.calculators.generic.G3DGenericCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCode

Generic calculator class (base class for all problem-specific calculators)

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

Newton_Raphson_solver(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Runs Newton-Raphson solver on specified function

input: function (func), iteration start value (start_value), function target value (target_value)

optional input (kwargs): numerical differentiation delta (delta, default 0.0001), maximum number of iterations (maxiter, default 100), tolerance (tol, default 1.e-6), lower function limit (lower_bound), upper function limit (upper_bound)

Parameters:
  • func (Callable :) – function to solve

  • *args (Any) –

    arguments (optional input):

    1. start value

    2. target value

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘delta’, ‘maxiter’, ‘tol’, ‘lower_bound’, ‘upper_bound’

    (any other keyword->argument input will be passed on to the specified function)

Returns:

Newton-Raphson solver result

Return type:

float

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> result = cflow.Newton_Raphson_solver(func, start_value=10., target_value=0.)

backup() → None[source]

Backup of stored variables

property gas: Gas

Gas object

property newton: G3DNewtonRaphsonSolver

Newton-Raphson solver

newton_reset() → None[source]

Deprecated since version 2.6: redirects to reset_newton()

print() → None[source]

Prints allocated variables

reset_newton() → None[source]

Resets Newton-Raphson solver to its default state

restore() → None[source]

Restore variable state from backup

set_from_key_value(key: str, value: Any) → bool[source]

Checks if provided key is in list of defined keys and updates calculator settings accordingly

g3d.calc.calculators.heat module

One-dimensional flow with heat addition calculator

class g3d.calc.calculators.heat.G3DHeatCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to one-dimensional flow with heat addition

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_Q_star_and_T0(*args, **kwargs)

find_Mach_from_Q_star_and_T0s(*args, **kwargs)

find_Mach_from_pressure_ratio(*args, **kwargs)

find_Mach_from_q_star_and_To(*args, **kwargs)

find_Mach_from_q_star_and_Tos(*args, **kwargs)

find_Mach_from_temperature_ratio(*args, **kwargs)

find_Mach_from_total_temperature_ratio(...)

get_Mach_from_pressure_ratio(*args, **kwargs)

calculates local flow Mach number (M []) from provided local pressure (P [Pa]) and choked flow pressure (Ps [Pa]) input: local pressure (P [Pa]), choked flow pressure (Ps [Pa]) example: M = get_Mach_from_pressure_ratio(P=P, Ps=Ps)

get_Mach_from_q_star_and_To(*args, **kwargs)

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: choked flow heat addition (qs [J/kg]), local total temperature (To [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_q_star_and_To(qs=qs, To=To)

get_Mach_from_q_star_and_Tos(*args, **kwargs)

calculates local flow Mach number (M []) from provided choked flow total temperature (Tos [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: choked flow heat addition (qs [J/kg]), choked flow total temperature (Tos [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_q_star_and_Tos(qs=qs, Tos=Tos)

get_Mach_from_temperature_ratio(*args, **kwargs)

calculates local flow Mach number (M []) from provided local temperature (T [K]) and choked flow temperature (Ts [K]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: local temperature (T [K]), choked flow temperature (Ts [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_temperature_ratio(T=T, Ts=Ts)

get_Mach_from_total_temperature_ratio(*args, ...)

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow total temperature (Tos [K]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: local total temperature (To [K]), choked flow total temperature (Tos [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_total_temperature_ratio(To=To, Tos=Tos)

get_P(*args, **kwargs)

calculates local pressure (P [Pa]) based on provided choked flow pressure (Ps [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow pressure (Ps [Pa]) example: P = get_P(M=M, Ps=Ps)

get_P0(*args, **kwargs)

get_P0_star(*args, **kwargs)

get_P_star(*args, **kwargs)

calculates choked flow pressure (Ps [Pa]) based on provided local pressure (P [Pa]) and flow Mach number (M []) input: flow Mach number (M []), pressure (P [Pa]) example: Ps = get_P_star(M=M, P=P)

get_Po(*args, **kwargs)

calculates local total pressure (Po [Pa]) based on provided choked flow total pressure (Pos [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total pressure (Pos [Pa]) example: Po = get_Po(M=M, Pos=Pos)

get_Po_star(*args, **kwargs)

calculates choked flow total pressure (Pos [Pa]) based on provided local total pressure (Po [Pa]) and flow Mach number (M []) input: flow Mach number (M []), total pressure (Po [Pa]) example: Pos = get_Po_star(M=M, Po=Po)

get_Q_star(*args, **kwargs)

get_RO(*args, **kwargs)

calculates local density (RO [kg/m^3]) based on provided choked flow density (ROs [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), choked flow density (ROs [kg/m^3]) example: RO = get_RO(M=M, ROs=ROs)

get_RO_star(*args, **kwargs)

calculates choked flow density (ROs [kg/m^3]) based on provided local density (RO [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), density (RO [kg/m^3]) example: ROs = get_RO_star(M=M, RO=RO)

get_T(*args, **kwargs)

calculates local temperature (T [K]) based on provided choked flow temperature (Ts [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow temperature (Ts [K]) example: T = get_T(M=M, Ts=Ts)

get_T0(*args, **kwargs)

get_T0_star(*args, **kwargs)

get_T_star(*args, **kwargs)

calculates choked flow temperature (Ts [K]) based on provided local temperature (T [K]) and flow Mach number (M []) input: flow Mach number (M []), temperature (T [K]) example: Ts = get_T_star(M=M, T=T)

get_To(*args, **kwargs)

calculates local total temperature (To [K]) based on provided choked flow total temperature (Tos [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total temperature (Tos [K]) example: To = get_To(M=M, Tos=Tos)

get_To_star(*args, **kwargs)

calculates choked flow total temperature (Tos [K]) based on provided local total temperature (To [K]) and flow Mach number (M []) input: flow Mach number (M []), total temperature (To [K]) example: Tos = get_To_star(M=M, To=To)

get_downstream_flow_state(*args, **kwargs)

two-station problem: calculates downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) based on upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M2, T2, P2 = get_downstream_flow_state(M1=M1, T1=T1, P1=P1, q=q, mode='subsonic')

get_downstream_pressure(*args, **kwargs)

two-station problem: calculates downstream pressure (P2 [Pa]) based on upstream temperature (T1 [K]), upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: P2 = get_downstream_pressure(M1=M1, T1=T1, P1=P1, q=q, mode='subsonic')

get_downstream_temperature(*args, **kwargs)

two-station problem: calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: T2 = get_downstream_temperature(M1=M1, T1=T1, q=q, mode='subsonic')

get_q_star(*args, **kwargs)

calculates choked flow heat addition from specified local total temperature (To [K]) and flow Mach number (M []) input: Mach number (M []), total temperature (To [K]) example qs = get_q_star(M=M, To=To)

get_upstream_flow_state(*args, **kwargs)

two-station problem: calculates upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) based on downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M1, T1, P1 = get_upstream_flow_state(M2=M2, T2=T2, P2=P2, q=q, mode='subsonic')

get_upstream_flow_state_after_overchoking(...)

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (Po [Pa], To [K]) the inlet static flow conditions are obtained such that the provided exit pressure is matched input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking(To=To, Po=Po, P2=P2, q=q)

get_upstream_flow_state_after_overchoking_2(...)

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (M1 [], T1 [K], P1 [Pa]) input: inlet Mach number (M1 []), inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking_2(M1=M1, T1=T1, P1=P1, q=q)

get_upstream_pressure(*args, **kwargs)

two-station problem: calculates upstream pressure (P1 [Pa]) based on downstream temperature (T2 [K]), downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: P1 = get_upstream_pressure(M2=M2, T2=T2, P2=P2, q=q, mode='subsonic')

get_upstream_temperature(*args, **kwargs)

two-station problem: calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: T1 = get_upstream_temperature(M2=M2, T2=T2, q=q, mode='subsonic')

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

process_diagram_get_HS(M)

extract HS-diagram data for one dimensional flow with heat addition input: Mach number (M []) example: H, DS = process_diagram_get_HS(M)

process_diagram_get_PVH(v, p1, v1, T1, q)

extract PVH-diagram data for one dimensional flow with heat addition input: specific volume (v [m^3/kg]), reference pressure (p1 [Pa]), reference specific volume (v1 [m^3/kg]), reference temperature (T1 [K]), added heat (q [J/kg]) example: H = process_diagram_get_PVH(v, p1, v1, T1, q)

process_diagram_get_TS(T1, S1, M1, Q, N)

extract Ts-diagram data for one dimensional flow with friction input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), added heat (Q [J/kg]), number of points (N) example: T, S = process_diagram_get_TS(T1, S1, M1, Q, N)

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_Mach_from_Q_star_and_T0(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_To()

find_Mach_from_Q_star_and_T0s(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_Tos()

find_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_pressure_ratio()

find_Mach_from_q_star_and_To(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_To()

find_Mach_from_q_star_and_Tos(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_Tos()

find_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_temperature_ratio()

find_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_total_temperature_ratio()

get_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local pressure (P [Pa]) and choked flow pressure (Ps [Pa]) input: local pressure (P [Pa]), choked flow pressure (Ps [Pa]) example: M = get_Mach_from_pressure_ratio(P=P, Ps=Ps)

get_Mach_from_q_star_and_To(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: choked flow heat addition (qs [J/kg]), local total temperature (To [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_q_star_and_To(qs=qs, To=To)

get_Mach_from_q_star_and_Tos(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided choked flow total temperature (Tos [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: choked flow heat addition (qs [J/kg]), choked flow total temperature (Tos [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_q_star_and_Tos(qs=qs, Tos=Tos)

get_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local temperature (T [K]) and choked flow temperature (Ts [K]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: local temperature (T [K]), choked flow temperature (Ts [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_temperature_ratio(T=T, Ts=Ts)

get_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow total temperature (Tos [K]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: local total temperature (To [K]), choked flow total temperature (Tos [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_total_temperature_ratio(To=To, Tos=Tos)

get_P(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local pressure (P [Pa]) based on provided choked flow pressure (Ps [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow pressure (Ps [Pa]) example: P = get_P(M=M, Ps=Ps)

get_P0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po()

get_P0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po_star()

get_P_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow pressure (Ps [Pa]) based on provided local pressure (P [Pa]) and flow Mach number (M []) input: flow Mach number (M []), pressure (P [Pa]) example: Ps = get_P_star(M=M, P=P)

get_Po(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local total pressure (Po [Pa]) based on provided choked flow total pressure (Pos [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total pressure (Pos [Pa]) example: Po = get_Po(M=M, Pos=Pos)

get_Po_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow total pressure (Pos [Pa]) based on provided local total pressure (Po [Pa]) and flow Mach number (M []) input: flow Mach number (M []), total pressure (Po [Pa]) example: Pos = get_Po_star(M=M, Po=Po)

get_Q_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_q_star()

get_RO(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local density (RO [kg/m^3]) based on provided choked flow density (ROs [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), choked flow density (ROs [kg/m^3]) example: RO = get_RO(M=M, ROs=ROs)

get_RO_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow density (ROs [kg/m^3]) based on provided local density (RO [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), density (RO [kg/m^3]) example: ROs = get_RO_star(M=M, RO=RO)

get_T(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local temperature (T [K]) based on provided choked flow temperature (Ts [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow temperature (Ts [K]) example: T = get_T(M=M, Ts=Ts)

get_T0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_To()

get_T0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_To_star()

get_T_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow temperature (Ts [K]) based on provided local temperature (T [K]) and flow Mach number (M []) input: flow Mach number (M []), temperature (T [K]) example: Ts = get_T_star(M=M, T=T)

get_To(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local total temperature (To [K]) based on provided choked flow total temperature (Tos [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total temperature (Tos [K]) example: To = get_To(M=M, Tos=Tos)

get_To_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow total temperature (Tos [K]) based on provided local total temperature (To [K]) and flow Mach number (M []) input: flow Mach number (M []), total temperature (To [K]) example: Tos = get_To_star(M=M, To=To)

get_downstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

two-station problem: calculates downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) based on upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M2, T2, P2 = get_downstream_flow_state(M1=M1, T1=T1, P1=P1, q=q, mode=’subsonic’)

get_downstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates downstream pressure (P2 [Pa]) based on upstream temperature (T1 [K]), upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: P2 = get_downstream_pressure(M1=M1, T1=T1, P1=P1, q=q, mode=’subsonic’)

get_downstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: T2 = get_downstream_temperature(M1=M1, T1=T1, q=q, mode=’subsonic’)

get_q_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow heat addition from specified local total temperature (To [K]) and flow Mach number (M []) input: Mach number (M []), total temperature (To [K]) example qs = get_q_star(M=M, To=To)

get_upstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

two-station problem: calculates upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) based on downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M1, T1, P1 = get_upstream_flow_state(M2=M2, T2=T2, P2=P2, q=q, mode=’subsonic’)

get_upstream_flow_state_after_overchoking(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (Po [Pa], To [K]) the inlet static flow conditions are obtained such that the provided exit pressure is matched input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking(To=To, Po=Po, P2=P2, q=q)

get_upstream_flow_state_after_overchoking_2(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (M1 [], T1 [K], P1 [Pa]) input: inlet Mach number (M1 []), inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking_2(M1=M1, T1=T1, P1=P1, q=q)

get_upstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates upstream pressure (P1 [Pa]) based on downstream temperature (T2 [K]), downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: P1 = get_upstream_pressure(M2=M2, T2=T2, P2=P2, q=q, mode=’subsonic’)

get_upstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: T1 = get_upstream_temperature(M2=M2, T2=T2, q=q, mode=’subsonic’)

process_diagram_get_HS(M: float | list[float] | ndarray) → Tuple[float, float] | Tuple[list[float], list[float]] | Tuple[ndarray, ndarray][source]

extract HS-diagram data for one dimensional flow with heat addition input: Mach number (M []) example: H, DS = process_diagram_get_HS(M)

process_diagram_get_PVH(v: float | list[float] | ndarray, p1: float, v1: float, T1: float, q: float) → float | list[float] | ndarray[source]

extract PVH-diagram data for one dimensional flow with heat addition input: specific volume (v [m^3/kg]), reference pressure (p1 [Pa]), reference specific volume (v1 [m^3/kg]), reference temperature (T1 [K]), added heat (q [J/kg]) example: H = process_diagram_get_PVH(v, p1, v1, T1, q)

process_diagram_get_TS(T1: float, S1: float, M1: float, Q: float, N: int) → Tuple[ndarray, ...][source]

extract Ts-diagram data for one dimensional flow with friction input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), added heat (Q [J/kg]), number of points (N) example: T, S = process_diagram_get_TS(T1, S1, M1, Q, N)

g3d.calc.calculators.ideal_gas module

Ideal-gas calculator

class g3d.calc.calculators.ideal_gas.G3DIdealGasCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to the thermodynamics state

Attributes:
C

Speed of sound [m/s]

P

Pressure [Pa]

RO

Density [kg/m^3]

T

Temperature [K]

gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_density(*args, **kwargs)

calculates density (RO [kg/m^3]) using the ideal gas law input: pressure (P [Pa]) and temperature (T [K]) example: RO = get_density(P=P, T=T)

get_pressure(*args, **kwargs)

calculates pressure (P [Pa]) using the ideal gas law input: temperature (T [K]) and density (RO [kg/m^3]) example: P = get_pressure(T=T, RO=RO)

get_speed_of_sound(*args, **kwargs)

calculates speed of sound (C [m/s]) input: temperature (T [K]) example: C = get_speed_of_sound(T=T)

get_temperature(*args, **kwargs)

calculates temperature (T [K]) using the ideal gas law input: pressure (P [Pa]) and density (RO [kg/m^3]) example: T = get_temperature(P=P, RO=RO)

get_temperature_from_speed_of_sound(*args, ...)

calculates temperature (T [K]) from speed of sound (C [m/s]) input: speed of sound (C [m/s]) example: T = get_temperature_from_speed_of_sound(C=C)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

property C: float

Speed of sound [m/s]

property P: float

Pressure [Pa]

property RO: float

Density [kg/m^3]

property T: float

Temperature [K]

get_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density (RO [kg/m^3]) using the ideal gas law input: pressure (P [Pa]) and temperature (T [K]) example: RO = get_density(P=P, T=T)

get_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure (P [Pa]) using the ideal gas law input: temperature (T [K]) and density (RO [kg/m^3]) example: P = get_pressure(T=T, RO=RO)

get_speed_of_sound(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates speed of sound (C [m/s]) input: temperature (T [K]) example: C = get_speed_of_sound(T=T)

get_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature (T [K]) using the ideal gas law input: pressure (P [Pa]) and density (RO [kg/m^3]) example: T = get_temperature(P=P, RO=RO)

get_temperature_from_speed_of_sound(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates temperature (T [K]) from speed of sound (C [m/s]) input: speed of sound (C [m/s]) example: T = get_temperature_from_speed_of_sound(C=C)

g3d.calc.calculators.moving_expansion module

Finite non-linear wave calculator (moving expansion regions)

class g3d.calc.calculators.moving_expansion.G3DMovingExpansionCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to moving expansion regions

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_U_from_C_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local speed of sound (C [m/s]) and speed of sound ahead of expansion region (RO4 [kg/m^3]) input: local speed of sound (C [m/s]), speed of sound ahead of expansion region (C4 [m/s]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_C_ratio(C=C, C4=C4)

get_U_from_density_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), and temperature ahead of expansion region (T4 [K]) input: local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_density_ratio(RO=RO, RO4=RO4, T4=T4)

get_U_from_pressure_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), and temperature ahead of expansion region (T4 [K]) input: local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_pressure_ratio(P=P, P4=P4, T4=T4)

get_U_from_temperature_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local temperature (T [K]), and temperature ahead of expansion region (T4 [K]) input: local temperature (T [K]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_temperature_ratio(T=T, T4=T4)

get_density(*args, **kwargs)

calculates density for a location inside a moving expansion region (RO [kg/m^3]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) example RO = get_density(U=U, T4=T4, RO4=RO4)

get_pressure(*args, **kwargs)

calculates pressure for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) example P = get_pressure(U=U, T4=T4, P4=P4)

get_speed_of_sound(*args, **kwargs)

calculates speed of sound for a location inside a moving expansion region (C [m/s]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example C = get_speed_of_sound(U=U, T4=T4)

get_temperature(*args, **kwargs)

calculates temperature for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example T = get_temperature(U=U, T4=T4)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_U_from_C_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local speed of sound (C [m/s]) and speed of sound ahead of expansion region (RO4 [kg/m^3]) input: local speed of sound (C [m/s]), speed of sound ahead of expansion region (C4 [m/s]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_C_ratio(C=C, C4=C4)

get_U_from_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), and temperature ahead of expansion region (T4 [K]) input: local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_density_ratio(RO=RO, RO4=RO4, T4=T4)

get_U_from_pressure_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), and temperature ahead of expansion region (T4 [K]) input: local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_pressure_ratio(P=P, P4=P4, T4=T4)

get_U_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local temperature (T [K]), and temperature ahead of expansion region (T4 [K]) input: local temperature (T [K]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_temperature_ratio(T=T, T4=T4)

get_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density for a location inside a moving expansion region (RO [kg/m^3]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) example RO = get_density(U=U, T4=T4, RO4=RO4)

get_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) example P = get_pressure(U=U, T4=T4, P4=P4)

get_speed_of_sound(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates speed of sound for a location inside a moving expansion region (C [m/s]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example C = get_speed_of_sound(U=U, T4=T4)

get_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example T = get_temperature(U=U, T4=T4)

g3d.calc.calculators.moving_shock module

Moving shock wave calculator

class g3d.calc.calculators.moving_shock.G3DMovingShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to moving shock waves

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_PR21_from_Mr(*args, **kwargs)

find_PR21_from_Ms(*args, **kwargs)

find_PR21_from_PR51(*args, **kwargs)

find_PR21_from_TR51(*args, **kwargs)

find_PR21_from_up(*args, **kwargs)

get_Mr(*args, **kwargs)

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock Mach number (Ms []) input: incident shock Mach number (Ms []) example: Mr = get_Mr(Ms=Ms)

get_Mr_from_PR21(*args, **kwargs)

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock pressure ratio (PR21 []) input: incident shock Mach number (Ms []) example: Mr = get_Mr_from_PR21(PR21=PR21)

get_Ms(*args, **kwargs)

calculates incident shock Mach number (Ms []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example: Ms = get_Ms(PR21=PR21)

get_PR21_from_Mr(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from reflected shock Mach number (Mr []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock Mach number (Mr []) example PR21 = get_PR21_from_Mr(Mr=Mr)

get_PR21_from_Ms(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from shock Mach number (Ms []) input: incident shock Mach number (Ms []) example PR21 = get_PR21_from_Ms(Ms=Ms)

get_PR21_from_PR51(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from the ratio of pressure behind the reflected shock (P5) and the pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow pressure ratio (PR51 []) example PR21 = get_PR21_from_PR51(PR51=PR51)

get_PR21_from_TR51(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from the ratio of temperature behind the reflected shock (T5) and the temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow temperature ratio (TR51 []) example PR21 = get_PR21_from_TR51(TR51=TR51)

get_PR21_from_up(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from induced flow velocity (Up [m/s]) the pressure ratio is calculated using the built-in Newton-Raphson solver input: induced flow velocity (Up [m/s]), temperature of the undisturbed flow ahead of the incident shock (T1 [K]) example PR21 = get_PR21_from_up(Up=Up, T1=T1)

get_PR51_from_PR21(*args, **kwargs)

calculates ratio of pressure behind reflected shock (P5) and pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: PR51 = get_PR51_from_PR21(PR21=PR21)

get_TR51_from_PR21(*args, **kwargs)

calculates ratio of temperature behind reflected shock (T5) and temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: TR51 = get_TR51_from_PR21(PR21=PR21)

get_density_ratio(*args, **kwargs)

calculates shock density ratio (RR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example RR21 = get_density_ratio(PR21=PR21)

get_temperature_ratio(*args, **kwargs)

calculates shock temperature ratio (TR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example TR21 = get_temperature_ratio(PR21=PR21)

get_up(*args, **kwargs)

calculates induced flow velocity (Up [m/s], velocity behind incident shock) corresponding to specified shock pressure ratio (PR21 []) and temperature in front of incident shock (T1 [K]) input: shock pressure ratio (PR21 []), temperature in front of incident shock (T1 [K]) example: Up = get_up(PR21=PR21, T1=T1)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_PR21_from_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_Mr()

find_PR21_from_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_Ms()

find_PR21_from_PR51(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_PR51()

find_PR21_from_TR51(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_PR21_from_TR51()

find_PR21_from_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_up()

get_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock Mach number (Ms []) input: incident shock Mach number (Ms []) example: Mr = get_Mr(Ms=Ms)

get_Mr_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock pressure ratio (PR21 []) input: incident shock Mach number (Ms []) example: Mr = get_Mr_from_PR21(PR21=PR21)

get_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates incident shock Mach number (Ms []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example: Ms = get_Ms(PR21=PR21)

get_PR21_from_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from reflected shock Mach number (Mr []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock Mach number (Mr []) example PR21 = get_PR21_from_Mr(Mr=Mr)

get_PR21_from_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from shock Mach number (Ms []) input: incident shock Mach number (Ms []) example PR21 = get_PR21_from_Ms(Ms=Ms)

get_PR21_from_PR51(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from the ratio of pressure behind the reflected shock (P5) and the pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow pressure ratio (PR51 []) example PR21 = get_PR21_from_PR51(PR51=PR51)

get_PR21_from_TR51(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates pressure ratio of incident shock (PR21 []) from the ratio of temperature behind the reflected shock (T5) and the temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow temperature ratio (TR51 []) example PR21 = get_PR21_from_TR51(TR51=TR51)

get_PR21_from_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from induced flow velocity (Up [m/s]) the pressure ratio is calculated using the built-in Newton-Raphson solver input: induced flow velocity (Up [m/s]), temperature of the undisturbed flow ahead of the incident shock (T1 [K]) example PR21 = get_PR21_from_up(Up=Up, T1=T1)

get_PR51_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates ratio of pressure behind reflected shock (P5) and pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: PR51 = get_PR51_from_PR21(PR21=PR21)

get_TR51_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates ratio of temperature behind reflected shock (T5) and temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: TR51 = get_TR51_from_PR21(PR21=PR21)

get_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates shock density ratio (RR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example RR21 = get_density_ratio(PR21=PR21)

get_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates shock temperature ratio (TR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example TR21 = get_temperature_ratio(PR21=PR21)

get_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates induced flow velocity (Up [m/s], velocity behind incident shock) corresponding to specified shock pressure ratio (PR21 []) and temperature in front of incident shock (T1 [K]) input: shock pressure ratio (PR21 []), temperature in front of incident shock (T1 [K]) example: Up = get_up(PR21=PR21, T1=T1)

g3d.calc.calculators.newton_raphson module

Newton-Raphson calculator

class g3d.calc.calculators.newton_raphson.G3DNewtonRaphsonSolver(*args: Any, **kwargs: Any)[source]

Bases: G3DCode

Newton-Raphson solver

Attributes:
check_lower_bound

Check lower bound (bool, default value: False)

check_upper_bound

Check upper bound (bool, default value: False)

coarse_delta

Delta used in coarse search (default 1.e-2)

delta

Delta used for numerical differentiation (default 1.e-4)

end_value

Search end value

lower_bound

Lower function bound, one-sided numerical differentiation used if needed

max_iter

Maximum number of Newton-Raphson iterations (default 100)

scipy_kwargs

Scipy Newton-Raphson parameters

solver_mode

Newton-Raphson solver mode: native (default) or scipy

start_value

Newton search start value

tag

tag (string) used for identification

target_value

Function target value

tolerance

Newton-Raphson tolerance = abs(value - target_value), (default 1.e-6)

upper_bound

Upper function bound, one-sided numerical differentiation used if needed

verbose

Verbose mode => prints iteration information (default False)

Methods

copy(e)

copies data from specified entity input: entity example: copy(e)

find_start_value(func, *args, **kwargs)

Finds start value using coarse search for provided function

get_settings_from_solver(newton)

copy settings from provided Newton-Raphson solver object input: Newton-Raphson solver object

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

native_solve(func, *args, **kwargs)

Executes native Newton-Raphson for provided function and parameters

print()

Prints solver settings

reset()

Resets Newton-Raphson solver parameters to their default values

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Set parameters from provided key => value input

solve(func, *args, **kwargs)

Executes scipy Newton-Raphson for provided function and parameters

update_settings(**kwargs)

Updates Newton-Raphson solver parameters

property check_lower_bound: bool

False)

Type:

Check lower bound (bool, default value

property check_upper_bound: bool

False)

Type:

Check upper bound (bool, default value

property coarse_delta: float

Delta used in coarse search (default 1.e-2)

property delta: float

Delta used for numerical differentiation (default 1.e-4)

property end_value: float

Search end value

find_start_value(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Finds start value using coarse search for provided function

get_settings_from_solver(newton: G3DNewtonRaphsonSolver) → None[source]

copy settings from provided Newton-Raphson solver object input: Newton-Raphson solver object

property lower_bound: float

Lower function bound, one-sided numerical differentiation used if needed

property max_iter: int

Maximum number of Newton-Raphson iterations (default 100)

native_solve(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Executes native Newton-Raphson for provided function and parameters

print() → None[source]

Prints solver settings

reset() → None[source]

Resets Newton-Raphson solver parameters to their default values

property scipy_kwargs: dict[Any, Any]

Scipy Newton-Raphson parameters

set_from_key_value(key: str, value: Any) → bool[source]

Set parameters from provided key => value input

solve(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Executes scipy Newton-Raphson for provided function and parameters

property solver_mode: Any

native (default) or scipy

Type:

Newton-Raphson solver mode

property start_value: float

Newton search start value

property target_value: float

Function target value

property tolerance: float

Newton-Raphson tolerance = abs(value - target_value), (default 1.e-6)

update_settings(**kwargs: Any) → None[source]

Updates Newton-Raphson solver parameters

property upper_bound: float

Upper function bound, one-sided numerical differentiation used if needed

property verbose: bool

Verbose mode => prints iteration information (default False)

g3d.calc.calculators.normal_shock module

Normal-shock calculator

class g3d.calc.calculators.normal_shock.G3DNormalShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to normal shocks

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_downstream_Astar(*args, **kwargs)

calculate choke cross-section area downstream of normal shock (As2 [m^2]) as function of upstream Mach number (M1 []),and upstream choke cross-section area (As1 [m^2]) input: upstream Mach number (M1 []), upstream choke cross-section area (As1 [m^2], default value: 1.0) example: As2 = get_downstream_Astar(M1=M1, As1=As1)

get_downstream_Mach(*args, **kwargs)

calculate Mach number downstream of normal shock (M2 []) as function of upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: M2 = get_downstream_Mach(M1=M1)

get_downstream_density(*args, **kwargs)

calculate density downstream of normal shock (RO2 [kg/m^3]) as function of upstream Mach number (M1 []), and upstream density (RO1 [kg/m^3]) input: upstream Mach number (M1 []), upstream density (RO1 [kg/m^3], default value: 1.0) example: RO2 = get_downstream_density(M1=M1, RO1=RO1)

get_downstream_pressure(*args, **kwargs)

calculate pressure downstream of normal shock (P2 [Pa]) as function of upstream Mach number (M1 []), and upstream pressure (P1 [Pa]) input: upstream Mach number (M1 []), upstream pressure (P1 [Pa], default value: 1.0) example: P2 = get_downstream_pressure(M1=M1, P1=P1)

get_downstream_temperature(*args, **kwargs)

calculate temperature downstream of normal shock (T2 [K]) as function of upstream Mach number (M1 []), and upstream temperature (T1 [K]) input: upstream Mach number (M1 []), upstream temperature (T1 [K], default value: 1.0) example: T2 = get_downstream_pressure(M1=M1, T1=T1)

get_downstream_total_pressure(*args, **kwargs)

calculate total pressure downstream of normal shock (Po2 [Pa]) as function of upstream Mach number (M1 []), and upstream total pressure (Po1 [Pa]) input: upstream Mach number (M1 []), upstream total pressure (Po1 [Pa], default value: 1.0) example: Po2 = get_downstream_total_pressure(M1=M1, Po1=Po1)

get_entropy_increase(*args, **kwargs)

calculate normal shock entropy increase from upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: dS = get_entropy_increase(M1=M1)

get_upstream_Astar(*args, **kwargs)

calculate choke cross-section area upstream of normal shock (As1 [m^2]) as function of downstream Mach number (M2 []),and downstream choke cross-section area (As2 [m^2]) input: downstream Mach number (M2 []), downstream choke cross-section area (As2 [m^2], default value: 1.0) example: As1 = get_upstream_Astar(M2=M2, As2=As2)

get_upstream_Mach(*args, **kwargs)

calculate Mach number upstream of normal shock (M1 []) as function of downstream Mach number (M2 []) input: downstream Mach number (M2 []) example: M1 = get_upstream_Mach(M2=M2s)

get_upstream_Mach_from_density_ratio(*args, ...)

calculate upstream Mach number (M1 []) from normal shock density ratio (RR []) input: density ratio (RR []) example: M1 = get_upstream_Mach_from_density_ratio(RR=RR)

get_upstream_Mach_from_pressure_ratio(*args, ...)

calculate upstream Mach number (M1 []) from normal shock pressure ratio (PR []) input: pressure ratio (PR []) example: M1 = get_upstream_Mach_from_pressure_ratio(PR=PR)

get_upstream_Mach_from_temperature_ratio(...)

calculate upstream Mach number (M1 []) from normal shock temperature ratio (TR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (TR []) example: M1 = get_upstream_Mach_from_temperature_ratio(TR=TR)

get_upstream_Mach_from_total_pressure_ratio(...)

calculate upstream Mach number (M1 []) from normal shock total pressure ratio (PoR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (PoR []) example: M1 = get_upstream_Mach_from_total_pressure_ratio(PoR=PoR)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_downstream_Astar(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate choke cross-section area downstream of normal shock (As2 [m^2]) as function of upstream Mach number (M1 []),and upstream choke cross-section area (As1 [m^2]) input: upstream Mach number (M1 []), upstream choke cross-section area (As1 [m^2], default value: 1.0) example: As2 = get_downstream_Astar(M1=M1, As1=As1)

get_downstream_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number downstream of normal shock (M2 []) as function of upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: M2 = get_downstream_Mach(M1=M1)

get_downstream_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate density downstream of normal shock (RO2 [kg/m^3]) as function of upstream Mach number (M1 []), and upstream density (RO1 [kg/m^3]) input: upstream Mach number (M1 []), upstream density (RO1 [kg/m^3], default value: 1.0) example: RO2 = get_downstream_density(M1=M1, RO1=RO1)

get_downstream_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate pressure downstream of normal shock (P2 [Pa]) as function of upstream Mach number (M1 []), and upstream pressure (P1 [Pa]) input: upstream Mach number (M1 []), upstream pressure (P1 [Pa], default value: 1.0) example: P2 = get_downstream_pressure(M1=M1, P1=P1)

get_downstream_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate temperature downstream of normal shock (T2 [K]) as function of upstream Mach number (M1 []), and upstream temperature (T1 [K]) input: upstream Mach number (M1 []), upstream temperature (T1 [K], default value: 1.0) example: T2 = get_downstream_pressure(M1=M1, T1=T1)

get_downstream_total_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate total pressure downstream of normal shock (Po2 [Pa]) as function of upstream Mach number (M1 []), and upstream total pressure (Po1 [Pa]) input: upstream Mach number (M1 []), upstream total pressure (Po1 [Pa], default value: 1.0) example: Po2 = get_downstream_total_pressure(M1=M1, Po1=Po1)

get_entropy_increase(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate normal shock entropy increase from upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: dS = get_entropy_increase(M1=M1)

get_upstream_Astar(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate choke cross-section area upstream of normal shock (As1 [m^2]) as function of downstream Mach number (M2 []),and downstream choke cross-section area (As2 [m^2]) input: downstream Mach number (M2 []), downstream choke cross-section area (As2 [m^2], default value: 1.0) example: As1 = get_upstream_Astar(M2=M2, As2=As2)

get_upstream_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number upstream of normal shock (M1 []) as function of downstream Mach number (M2 []) input: downstream Mach number (M2 []) example: M1 = get_upstream_Mach(M2=M2s)

get_upstream_Mach_from_density_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock density ratio (RR []) input: density ratio (RR []) example: M1 = get_upstream_Mach_from_density_ratio(RR=RR)

get_upstream_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock pressure ratio (PR []) input: pressure ratio (PR []) example: M1 = get_upstream_Mach_from_pressure_ratio(PR=PR)

get_upstream_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock temperature ratio (TR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (TR []) example: M1 = get_upstream_Mach_from_temperature_ratio(TR=TR)

get_upstream_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock total pressure ratio (PoR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (PoR []) example: M1 = get_upstream_Mach_from_total_pressure_ratio(PoR=PoR)

g3d.calc.calculators.nozzle module

Quasi-one-dimensional flow calculator (nozzles and diffusers)

class g3d.calc.calculators.nozzle.G3DNozzleCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

class collecting functions related to nozzle flows (Q1D one-dimensional flows with smooth cross-section area changes)

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

area_ratio(*args, **kwargs)

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_area_ratio(*args, **kwargs)

find_Mach_internal_shock(*args, **kwargs)

get_Mach_from_area_ratio(*args, **kwargs)

calculates Mach number (M []) corresponding to the specified area ratio (AR []) the Mach number is calculated using the built-in Newton-Raphson solver the flow is assumed to be subsonic unless mode='supersonic' is specified input: area ratio (AR []) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_area_ratio(AR=AR)

get_Mach_internal_shock(*args, **kwargs)

calculate Mach number (M1 []) just upstream of shock for choked nozzle flow with internal shock calculations are made using the built-in Newton-Raphson solver input: inlet total pressure (Po [Pa], total pressure upstream of shock), throat area (At [m^2]), exit area (Ae [m^2]), nozzle exit pressure (Pe [Pa]) example: M1 = get_Mach_internal_shock(Po=Po, At=At, Ae=Ae, Pe=Pe)

get_area_ratio(*args, **kwargs)

calculates area ratio (AR []) for specified Mach number (M []) using the area-Mach-number relation input: Mach number (M []) example: AR = get_area_ratio(M=M)

get_choked_area(*args, **kwargs)

calculates choked cross-section area (At [m^2]) for specified choked massflow (mp [kg/s]), total pressure (Po [Pa]), and total temperature (To [K]) input: massflow (mp [kg/s]), total pressure (Po [Pa]), total temperature (To [K]) example: As = get_choked_area(mp=mp, Po=Po, To=To)

get_choked_mass_flow(*args, **kwargs)

calculates choked massflow (mp [kg/s]) for specified upstream total pressure (Po [Pa]), total temperature (To [K]), and throat area (At [m^2]) input: total pressure (Po [Pa]), total temperature (To [K]), throat area (At [m^2]) example: me = get_choked_mass_flow(Po=Po, To=To, At=At)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

internal_shock_get_exit_Mach_number(*args, ...)

calculates exit Mach number (Me []) for nozzle flow with internal shock input: total pressure upstream of shock (Po [Pa], same as nozzle inlet total pressure), static pressure downstream of nozzle exit (Pb [Pa]), nozzle exit-to-throat area ratio (AR=Ae/At []) example: Me = internal_shock_get_exit_Mach_number(Po=Po, Pb=Pb, AR=AR)

internal_shock_get_exit_conditions(*args, ...)

calculates exit Mach number and pressure (Me [], Pe [Pa]) for nozzle flow with internal shock some values are calculated using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Me, Pe = internal_shock_get_exit_conditions(M1=M1, Po=Po, At=At, Ae=Ae)

internal_shock_get_exit_pressure(*args, **kwargs)

calculates exit pressure (Pe [Pa]) for nozzle flow with internal shock calculations are done using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Pe = internal_shock_get_exit_pressure(M1=M1, Po=Po, At=At, Ae=Ae)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

moc(Me[, n, t0])

simple Methods-Of-Characteristics (MOC) deign of 2D planar divergent nozzle shape input: exit Mach number (design condition/supercritical flow) (Me []), number of characteristic lines (n, default value: 10), start angle (t0 [rad], default value: 0.01) example: Km, Kp, t, v, M, mu, x, y = moc(Me=Me, n=n, t0=t0)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_area_ratio()

find_Mach_from_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_area_ratio()

find_Mach_internal_shock(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_internal_shock()

get_Mach_from_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates Mach number (M []) corresponding to the specified area ratio (AR []) the Mach number is calculated using the built-in Newton-Raphson solver the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: area ratio (AR []) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_area_ratio(AR=AR)

get_Mach_internal_shock(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number (M1 []) just upstream of shock for choked nozzle flow with internal shock calculations are made using the built-in Newton-Raphson solver input: inlet total pressure (Po [Pa], total pressure upstream of shock), throat area (At [m^2]), exit area (Ae [m^2]), nozzle exit pressure (Pe [Pa]) example: M1 = get_Mach_internal_shock(Po=Po, At=At, Ae=Ae, Pe=Pe)

get_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates area ratio (AR []) for specified Mach number (M []) using the area-Mach-number relation input: Mach number (M []) example: AR = get_area_ratio(M=M)

get_choked_area(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked cross-section area (At [m^2]) for specified choked massflow (mp [kg/s]), total pressure (Po [Pa]), and total temperature (To [K]) input: massflow (mp [kg/s]), total pressure (Po [Pa]), total temperature (To [K]) example: As = get_choked_area(mp=mp, Po=Po, To=To)

get_choked_mass_flow(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked massflow (mp [kg/s]) for specified upstream total pressure (Po [Pa]), total temperature (To [K]), and throat area (At [m^2]) input: total pressure (Po [Pa]), total temperature (To [K]), throat area (At [m^2]) example: me = get_choked_mass_flow(Po=Po, To=To, At=At)

internal_shock_get_exit_Mach_number(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates exit Mach number (Me []) for nozzle flow with internal shock input: total pressure upstream of shock (Po [Pa], same as nozzle inlet total pressure), static pressure downstream of nozzle exit (Pb [Pa]), nozzle exit-to-throat area ratio (AR=Ae/At []) example: Me = internal_shock_get_exit_Mach_number(Po=Po, Pb=Pb, AR=AR)

internal_shock_get_exit_conditions(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates exit Mach number and pressure (Me [], Pe [Pa]) for nozzle flow with internal shock some values are calculated using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Me, Pe = internal_shock_get_exit_conditions(M1=M1, Po=Po, At=At, Ae=Ae)

internal_shock_get_exit_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates exit pressure (Pe [Pa]) for nozzle flow with internal shock calculations are done using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Pe = internal_shock_get_exit_pressure(M1=M1, Po=Po, At=At, Ae=Ae)

moc(Me: float, n: int = 10, t0: float = 0.01) → Tuple[ndarray, ...][source]

simple Methods-Of-Characteristics (MOC) deign of 2D planar divergent nozzle shape input: exit Mach number (design condition/supercritical flow) (Me []), number of characteristic lines (n, default value: 10), start angle (t0 [rad], default value: 0.01) example: Km, Kp, t, v, M, mu, x, y = moc(Me=Me, n=n, t0=t0)

g3d.calc.calculators.oblique_shock module

Oblique-shock calculator

class g3d.calc.calculators.oblique_shock.G3DObliqueShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to oblique shocks

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

analyze_oblique_shock(*args, **kwargs)

calculates shock angle (beta [rad*]), downstream flow Mach number (M2 []), shock pressure ratio (PR21 []), and shock temperature ratio (TR21 []) corresponding to the specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated flow deflection angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: beta, M2, PR21, TR21 = analyze_oblique_shock(M1=M1, theta=theta)

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_M1_from_theta_and_M2(*args, **kwargs)

find_Mach_min(*args, **kwargs)

find_beta(*args, **kwargs)

get_M1_from_theta_and_M2(*args, **kwargs)

calculates flow Mach number upstream of oblique shock (M1 []) from specified downstream flow Mach number (M2 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: downstream flow Mach number (M2 []), flow deflection angle (theta [rad*]) example: M2 = get_M1_from_theta_and_M2(M2=M2, theta=theta)

get_Mach(*args, **kwargs)

calculate upstream Mach number (M []) corresponding to specified shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]), shock angle (beta [rad*]) example: M = get_Mach(theta=theta, beta=beta)

get_Mach_angle(*args, **kwargs)

calculates Mach angle (mu [rad*]) corresponding to specified flow Mach number (M []) * the mach angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: Mach number (M []) example: mu = get_Mach_angle(M=M)

get_Mach_min(*args, **kwargs)

calculates the minimum flow Mach number (M []) for a specified flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]) example: M = get_Mach_min(theta=theta)

get_angles_from_PR_and_M1(*args, **kwargs)

calculates shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) corresponding to specified pressure ratio (PR []) and upstream flow Mach number (M1 []) * shock angle and flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: pressure ratio (PR []), upstream flow Mach number (M1 []) example: beta, theta = get_angles_from_PR_and_M1(PR=PR, M1=M1)

get_beta(*args, **kwargs)

calculates shock angle (beta [rad*]) for specified flow Mach number (M []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated shock angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the shock angle is obtained using the built-in Newton-Raphson solver input: flow Mach number (M []), flow deflection angle (theta [rad*]) example: beta = get_beta(M=M, theta=theta)

get_density_ratio(*args, **kwargs)

calculates density ratio (ROR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: ROR = get_density_ratio(M1=M1, beta=beta)

get_downstream_Mach(*args, **kwargs)

calculates downstream flow Mach number (M2 []) from upstream flow Mach number (M1 []), shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream flow Mach number (M1 []), shock angle (beta [rad*]), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach(M1=M1, beta=beta, theta=theta)

get_downstream_Mach_from_theta_and_M1(*args, ...)

calculates flow Mach number downstream of oblique shock (M2 []) from specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach_from_theta_and_M1(M1=M1, theta=theta)

get_normal_Mach_1(*args, **kwargs)

calculates the upstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn1 []) using the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: Mn1 = get_normal_Mach_1(M1=M1, beta=beta)

get_normal_Mach_2(*args, **kwargs)

calculates the downstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn2 []) using the upstream shock-normal Mach number (Mn1 []) input: upstream shock-normal Mach number (Mn1 []) example: Mn2 = get_normal_Mach_2(Mn1=Mn1)

get_pressure_ratio(*args, **kwargs)

calculates pressure ratio (PR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: PR = get_pressure_ratio(M1=M1, beta=beta)

get_temperature_ratio(*args, **kwargs)

calculates temperature ratio (TR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: TR = get_pressure_ratio(M1=M1, beta=beta)

get_theta(*args, **kwargs)

calculates flow deflection angle (theta [rad*]) from flow Mach number (M []) and shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated deflection angle in degrees as well) input: flow Mach number (M []), shock angle (beta [rad*]) example: theta = get_theta(M=M, beta=beta)

get_theta_beta_Mach_array(M1[, N])

extracts shock angle vector and flow deflection angle vector for specified upstream flow Mach number (M1 []) input: upstream flow Mach number (M1 []), vector length (N, default value: 100) example: theta, beta = get_theta_beta_Mach_array(M1, N)

get_theta_max(*args, **kwargs)

calculates maximum flow deflection angle (theta_max [rad*]) for a specified flow Mach number (M []) * the calculated flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: flow Mach number (M []) example: theta_max = get_theta_max(M=M)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

analyze_oblique_shock(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]), downstream flow Mach number (M2 []), shock pressure ratio (PR21 []), and shock temperature ratio (TR21 []) corresponding to the specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated flow deflection angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: beta, M2, PR21, TR21 = analyze_oblique_shock(M1=M1, theta=theta)

find_M1_from_theta_and_M2(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_M1_from_theta_and_M2()

find_Mach_min(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_min()

find_beta(*args, **kwargs)[source]

Deprecated since version 2.6: redirects to get_beta()

get_M1_from_theta_and_M2(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates flow Mach number upstream of oblique shock (M1 []) from specified downstream flow Mach number (M2 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: downstream flow Mach number (M2 []), flow deflection angle (theta [rad*]) example: M2 = get_M1_from_theta_and_M2(M2=M2, theta=theta)

get_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M []) corresponding to specified shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]), shock angle (beta [rad*]) example: M = get_Mach(theta=theta, beta=beta)

get_Mach_angle(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates Mach angle (mu [rad*]) corresponding to specified flow Mach number (M []) * the mach angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: Mach number (M []) example: mu = get_Mach_angle(M=M)

get_Mach_min(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates the minimum flow Mach number (M []) for a specified flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]) example: M = get_Mach_min(theta=theta)

get_angles_from_PR_and_M1(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) corresponding to specified pressure ratio (PR []) and upstream flow Mach number (M1 []) * shock angle and flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: pressure ratio (PR []), upstream flow Mach number (M1 []) example: beta, theta = get_angles_from_PR_and_M1(PR=PR, M1=M1)

get_beta(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]) for specified flow Mach number (M []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated shock angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the shock angle is obtained using the built-in Newton-Raphson solver input: flow Mach number (M []), flow deflection angle (theta [rad*]) example: beta = get_beta(M=M, theta=theta)

get_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density ratio (ROR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: ROR = get_density_ratio(M1=M1, beta=beta)

get_downstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates downstream flow Mach number (M2 []) from upstream flow Mach number (M1 []), shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream flow Mach number (M1 []), shock angle (beta [rad*]), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach(M1=M1, beta=beta, theta=theta)

get_downstream_Mach_from_theta_and_M1(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates flow Mach number downstream of oblique shock (M2 []) from specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach_from_theta_and_M1(M1=M1, theta=theta)

get_normal_Mach_1(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates the upstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn1 []) using the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: Mn1 = get_normal_Mach_1(M1=M1, beta=beta)

get_normal_Mach_2(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates the downstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn2 []) using the upstream shock-normal Mach number (Mn1 []) input: upstream shock-normal Mach number (Mn1 []) example: Mn2 = get_normal_Mach_2(Mn1=Mn1)

get_pressure_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio (PR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: PR = get_pressure_ratio(M1=M1, beta=beta)

get_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature ratio (TR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: TR = get_pressure_ratio(M1=M1, beta=beta)

get_theta(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates flow deflection angle (theta [rad*]) from flow Mach number (M []) and shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated deflection angle in degrees as well) input: flow Mach number (M []), shock angle (beta [rad*]) example: theta = get_theta(M=M, beta=beta)

get_theta_beta_Mach_array(M1: float, N: int = 100) → Tuple[ndarray, ...][source]

extracts shock angle vector and flow deflection angle vector for specified upstream flow Mach number (M1 []) input: upstream flow Mach number (M1 []), vector length (N, default value: 100) example: theta, beta = get_theta_beta_Mach_array(M1, N)

get_theta_max(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates maximum flow deflection angle (theta_max [rad*]) for a specified flow Mach number (M []) * the calculated flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: flow Mach number (M []) example: theta_max = get_theta_max(M=M)

g3d.calc.calculators.q1d_ode module

ODE-based q1d calculator : area changes, friction and heat addition

class g3d.calc.calculators.q1d_ode.Q1DODESolver(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

quasi-one-dimensional ODE solver handles cross-section area changes, heat addition, and friction

Attributes:
L

Pipe length (L [m])

dksi

Axial spacing between function evaluations

f_fun

Friction factor as a function of axial coordinate f(x) []

gas

Gas object

h

Axial spacing used for numerical differentiation (h [m], default value: 1.e-4)

newton

Newton-Raphson solver

p1

Initial pressure (p1 [Pa])

q_fun

Added heat as a function of axial coordinate q(x) [J/kg]

r

Cross-section radius (r [m], used unless function r_func is specified)

r_fun

Cross-section radius as a function of axial coordinate r(x) [m]

rho1

Initial density (rho1 [kg/m^3])

tag

tag (string) used for identification

u1

Initial velocity (u1 [m/s])

x1

Start coordinate (x1 [m], default value: 0.)

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset(*args, **kwargs)

Resets solver parameters to their default values

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Set parameters from provided key => value input

solve(*args, **kwargs)

Q1D ODE solver for investigations of combined affects of area changes, heat addition, and friction input: functions describing area distribution (r_fun - r(x) [m]), heat addition (q(x) [J/kg]), and friction factor (f_fun - f(x) [], default value: None), initial conditions: axial position (x1 [m], default value: 0.), density (rho1 [kg/m^3], default value: 1.), velocity (u1 [m/s], default value: 0.), pressure (p1 [Pa], default value: 1.e5), axial increment per step (dksi [m], default value: 0.), pipe length (L [m], default value: 1.e20), delta (h [m], default value: 1.e-4) example: x, rho, u, p, T, M, A = solve(r_fun=r_fun, q_fun=q_fun, f_fun=f_fun, x1=x1, rho1=rho1, u1=u1, p1=p1, dksi=dksi, L=L, h=h)

property L: float

Pipe length (L [m])

property dksi: float

Axial spacing between function evaluations

property f_fun: Callable[[float], float]

Friction factor as a function of axial coordinate f(x) []

property h: float

1.e-4)

Type:

Axial spacing used for numerical differentiation (h [m], default value

property p1: float

Initial pressure (p1 [Pa])

property q_fun: Callable[[float], float]

Added heat as a function of axial coordinate q(x) [J/kg]

property r: float

Cross-section radius (r [m], used unless function r_func is specified)

property r_fun: Callable[[float], float]

Cross-section radius as a function of axial coordinate r(x) [m]

reset(*args: Any, **kwargs: Any) → None[source]

Resets solver parameters to their default values

property rho1: float

Initial density (rho1 [kg/m^3])

set_from_key_value(key: str, value: Any) → bool[source]

Set parameters from provided key => value input

solve(*args: Any, **kwargs: Any) → Tuple[ndarray, ...][source]

Q1D ODE solver for investigations of combined affects of area changes, heat addition, and friction input: functions describing area distribution (r_fun - r(x) [m]), heat addition (q(x) [J/kg]), and friction factor (f_fun - f(x) [], default value: None), initial conditions: axial position (x1 [m], default value: 0.), density (rho1 [kg/m^3], default value: 1.), velocity (u1 [m/s], default value: 0.), pressure (p1 [Pa], default value: 1.e5), axial increment per step (dksi [m], default value: 0.), pipe length (L [m], default value: 1.e20), delta (h [m], default value: 1.e-4) example: x, rho, u, p, T, M, A = solve(r_fun=r_fun, q_fun=q_fun, f_fun=f_fun, x1=x1, rho1=rho1, u1=u1, p1=p1, dksi=dksi, L=L, h=h)

property u1: float

Initial velocity (u1 [m/s])

property x1: float

0.)

Type:

Start coordinate (x1 [m], default value

g3d.calc.calculators.shock_tube module

Shock-tube relations calculator

class g3d.calc.calculators.shock_tube.G3DShockTubeCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to shock-tube problems

Attributes:
gas

Gas object

gas1

Driver gas (high-pressure chamber)

gas2

Driven gas (low-pressure chamber)

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_PR21_from_PR41(*args, **kwargs)

get_PR21_from_PR41(*args, **kwargs)

finds incident shock pressure ratio (PR21 []) matching specified shock-tube pressure ratio (PR41 [], driver section pressure over driven section pressure), driver section temperature (T4 [K]), and driven section temperature (T1 [K]).

get_PR41(*args, **kwargs)

calculates driver/driven gas pressure ratio (PR41 [], shock tube initial condition) from incident shock pressure ratio (PR21 []), driven section temperature (T1 [k]), and driver section temperature (T4 [K]) input: incident shock wave pressure ratio (PR21 [K]), driven section temperature (T1 [K]), driver section temperature (T4 [K]) example: PR41 = get_PR41(PR21=PR21, T1=T1, T4=T4)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_PR21_from_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_PR41()

property gas1: Gas

Driver gas (high-pressure chamber)

property gas2: Gas

Driven gas (low-pressure chamber)

get_PR21_from_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

finds incident shock pressure ratio (PR21 []) matching specified shock-tube pressure ratio (PR41 [], driver section pressure over driven section pressure), driver section temperature (T4 [K]), and driven section temperature (T1 [K]). the pressure ration is calculated using the built-in Newton-Raphson solver. input: driver pressure of driven pressure (PR41 []), driver section temperature (T4 [K]), driven section temperature (T1 [K]) example: PR21 = get_PR21_from_PR41(PR41=PR41, T4=T4, T1=T1)

get_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates driver/driven gas pressure ratio (PR41 [], shock tube initial condition) from incident shock pressure ratio (PR21 []), driven section temperature (T1 [k]), and driver section temperature (T4 [K]) input: incident shock wave pressure ratio (PR21 [K]), driven section temperature (T1 [K]), driver section temperature (T4 [K]) example: PR41 = get_PR41(PR21=PR21, T1=T1, T4=T4)

g3d.calc.calculators.stagnation module

Total and critical (sonic) flow conditions calculator

class g3d.calc.calculators.stagnation.G3DStagnationCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DGenericCalculator

class collecting functions related to reference states stagnation parameters and critical (sonic) parameters

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_Mach_from_total_density_ratio(*args, ...)

calculates Mach number (M []) from total-to-static density ratio (ROo / RO []) input: total density (ROo [kg/m^3]) and static density (RO [kg/m^3]) example: M = get_Mach_from_total_density_ratio(ROo=ROo, RO=RO)

get_Mach_from_total_pressure_ratio(*args, ...)

calculates Mach number (M []) from total-to-static pressure ratio (Po / P []) input: total pressure (Po [Pa]) and static pressure (P [Pa]) example: M = get_Mach_from_total_pressure_ratio(Po=Po, P=P)

get_Mach_from_total_temperature_ratio(*args, ...)

calculates Mach number (M []) from total-to-static temperature ratio (To / T []) input: total temperature (To [K]) and static temperature (T [K]) example: M = get_Mach_from_total_temperature_ratio(To=To, T=T)

get_critical_density(*args, **kwargs)

calculates critical density (ROs [kg/m^3]) from total density (ROo [kg/m^3]) input: total density (ROo [kg/m^3], default value: 1.0) example: ROs = get_critical_density(ROo=ROo)

get_critical_pressure(*args, **kwargs)

calculates critical pressure (Ps [Pa]) from total pressure (Po [Pa]) input: total pressure (Po [Pa], default value: 1.0) example: Ps = get_critical_pressure(Po=Po)

get_critical_temperature(*args, **kwargs)

calculates critical temperature (Ts [K]) from total temperature (To [K]) input: total temperature (To [K], default value: 1.0) example: Ts = get_critical_temperature(To=To)

get_static_density(*args, **kwargs)

calculates static density (RO [kg/m^3]) from Mach number (M []) and total density (ROo [kg/m^3]) input: Mach number (M []), total density (ROo [kg/m^3]) example: RO = get_static_density(M=M, ROo=ROo)

get_static_pressure(*args, **kwargs)

calculates static pressure (P [Pa]) from Mach number (M []) and total pressure (Po [Pa]) input: Mach number (M []), total pressure (Po [Pa]) example: P = get_static_pressure(M=M, Po=Po)

get_static_temperature(*args, **kwargs)

calculates static temperature (T [K]) from Mach number (M []) and total temperature (To [K]) input: Mach number (M []), total temperature (To [K]) example: T = get_static_temperature(M=M, To=To)

get_total_density(*args, **kwargs)

calculates total density (ROo [kg/m^3]) from Mach number (M []) and static density (RO [kg/m^3]) input: Mach number (M []), static density (RO [kg/m^3]) example: ROo = get_total_density(M=M, RO=RO)

get_total_pressure(*args, **kwargs)

calculates total pressure (Po [Pa]) from Mach number (M []) and static pressure (P [Pa]) input: Mach number (M []), static pressure (P [Pa]) example: Po = get_total_pressure(M=M, P=P)

get_total_temperature(*args, **kwargs)

calculates total temperature (To [K]) from Mach number (M []) and static temperature (T [K]) input: Mach number (M []), static temperature (T [K]) example: To = get_total_temperature(M=M, T=T)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_Mach_from_total_density_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static density ratio (ROo / RO []) input: total density (ROo [kg/m^3]) and static density (RO [kg/m^3]) example: M = get_Mach_from_total_density_ratio(ROo=ROo, RO=RO)

get_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static pressure ratio (Po / P []) input: total pressure (Po [Pa]) and static pressure (P [Pa]) example: M = get_Mach_from_total_pressure_ratio(Po=Po, P=P)

get_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static temperature ratio (To / T []) input: total temperature (To [K]) and static temperature (T [K]) example: M = get_Mach_from_total_temperature_ratio(To=To, T=T)

get_critical_density(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical density (ROs [kg/m^3]) from total density (ROo [kg/m^3]) input: total density (ROo [kg/m^3], default value: 1.0) example: ROs = get_critical_density(ROo=ROo)

get_critical_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical pressure (Ps [Pa]) from total pressure (Po [Pa]) input: total pressure (Po [Pa], default value: 1.0) example: Ps = get_critical_pressure(Po=Po)

get_critical_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical temperature (Ts [K]) from total temperature (To [K]) input: total temperature (To [K], default value: 1.0) example: Ts = get_critical_temperature(To=To)

get_static_density(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static density (RO [kg/m^3]) from Mach number (M []) and total density (ROo [kg/m^3]) input: Mach number (M []), total density (ROo [kg/m^3]) example: RO = get_static_density(M=M, ROo=ROo)

get_static_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static pressure (P [Pa]) from Mach number (M []) and total pressure (Po [Pa]) input: Mach number (M []), total pressure (Po [Pa]) example: P = get_static_pressure(M=M, Po=Po)

get_static_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static temperature (T [K]) from Mach number (M []) and total temperature (To [K]) input: Mach number (M []), total temperature (To [K]) example: T = get_static_temperature(M=M, To=To)

get_total_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total density (ROo [kg/m^3]) from Mach number (M []) and static density (RO [kg/m^3]) input: Mach number (M []), static density (RO [kg/m^3]) example: ROo = get_total_density(M=M, RO=RO)

get_total_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total pressure (Po [Pa]) from Mach number (M []) and static pressure (P [Pa]) input: Mach number (M []), static pressure (P [Pa]) example: Po = get_total_pressure(M=M, P=P)

get_total_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total temperature (To [K]) from Mach number (M []) and static temperature (T [K]) input: Mach number (M []), static temperature (T [K]) example: To = get_total_temperature(M=M, T=T)

Module contents

g3d/calc/calculators sub library

class g3d.calc.calculators.G3DAcousticsCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to acoustic evaluations

Attributes:
gas

Gas object

newton

Newton-Raphson solver

pref

Reference pressure [Pa] (default value: 2.e-5 Pa)

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_SPL_from_dp(*args, **kwargs)

Calculates sound pressure level (SPL [dB]) from pressure fluctuation (dP [Pa], RMS)

get_dB_from_dp(*args, **kwargs)

get_dp_from_SPL(*args, **kwargs)

Calculates pressure fluctuation (dP [Pa], RMS) from sound pressure level (SPL [dB])

get_dp_from_dB(*args, **kwargs)

get_dro(*args, **kwargs)

Calculates sound wave induced density fluctuation (dRO [kg/m^3]) input: far-field speed of sound (Cinf [m/s]) and RMS pressure fluctuation (dP [Pa]) example: dRO = get_dro(Cinf=Cinf, dP=dP)

get_du(*args, **kwargs)

Calculates sound wave induced flow velocity (dU [m/s])

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_SPL_from_dp(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound pressure level (SPL [dB]) from pressure fluctuation (dP [Pa], RMS)

input: pressure fluctuation (dP [Pa], RMS)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    pressure fluctuation RMS [Pa] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘dP’

Returns:

sound pressure level [dB]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> SPL = cflow.acoustics.get_SPL_from_dp(dP=10.)

get_dB_from_dp(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_SPL_from_dp()

get_dp_from_SPL(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates pressure fluctuation (dP [Pa], RMS) from sound pressure level (SPL [dB])

input: sound pressure level (SPL [dB])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    sound pressure level [dB] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘SPL’

Returns:

pressure fluctuation (RMS dP) [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dP = cflow.acoustics.get_dp_from_SPL(SPL=70.)

get_dp_from_dB(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_dp_from_SPL()

get_dro(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound wave induced density fluctuation (dRO [kg/m^3]) input: far-field speed of sound (Cinf [m/s]) and RMS pressure fluctuation (dP [Pa]) example: dRO = get_dro(Cinf=Cinf, dP=dP)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. far-field speed of sound [m/s]

    2. pressure fluctuation [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘Cinf’, ‘dP’

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dRO = cflow.acoustics.get_dro(Cinf=340., dP=10.)

get_du(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates sound wave induced flow velocity (dU [m/s])

input: far-field speed of sound (Cinf [m/s]), far-field density (ROinf [kg/m^3]), and RMS pressure fluctuation (dP [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. far-field speed of sound [m/s]

    2. far field density [kg/m^3]

    3. pressure fluctuation [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘Cinf’, ‘ROinf’, ‘dP’

Returns:

induced velocity (u) [m/s]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> dU = cflow.acoustics.get_du(Cinf=340., ROinf=1.2, dP=10.)

property pref: float

2.e-5 Pa)

Type:

Reference pressure [Pa] (default value

class g3d.calc.calculators.G3DCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DGenericCalculator

Class definition of base class G3DCalculator

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

class g3d.calc.calculators.G3DChannelFlowCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to compressible channel flow

Attributes:
H

Channel height [m]

L

Channel length [m]

M

Mach number based on freestream velocity []

Re

Reynolds number based on freestream velocity []

Re_tau

Reynolds number based on friction velocity []

T

Temperature [K]

W

Channel width [m]

delta

Channel half height [m]

gas

Gas object

mu

Dynamic viscosity [kg/(m s)]

newton

Newton-Raphson solver

p

Pressure [Pa]

rho

Density [kg/s]

tag

tag (string) used for identification

tau_w

Wall-shear stress [N/m^2]

u

Velocity [m/s]

u_tau

Friction velocity [m/s]

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

print channel flow stats based on previously provided input

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

property H: float

Channel height [m]

Returns:

channel height

Return type:

float

property L: float

Channel length [m]

Returns:

channel length

Return type:

float

property M: float

Mach number based on freestream velocity []

Returns:

Mach number

Return type:

float

property Re: float

Reynolds number based on freestream velocity []

Returns:

Reynolds number

Return type:

float

property Re_tau: float

Reynolds number based on friction velocity []

Returns:

Reynolds number

Return type:

float

property T: float

Temperature [K]

Returns:

temperature

Return type:

float

property W: float

Channel width [m]

Returns:

channel width

Return type:

float

property delta: float

Channel half height [m]

Returns:

channel half height

Return type:

float

property mu: float

Dynamic viscosity [kg/(m s)]

Returns:

dynamic viscosity

Return type:

float

property p: float

Pressure [Pa]

Returns:

pressure

Return type:

float

print() → None[source]

print channel flow stats based on previously provided input

property rho: float

Density [kg/s]

Returns:

density

Return type:

float

property tau_w: float

Wall-shear stress [N/m^2]

Returns:

wall-shear stress

Return type:

float

property u: float

Velocity [m/s]

Returns:

velocity

Return type:

float

property u_tau: float

Friction velocity [m/s]

Returns:

friction velocity

Return type:

float

class g3d.calc.calculators.G3DExpansionWaveCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to Prandtl-Meyer expansions

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

analyze_expansion_region(*args, **kwargs)

Calculate pressure ratio (PR21 []), temperature ratio (TR21 []), and downstream Mach number (M2 []) for specified upstream Mach number (M1 []) and flow deflection (theta) flow deflection should be given in radians unless angle_type=AngleType.DEGREES is specified

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach(*args, **kwargs)

get_Mach(*args, **kwargs)

Finds Mach number corresponding to specified Prandtl-Meyer function value using the built-in Newton-Raphson solver the Prandtl-Meyer function value should be specified in radians unless angle_type=AngleType.DEGREES is specified

get_Prandtl_Meyer_function(*args, **kwargs)

Evaluates Prandtl-Meyer function for specified Mach number the value calculated is given in radians unless angle_type=AngleType.DEGREES is specified

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

analyze_expansion_region(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculate pressure ratio (PR21 []), temperature ratio (TR21 []), and downstream Mach number (M2 []) for specified upstream Mach number (M1 []) and flow deflection (theta) flow deflection should be given in radians unless angle_type=AngleType.DEGREES is specified

input: upstream Mach number (M1 []) and flow deflection (theta [rad or deg])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. flow deflection [rad or deg]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘theta’, ‘angle_type’

Returns:

flow expansion properties: downstream Mach number, pressure ratio, temperature ratio

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2, PR21, TR21 = cflow.expansion.analyze_expansion_region(M1=2.5, theta=10., angle_type=AngleType.DEGREES)

find_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach()

get_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds Mach number corresponding to specified Prandtl-Meyer function value using the built-in Newton-Raphson solver the Prandtl-Meyer function value should be specified in radians unless angle_type=AngleType.DEGREES is specified

input: Prandtl-Meyer value (theta [rad or deg])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    Prandtl-Meyer [rad or deg] value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘theta’, ‘angle_type’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.expansion.get_Mach(theta=10., angle_type=AngleType.DEGREES)

get_Prandtl_Meyer_function(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Evaluates Prandtl-Meyer function for specified Mach number the value calculated is given in radians unless angle_type=AngleType.DEGREES is specified

input: Mach number (M [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    Mach number value(s)

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘angle_type’

Returns:

Prandtl-Meyer function value (nu) [rad or deg]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> nu = cflow.expansion.get_Prandtl_Meyer_function(M=2.5, angle_type=AngleType.DEGREES)

class g3d.calc.calculators.G3DFrictionCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to one-dimensional flow with friction

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

choked_supersonic_find_shock_Mach(*args, ...)

choked_supersonic_get_shock_Mach(*args, **kwargs)

Finds Mach number (M []) upstream of shock in an over-choked (length longer than choked length) supersonic one-dimensional flow with friction.

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_L_star(*args, **kwargs)

find_Mach_from_pressure_ratio(*args, **kwargs)

find_Mach_from_temperature_ratio(*args, **kwargs)

find_Mach_from_total_pressure_ratio(*args, ...)

find_pipe_diameter_from_massflow(*args, **kwargs)

get_L_star(*args, **kwargs)

Calculates choke length (L* [m]) for specified Mach number

get_L_star_from_diameter_and_massflow(*args, ...)

Get choked length (Ls [m]) from pipe diameter (D [m]) and massflow (mp [kg/s])

get_Mach_from_L_star(*args, **kwargs)

Finds the Mach number (M []) matching the specified choked length (L* [m])

get_Mach_from_pressure_ratio(*args, **kwargs)

Finds the Mach number (M []) matching the specified pressure ratio (given by a local pressure (P [Pa]) and a choked pressure (Ps [Pa]))

get_Mach_from_temperature_ratio(*args, **kwargs)

Finds the Mach number (M []) matching the specified temperature ratio (given by a local temperature (T [K]) and a choked temperature (Ts [K]))

get_Mach_from_total_pressure_ratio(*args, ...)

Finds the Mach number (M []) matching the specified total pressure ratio

get_P(*args, **kwargs)

Calculates pressure (P [Pa]) for specified Mach number (M) and choke pressure (P* [Pa], P*=1.

get_P0(*args, **kwargs)

get_P0_star(*args, **kwargs)

get_PR_from_Mach(*args, **kwargs)

Get pressure ratio (PR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_P_star(*args, **kwargs)

Calculates choke pressure (P* [Pa]) for specified Mach number (M []) and pressure (P [Pa], P=1.

get_Po(*args, **kwargs)

Calculates total pressure (Po [Pa]) for specified Mach number (M []) and choked flow total pressure (Po* [Pa], Po*=1.

get_PoR_from_Mach(*args, **kwargs)

Get total pressure ratio (PoR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_Po_star(*args, **kwargs)

Calculates choke density (Po* [Pa]) for specified Mach number (M []) and total pressure (Po [Pa], Po=1.

get_RO(*args, **kwargs)

Calculates density (RO [kg/m^3]) for specified Mach number (M []) and choke density (RO* [kg/m^3], RO*=1.

get_RO_star(*args, **kwargs)

Calculates choke density (RO* [kg/m^3]) for specified Mach number (M []) and density (RO [kg/m^3], RO=1.

get_RR_from_Mach(*args, **kwargs)

Get density ratio (RR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_T(*args, **kwargs)

Calculates temperature (T [K]) for specified Mach number (M []) and choke temperature (T* [K], T*=1.

get_TR_from_Mach(*args, **kwargs)

Get temperature ratio (TR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

get_T_star(*args, **kwargs)

Calculates choke temperature (T* [K]) for specified Mach number (M) and temperature (T [K], T=1.

get_downstream_Mach(*args, **kwargs)

Two-station problem:

get_downstream_Mach_from_PR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and pressure ratio (PR [])

get_downstream_Mach_from_RR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and density ratio (RR [])

get_downstream_Mach_from_TR(*args, **kwargs)

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and temperature ratio (TR [])

get_downstream_flow_state(*args, **kwargs)

Two-station problem:

get_downstream_pressure(*args, **kwargs)

Two-station problem:

get_downstream_temperature(*args, **kwargs)

Two-station problem:

get_friction_factor(*args, **kwargs)

Calculates friction factor (4fL/D []) for specified Mach number

get_pipe_diameter_from_massflow(*args, **kwargs)

Finds pipe diameter (D [m]) from specified massflow (mp [kg/s]).

get_upstream_Mach(*args, **kwargs)

Two-station problem:

get_upstream_Mach_from_PR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and pressure ratio (PR [])

get_upstream_Mach_from_RR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and density ratio (RR [])

get_upstream_Mach_from_TR(*args, **kwargs)

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and temperature ratio (TR [])

get_upstream_flow_state(*args, **kwargs)

Two-station problem:

get_upstream_flow_state_after_overchoking(...)

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

get_upstream_flow_state_after_overchoking_2(...)

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

get_upstream_pressure(*args, **kwargs)

Two-station problem:

get_upstream_temperature(*args, **kwargs)

Two-station problem:

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

process_diagram_get_HS(M)

Extract HS-diagram data for one dimensional flow with friction

process_diagram_get_TS(T1, S1, M1, Ds, N)

Extract Ts-diagram data for one dimensional flow with friction

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

choked_supersonic_find_shock_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to choked_supersonic_get_shock_Mach()

choked_supersonic_get_shock_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds Mach number (M []) upstream of shock in an over-choked (length longer than choked length) supersonic one-dimensional flow with friction. The Mach number is estimated using the built-in Newton-Raphson solver.

input: inlet Mach number (M1 []), inlet temperature (T1 [K]), pipe length (L [m]), average Darcy friction factor (f []), and pipe diameter (D [m])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet Mach number

    2. inlet temperature [K]

    3. pipe length [m]

    4. average Darcy friction factor

    5. pipe diameter [m]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘f’, ‘D’

Returns:

shock Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.choked_supersonic_get_shock_Mach(M1=0.7, T1=300., f=0.005, D=0.1)

find_Mach_from_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_L_star()

find_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_pressure_ratio()

find_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_temperature_ratio()

find_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_total_pressure_ratio()

find_pipe_diameter_from_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_pipe_diameter_from_massflow()

get_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke length (L* [m]) for specified Mach number

input: Mach number (M []), average Darcy friction factor (f []), pipe diameter (D [m])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. average Darcy friction factor

    3. pipe diameter [m]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘f’, ‘D’

Returns:

choking length [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> L_star = cflow.friction.get_L_star(M=2.0, f=0.005, D=0.1)

get_L_star_from_diameter_and_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get choked length (Ls [m]) from pipe diameter (D [m]) and massflow (mp [kg/s])

input: pipe diameter (D [m]), massflow (mp [kg/s]), inlet pressure (P1 [Pa]), inlet temperature (T1 [K]), and average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. pipe diameter [m]

    2. massflow [kg/s]

    3. inlet pressure [Pa]

    4. inlet temperature [K]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘D’, ‘mp’, ‘P1’, ‘T1’, ‘f’

Returns:

choked length [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> L_star = cflow.friction.get_L_star_from_diameter_and_massflow(D=0.1, mp=4.75, P1=1.e5, T1=300., f=0.005)

get_Mach_from_L_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds the Mach number (M []) matching the specified choked length (L* [m])

The Mach number is estimated using the built-in Newton-Raphson solver

input: choke length (Ls [m]), average Darcy friction factor (f []), pipe diameter (D [m])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
*argsAny

arguments (optional input):

  1. choke length [m]

  2. average Darcy friction factor

  3. pipe diameter [m]

variable value(s) in above-listed order

**kwargsAny

keyword-value pairs (optional input):

valid keywords: ‘Ls’, ‘f’, ‘D’, ‘mode’

Returns:
float, ndarray

Mach number

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_L_star(Ls=10., f=0.005, D=0.1, mode=’subsonic’)

get_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds the Mach number (M []) matching the specified pressure ratio (given by a local pressure (P [Pa]) and a choked pressure (Ps [Pa]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local pressure (P [Pa]) and choked pressure (Ps [Pa])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. pressure [Pa]

    2. choked pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘P’, ‘Ps’, ‘mode’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_pressure_ratio(P=1.e5, Ps=1.6e5, mode=’subsonic’)

get_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Finds the Mach number (M []) matching the specified temperature ratio (given by a local temperature (T [K]) and a choked temperature (Ts [K]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local temperature (T [K]) and choked temperature (Ts [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. temperature [K]

    2. choked temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘T’, ‘Ts’

Returns:

Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_temperature_ratio(T=300., Ts=600.)

get_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]
Finds the Mach number (M []) matching the specified total pressure ratio

(given by a local total pressure (Po [Pa]) and a choked total pressure (Pos [Pa]))

The Mach number is estimated using the built-in Newton-Raphson solver

input: local total pressure (Po [Pa]) and choked total pressure (Pos [Pa])

optional input: mode ‘subsonic’ (default) or ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
*argsAny

arguments (optional input):

  1. total pressure [Pa]

  2. choked total pressure [Pa]

variable value(s) in above-listed order

**kwargsAny

keyword-value pairs (optional input):

valid keywords: ‘Po’, ‘Pos’, ‘mode’

Returns:
float, ndarray

Mach number

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M = cflow.friction.get_Mach_from_total_pressure_ratio(Po=1.e5, Pos=8.5e4, mode=’subsonic’)

get_P(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates pressure (P [Pa]) for specified Mach number (M) and choke pressure (P* [Pa], P*=1. if omitted)

input: Mach number (M []), choke pressure (P* [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Ps’

Returns:

flow pressure [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P = cflow.friction.get_P(M=2.0, Ps=1.e5)

get_P0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po()

get_P0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po_star()

get_PR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get pressure ratio (PR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

pressure ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> PR = cflow.friction.get_PR_from_Mach(M1=2.0, M2=1.5)

get_P_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke pressure (P* [Pa]) for specified Mach number (M []) and pressure (P [Pa], P=1. if omitted)

input: Mach number (M []), pressure (P [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘P’

Returns:

choked flow pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P_star = cflow.friction.get_P_star(M=2.0, P=1.e5)

get_Po(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates total pressure (Po [Pa]) for specified Mach number (M []) and choked flow total pressure (Po* [Pa], Po*=1. if omitted)

input: Mach number (M), choke total pressure (Po*) [Pa]

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked total pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Pos’

Returns:

total pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> Po = cflow.friction.get_Po(M=2.0, Pos=1.e5)

get_PoR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get total pressure ratio (PoR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

total pressure ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> PoR = cflow.friction.get_PoR_from_Mach(M1=2.0, M2=1.5)

get_Po_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke density (Po* [Pa]) for specified Mach number (M []) and total pressure (Po [Pa], Po=1. if omitted)

input: Mach number (M []), total pressure (Po [Pa])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. total pressure [Pa]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Po’

Returns:

choked flow total pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> Po_star = cflow.friction.get_Po_star(M=2.0, Po=1.e5)

get_RO(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates density (RO [kg/m^3]) for specified Mach number (M []) and choke density (RO* [kg/m^3], RO*=1. if omitted)

input: Mach number (M []), choke density (RO* [kg/m^3])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked density [kg/m^3]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘ROs’

Returns:

flow density [kg/m^3]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RO = cflow.friction.get_RO(M=2.0, ROs=1.2)

get_RO_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke density (RO* [kg/m^3]) for specified Mach number (M []) and density (RO [kg/m^3], RO=1. if omitted)

input: Mach number (M []), density (RO [kg/m^3])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. density [kg/m^3]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘RO’

Returns:

choked flow density [kg/m^3]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RO_star = cflow.friction.get_RO_star(M=2.0, RO=1.2)

get_RR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get density ratio (RR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

density ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> RR = cflow.friction.get_RR_from_Mach(M1=2.0, M2=1.5)

get_T(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates temperature (T [K]) for specified Mach number (M []) and choke temperature (T* [K], T*=1. if omitted)

input: Mach number (M []), choke temperature (T* [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. choked temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘Ts’

Returns:

flow temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T = cflow.friction.get_T(M=2.0, Ts=300.)

get_TR_from_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get temperature ratio (TR []) from upstream Mach number (M1 []) and downstream Mach number (M2 [])

input: upstream Mach number (M1 []) and downstream Mach number (M2 [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. downstream Mach number

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘M2’

Returns:

temperature ratio

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> TR = cflow.friction.get_TR_from_Mach(M1=2.0, M2=1.5)

get_T_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates choke temperature (T* [K]) for specified Mach number (M) and temperature (T [K], T=1. if omitted)

input: Mach number (M []), temperature (T [K])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. Mach number

    2. temperature [K]

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M’, ‘T’

Returns:

choked flow temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T_star = cflow.friction.get_T_star(M=2.0, T=300.)

get_downstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream Mach number (M2 []) based on upstream Mach number (M1 []) and pipe length (L [m])

input: upstream Mach number (M1 []), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. pipe length [m]

    3. pipe diameter [m]

    4. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach(M1=2.0, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_Mach_from_PR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and pressure ratio (PR [])

input: upstream Mach number (M1 []) and pressure ratio (PR []) example: M2 = get_downstream_Mach_from_PR(M1=M1, PR=PR)

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. pressure ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘PR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_PR(M1=2.0, PR=0.2)

get_downstream_Mach_from_RR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and density ratio (RR [])

input: upstream Mach number (M1 []) and density ratio (RR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. density ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘RR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_RR(M1=2.0, RR=0.25)

get_downstream_Mach_from_TR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get downstream Mach number (M2 []) from upstream Mach number (M1 []) and temperature ratio (TR [])

input: upstream Mach number (M1 []) and temperature ratio (TR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. temperature ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘TR’

Returns:

downstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2 = cflow.friction.get_downstream_Mach_from_TR(M1=2.0, TR=0.9)

get_downstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Two-station problem:

Calculates downstream flow state (Mach number (M2 []), temperature (T2 [K]), and pressure (P2 [Pa])) based on upstream flow state (Mach number (M1 []), temperature (T1 [K]), and pressure (P1 [Pa])), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static temperature [K]

    3. upstream static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘P1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream flowstate: Mach number, temperature [K], pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M2, T2, P2 = cflow.friction.get_downstream_flow_state(M1=2.0, T1=300., P1=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream pressure (P2 [Pa]) based on upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static pressure [Pa]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘P1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P2 = cflow.friction.get_downstream_pressure(M1=2.0, P1=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_downstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and pipe length (L [m])

input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. upstream Mach number

    2. upstream static temperature [K]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

downstream temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T2 = cflow.friction.get_downstream_temperature(M1=0.8, T1=300., L=10., D=0.1, f=0.005, mode=’subsonic’)

get_friction_factor(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Calculates friction factor (4fL/D []) for specified Mach number

input: Mach number (M [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) – arguments (optional input): Mach number value(s)

  • **kwargs (Any) – keyword-value pairs (optional input): valid keywords: ‘M’

Returns:

friction factor

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> ff = cflow.friction.get_friction_factor(M=2.0)

get_pipe_diameter_from_massflow(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Finds pipe diameter (D [m]) from specified massflow (mp [kg/s]). The pipe diameter is estimated using the built-in Newton-Raphson solver

input: inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), pipe length (L [m]), massflow (mp [kg/s]), and average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet temperature [K]

    2. inlet pressure [Pa]

    3. pipe length [m]

    4. massflow [kg/s]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘T1’, ‘P1’, ‘L’, ‘mp’, ‘f’

Returns:

diameter [m]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> D = cflow.friction.get_pipe_diameter_from_massflow(T1=300, P1=1.e5, L=2.0, mp=3.0, f=0.005)

get_upstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream Mach number (M1 []) based on downstream Mach number (M2 []) and pipe length (L [m])

input: downstream Mach number (M2 []), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. pipe length [m]

    3. pipe diameter [m]

    4. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach(M2=0.8, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_Mach_from_PR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and pressure ratio (PR [])

input: downstream Mach number (M2 []) and pressure ratio (PR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. pressure ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘PR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach_from_PR(M2=0.8, PR=0.2)

get_upstream_Mach_from_RR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and density ratio (RR [])

input: downstream Mach number (M2 []) and density ratio (RR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. density ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘RR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_downstream_Mach_from_RR(M2=0.8, RR=0.25)

get_upstream_Mach_from_TR(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Get upstream Mach number (M1 []) from downstream Mach number (M2 []) and temperature ratio (TR [])

input: downstream Mach number (M2 []) and temperature ratio (TR [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. temperature ratio

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘TR’

Returns:

upstream Mach number

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1 = cflow.friction.get_upstream_Mach_from_TR(M2=0.8, TR=0.9)

get_upstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Two-station problem:

Calculates upstream flow state (Mach number (M1 []), temperature (T1 [K]), and pressure (P1 [Pa])) based on downstream flow state (Mach number (M2 []), temperature (T2 [K]), and pressure (P2 [Pa])), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static temperature [K]

    3. downstream static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘T2’, ‘P2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream flowstate: Mach number, temperature [K], pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state(M2=0.8, T2=300., P2=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_flow_state_after_overchoking(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

The upstream flow state is calculated based on prescribed total conditions at the upstream flow station (To [K], Po [Pa]), exit static pressure (P2 [Pa]), pipe length (L [m])

input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet total temperature [K]

    2. inlet total pressure [Pa]

    3. exit static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘To’, ‘Po’, ‘P2’, ‘L’, ‘D’, ‘f’

Returns:

upstream flow state: Mach number, temperature and pressure

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state_after_overchoking(To=300., Po=1.e5, P2=7.5e4, L=3., D=0.1, f=0.005)

get_upstream_flow_state_after_overchoking_2(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

Calculates upstream flow state under overchoking conditions (L>L*, subsonic)

The upstream flow state is calculated based on prescribed total conditions at the upstream flow station (To [K], Po [Pa]), exit static pressure (P2 [Pa]), pipe length (L [m])

input: inlet mach number (M1 []), inlet static temperature (T1 [K]), inlet static pressure (P1 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. inlet mach number

    2. inlet static temperature [K]

    3. inlet static pressure [Pa]

    4. pipe length [m]

    5. pipe diameter [m]

    6. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M1’, ‘T1’, ‘P1’, ‘L’, ‘D’, ‘f’

Returns:

upstream flow state: Mach number, temperature [K] and pressure [Pa]

Return type:

tuple[float], tuple[ndarray]

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> M1, T1, P1 = cflow.friction.get_upstream_flow_state_after_overchoking_2(M1=2.0, T1=300., P1=1.e5, L=10., D=0.1, f=0.005)

get_upstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream pressure (P1 [Pa]) based on downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static pressure (P2 [Pa]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static pressure [Pa]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘P2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream pressure [Pa]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> P1 = cflow.friction.get_upstream_pressure(M2=0.8, P2=1.e5, L=10., D=0.1, f=0.005, mode=’subsonic’)

get_upstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Two-station problem:

Calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and pipe length (L [m])

input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), pipe length (L [m]), pipe diameter (D [m]), average Darcy friction factor (f [])

additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’

supported data types: float, list[float], ndarray

Parameters:
  • *args (Any) –

    arguments (optional input):

    1. downstream Mach number

    2. downstream static temperature [K]

    3. pipe length [m]

    4. pipe diameter [m]

    5. average Darcy friction factor

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘M2’, ‘T2’, ‘L’, ‘D’, ‘f’, ‘mode’

Returns:

upstream temperature [K]

Return type:

float, ndarray

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T1 = cflow.friction.get_upstream_temperature(M2=0.8, T2=300., L=10., D=0.1, f=0.005, mode=’subsonic’)

process_diagram_get_HS(M: float | list[float] | ndarray) → Tuple[float, float] | Tuple[list[float], list[float]] | Tuple[ndarray, ndarray][source]

Extract HS-diagram data for one dimensional flow with friction

input: Mach number (M [])

Parameters:

M (float, list[float], or ndarray :) – Mach number(s)

Returns:

H, Ds tuple[float, float], tuple[list[float], list[float]], tuple[ndarray, ndarray]

Return type:

tuple

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> H, Ds = cflow.friction.process_diagram_get_HS(M)

process_diagram_get_TS(T1: float, S1: float, M1: float, Ds: float, N: int) → Tuple[ndarray, ...][source]

Extract Ts-diagram data for one dimensional flow with friction

input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), entropy increment (Ds [J/K]), number of points (N)

Parameters:
  • T1 (float :) – temperature (T1) [K]

  • S1 (float :) – entropy (S1) [J/K]

  • M1 (float :) – Mach number

  • Ds (float :) – entropy change [J/K]

  • N (int :) – number of points

Returns:

T, S tuple[ndarray, …]

Return type:

tuple

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> T, S = cflow.friction.process_diagram_get_TS(T1, S1, M1, Ds, N)

class g3d.calc.calculators.G3DGenericCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCode

Generic calculator class (base class for all problem-specific calculators)

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

Newton_Raphson_solver(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Runs Newton-Raphson solver on specified function

input: function (func), iteration start value (start_value), function target value (target_value)

optional input (kwargs): numerical differentiation delta (delta, default 0.0001), maximum number of iterations (maxiter, default 100), tolerance (tol, default 1.e-6), lower function limit (lower_bound), upper function limit (upper_bound)

Parameters:
  • func (Callable :) – function to solve

  • *args (Any) –

    arguments (optional input):

    1. start value

    2. target value

    variable value(s) in above-listed order

  • **kwargs (Any) –

    keyword-value pairs (optional input):

    valid keywords: ‘delta’, ‘maxiter’, ‘tol’, ‘lower_bound’, ‘upper_bound’

    (any other keyword->argument input will be passed on to the specified function)

Returns:

Newton-Raphson solver result

Return type:

float

Examples

Basic usage:

$_>>> from g3d import cflow

$_>>> result = cflow.Newton_Raphson_solver(func, start_value=10., target_value=0.)

backup() → None[source]

Backup of stored variables

property gas: Gas

Gas object

property newton: G3DNewtonRaphsonSolver

Newton-Raphson solver

newton_reset() → None[source]

Deprecated since version 2.6: redirects to reset_newton()

print() → None[source]

Prints allocated variables

reset_newton() → None[source]

Resets Newton-Raphson solver to its default state

restore() → None[source]

Restore variable state from backup

set_from_key_value(key: str, value: Any) → bool[source]

Checks if provided key is in list of defined keys and updates calculator settings accordingly

class g3d.calc.calculators.G3DHeatCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to one-dimensional flow with heat addition

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_Q_star_and_T0(*args, **kwargs)

find_Mach_from_Q_star_and_T0s(*args, **kwargs)

find_Mach_from_pressure_ratio(*args, **kwargs)

find_Mach_from_q_star_and_To(*args, **kwargs)

find_Mach_from_q_star_and_Tos(*args, **kwargs)

find_Mach_from_temperature_ratio(*args, **kwargs)

find_Mach_from_total_temperature_ratio(...)

get_Mach_from_pressure_ratio(*args, **kwargs)

calculates local flow Mach number (M []) from provided local pressure (P [Pa]) and choked flow pressure (Ps [Pa]) input: local pressure (P [Pa]), choked flow pressure (Ps [Pa]) example: M = get_Mach_from_pressure_ratio(P=P, Ps=Ps)

get_Mach_from_q_star_and_To(*args, **kwargs)

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: choked flow heat addition (qs [J/kg]), local total temperature (To [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_q_star_and_To(qs=qs, To=To)

get_Mach_from_q_star_and_Tos(*args, **kwargs)

calculates local flow Mach number (M []) from provided choked flow total temperature (Tos [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: choked flow heat addition (qs [J/kg]), choked flow total temperature (Tos [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_q_star_and_Tos(qs=qs, Tos=Tos)

get_Mach_from_temperature_ratio(*args, **kwargs)

calculates local flow Mach number (M []) from provided local temperature (T [K]) and choked flow temperature (Ts [K]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: local temperature (T [K]), choked flow temperature (Ts [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_temperature_ratio(T=T, Ts=Ts)

get_Mach_from_total_temperature_ratio(*args, ...)

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow total temperature (Tos [K]) the flow is assumed to be subsonic unless mode='supersonic' is specified input: local total temperature (To [K]), choked flow total temperature (Tos [K]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_total_temperature_ratio(To=To, Tos=Tos)

get_P(*args, **kwargs)

calculates local pressure (P [Pa]) based on provided choked flow pressure (Ps [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow pressure (Ps [Pa]) example: P = get_P(M=M, Ps=Ps)

get_P0(*args, **kwargs)

get_P0_star(*args, **kwargs)

get_P_star(*args, **kwargs)

calculates choked flow pressure (Ps [Pa]) based on provided local pressure (P [Pa]) and flow Mach number (M []) input: flow Mach number (M []), pressure (P [Pa]) example: Ps = get_P_star(M=M, P=P)

get_Po(*args, **kwargs)

calculates local total pressure (Po [Pa]) based on provided choked flow total pressure (Pos [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total pressure (Pos [Pa]) example: Po = get_Po(M=M, Pos=Pos)

get_Po_star(*args, **kwargs)

calculates choked flow total pressure (Pos [Pa]) based on provided local total pressure (Po [Pa]) and flow Mach number (M []) input: flow Mach number (M []), total pressure (Po [Pa]) example: Pos = get_Po_star(M=M, Po=Po)

get_Q_star(*args, **kwargs)

get_RO(*args, **kwargs)

calculates local density (RO [kg/m^3]) based on provided choked flow density (ROs [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), choked flow density (ROs [kg/m^3]) example: RO = get_RO(M=M, ROs=ROs)

get_RO_star(*args, **kwargs)

calculates choked flow density (ROs [kg/m^3]) based on provided local density (RO [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), density (RO [kg/m^3]) example: ROs = get_RO_star(M=M, RO=RO)

get_T(*args, **kwargs)

calculates local temperature (T [K]) based on provided choked flow temperature (Ts [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow temperature (Ts [K]) example: T = get_T(M=M, Ts=Ts)

get_T0(*args, **kwargs)

get_T0_star(*args, **kwargs)

get_T_star(*args, **kwargs)

calculates choked flow temperature (Ts [K]) based on provided local temperature (T [K]) and flow Mach number (M []) input: flow Mach number (M []), temperature (T [K]) example: Ts = get_T_star(M=M, T=T)

get_To(*args, **kwargs)

calculates local total temperature (To [K]) based on provided choked flow total temperature (Tos [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total temperature (Tos [K]) example: To = get_To(M=M, Tos=Tos)

get_To_star(*args, **kwargs)

calculates choked flow total temperature (Tos [K]) based on provided local total temperature (To [K]) and flow Mach number (M []) input: flow Mach number (M []), total temperature (To [K]) example: Tos = get_To_star(M=M, To=To)

get_downstream_flow_state(*args, **kwargs)

two-station problem: calculates downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) based on upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M2, T2, P2 = get_downstream_flow_state(M1=M1, T1=T1, P1=P1, q=q, mode='subsonic')

get_downstream_pressure(*args, **kwargs)

two-station problem: calculates downstream pressure (P2 [Pa]) based on upstream temperature (T1 [K]), upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: P2 = get_downstream_pressure(M1=M1, T1=T1, P1=P1, q=q, mode='subsonic')

get_downstream_temperature(*args, **kwargs)

two-station problem: calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: T2 = get_downstream_temperature(M1=M1, T1=T1, q=q, mode='subsonic')

get_q_star(*args, **kwargs)

calculates choked flow heat addition from specified local total temperature (To [K]) and flow Mach number (M []) input: Mach number (M []), total temperature (To [K]) example qs = get_q_star(M=M, To=To)

get_upstream_flow_state(*args, **kwargs)

two-station problem: calculates upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) based on downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M1, T1, P1 = get_upstream_flow_state(M2=M2, T2=T2, P2=P2, q=q, mode='subsonic')

get_upstream_flow_state_after_overchoking(...)

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (Po [Pa], To [K]) the inlet static flow conditions are obtained such that the provided exit pressure is matched input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking(To=To, Po=Po, P2=P2, q=q)

get_upstream_flow_state_after_overchoking_2(...)

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (M1 [], T1 [K], P1 [Pa]) input: inlet Mach number (M1 []), inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking_2(M1=M1, T1=T1, P1=P1, q=q)

get_upstream_pressure(*args, **kwargs)

two-station problem: calculates upstream pressure (P1 [Pa]) based on downstream temperature (T2 [K]), downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: P1 = get_upstream_pressure(M2=M2, T2=T2, P2=P2, q=q, mode='subsonic')

get_upstream_temperature(*args, **kwargs)

two-station problem: calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), added heat (q [J/kg]) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: T1 = get_upstream_temperature(M2=M2, T2=T2, q=q, mode='subsonic')

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

process_diagram_get_HS(M)

extract HS-diagram data for one dimensional flow with heat addition input: Mach number (M []) example: H, DS = process_diagram_get_HS(M)

process_diagram_get_PVH(v, p1, v1, T1, q)

extract PVH-diagram data for one dimensional flow with heat addition input: specific volume (v [m^3/kg]), reference pressure (p1 [Pa]), reference specific volume (v1 [m^3/kg]), reference temperature (T1 [K]), added heat (q [J/kg]) example: H = process_diagram_get_PVH(v, p1, v1, T1, q)

process_diagram_get_TS(T1, S1, M1, Q, N)

extract Ts-diagram data for one dimensional flow with friction input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), added heat (Q [J/kg]), number of points (N) example: T, S = process_diagram_get_TS(T1, S1, M1, Q, N)

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_Mach_from_Q_star_and_T0(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_To()

find_Mach_from_Q_star_and_T0s(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_Tos()

find_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_pressure_ratio()

find_Mach_from_q_star_and_To(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_To()

find_Mach_from_q_star_and_Tos(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_q_star_and_Tos()

find_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_temperature_ratio()

find_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_from_total_temperature_ratio()

get_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local pressure (P [Pa]) and choked flow pressure (Ps [Pa]) input: local pressure (P [Pa]), choked flow pressure (Ps [Pa]) example: M = get_Mach_from_pressure_ratio(P=P, Ps=Ps)

get_Mach_from_q_star_and_To(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: choked flow heat addition (qs [J/kg]), local total temperature (To [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_q_star_and_To(qs=qs, To=To)

get_Mach_from_q_star_and_Tos(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided choked flow total temperature (Tos [K]) and choked flow heat addition (qs [J/kg]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: choked flow heat addition (qs [J/kg]), choked flow total temperature (Tos [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_q_star_and_Tos(qs=qs, Tos=Tos)

get_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local temperature (T [K]) and choked flow temperature (Ts [K]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: local temperature (T [K]), choked flow temperature (Ts [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_temperature_ratio(T=T, Ts=Ts)

get_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates local flow Mach number (M []) from provided local total temperature (To [K]) and choked flow total temperature (Tos [K]) the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: local total temperature (To [K]), choked flow total temperature (Tos [K]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_total_temperature_ratio(To=To, Tos=Tos)

get_P(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local pressure (P [Pa]) based on provided choked flow pressure (Ps [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow pressure (Ps [Pa]) example: P = get_P(M=M, Ps=Ps)

get_P0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po()

get_P0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Po_star()

get_P_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow pressure (Ps [Pa]) based on provided local pressure (P [Pa]) and flow Mach number (M []) input: flow Mach number (M []), pressure (P [Pa]) example: Ps = get_P_star(M=M, P=P)

get_Po(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local total pressure (Po [Pa]) based on provided choked flow total pressure (Pos [Pa]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total pressure (Pos [Pa]) example: Po = get_Po(M=M, Pos=Pos)

get_Po_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow total pressure (Pos [Pa]) based on provided local total pressure (Po [Pa]) and flow Mach number (M []) input: flow Mach number (M []), total pressure (Po [Pa]) example: Pos = get_Po_star(M=M, Po=Po)

get_Q_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_q_star()

get_RO(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local density (RO [kg/m^3]) based on provided choked flow density (ROs [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), choked flow density (ROs [kg/m^3]) example: RO = get_RO(M=M, ROs=ROs)

get_RO_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow density (ROs [kg/m^3]) based on provided local density (RO [kg/m^3]) and flow Mach number (M []) input: flow Mach number (M []), density (RO [kg/m^3]) example: ROs = get_RO_star(M=M, RO=RO)

get_T(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local temperature (T [K]) based on provided choked flow temperature (Ts [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow temperature (Ts [K]) example: T = get_T(M=M, Ts=Ts)

get_T0(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_To()

get_T0_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_To_star()

get_T_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow temperature (Ts [K]) based on provided local temperature (T [K]) and flow Mach number (M []) input: flow Mach number (M []), temperature (T [K]) example: Ts = get_T_star(M=M, T=T)

get_To(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local total temperature (To [K]) based on provided choked flow total temperature (Tos [K]) and flow Mach number (M []) input: flow Mach number (M []), choked flow total temperature (Tos [K]) example: To = get_To(M=M, Tos=Tos)

get_To_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow total temperature (Tos [K]) based on provided local total temperature (To [K]) and flow Mach number (M []) input: flow Mach number (M []), total temperature (To [K]) example: Tos = get_To_star(M=M, To=To)

get_downstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

two-station problem: calculates downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) based on upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M2, T2, P2 = get_downstream_flow_state(M1=M1, T1=T1, P1=P1, q=q, mode=’subsonic’)

get_downstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates downstream pressure (P2 [Pa]) based on upstream temperature (T1 [K]), upstream pressure (P1 [Pa]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), upstream static pressure (P1 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: P2 = get_downstream_pressure(M1=M1, T1=T1, P1=P1, q=q, mode=’subsonic’)

get_downstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates downstream temperature (T2 [K]) based on upstream temperature (T1 [K]), upstream Mach number (M1 []), and added heat (q [J/kg]) input: upstream Mach number (M1 []), upstream static temperature (T1 [K]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: T2 = get_downstream_temperature(M1=M1, T1=T1, q=q, mode=’subsonic’)

get_q_star(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked flow heat addition from specified local total temperature (To [K]) and flow Mach number (M []) input: Mach number (M []), total temperature (To [K]) example qs = get_q_star(M=M, To=To)

get_upstream_flow_state(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

two-station problem: calculates upstream flow state (Mach number M1 [], temperature T1 [K], pressure P1 [Pa]) based on downstream flow state (Mach number M2 [], temperature T2 [K], pressure P2 [Pa]) and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M1, T1, P1 = get_upstream_flow_state(M2=M2, T2=T2, P2=P2, q=q, mode=’subsonic’)

get_upstream_flow_state_after_overchoking(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (Po [Pa], To [K]) the inlet static flow conditions are obtained such that the provided exit pressure is matched input: inlet total temperature (To [K]), inlet total pressure (Po [Pa]), exit static pressure (P2 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking(To=To, Po=Po, P2=P2, q=q)

get_upstream_flow_state_after_overchoking_2(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates upstream static flow conditions if the added heat exceeds the choked flow heat addition for the provided upstream total condition (M1 [], T1 [K], P1 [Pa]) input: inlet Mach number (M1 []), inlet temperature (T1 [K]), inlet pressure (P1 [Pa]), added heat (q [J/kg]) example: M1, T1, P1 = get_upstream_flow_state_after_overchoking_2(M1=M1, T1=T1, P1=P1, q=q)

get_upstream_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates upstream pressure (P1 [Pa]) based on downstream temperature (T2 [K]), downstream pressure (P2 [Pa]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), downstream static pressure (P2 [Pa]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: P1 = get_upstream_pressure(M2=M2, T2=T2, P2=P2, q=q, mode=’subsonic’)

get_upstream_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

two-station problem: calculates upstream temperature (T1 [K]) based on downstream temperature (T2 [K]), downstream Mach number (M2 []), and added heat (q [J/kg]) input: downstream Mach number (M2 []), downstream static temperature (T2 [K]), added heat (q [J/kg]) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: T1 = get_upstream_temperature(M2=M2, T2=T2, q=q, mode=’subsonic’)

process_diagram_get_HS(M: float | list[float] | ndarray) → Tuple[float, float] | Tuple[list[float], list[float]] | Tuple[ndarray, ndarray][source]

extract HS-diagram data for one dimensional flow with heat addition input: Mach number (M []) example: H, DS = process_diagram_get_HS(M)

process_diagram_get_PVH(v: float | list[float] | ndarray, p1: float, v1: float, T1: float, q: float) → float | list[float] | ndarray[source]

extract PVH-diagram data for one dimensional flow with heat addition input: specific volume (v [m^3/kg]), reference pressure (p1 [Pa]), reference specific volume (v1 [m^3/kg]), reference temperature (T1 [K]), added heat (q [J/kg]) example: H = process_diagram_get_PVH(v, p1, v1, T1, q)

process_diagram_get_TS(T1: float, S1: float, M1: float, Q: float, N: int) → Tuple[ndarray, ...][source]

extract Ts-diagram data for one dimensional flow with friction input: initial temperature (T1 [K]), initial entropy (S1 [J/K]), initial Mach number (M1 []), added heat (Q [J/kg]), number of points (N) example: T, S = process_diagram_get_TS(T1, S1, M1, Q, N)

class g3d.calc.calculators.G3DIdealGasCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to the thermodynamics state

Attributes:
C

Speed of sound [m/s]

P

Pressure [Pa]

RO

Density [kg/m^3]

T

Temperature [K]

gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_density(*args, **kwargs)

calculates density (RO [kg/m^3]) using the ideal gas law input: pressure (P [Pa]) and temperature (T [K]) example: RO = get_density(P=P, T=T)

get_pressure(*args, **kwargs)

calculates pressure (P [Pa]) using the ideal gas law input: temperature (T [K]) and density (RO [kg/m^3]) example: P = get_pressure(T=T, RO=RO)

get_speed_of_sound(*args, **kwargs)

calculates speed of sound (C [m/s]) input: temperature (T [K]) example: C = get_speed_of_sound(T=T)

get_temperature(*args, **kwargs)

calculates temperature (T [K]) using the ideal gas law input: pressure (P [Pa]) and density (RO [kg/m^3]) example: T = get_temperature(P=P, RO=RO)

get_temperature_from_speed_of_sound(*args, ...)

calculates temperature (T [K]) from speed of sound (C [m/s]) input: speed of sound (C [m/s]) example: T = get_temperature_from_speed_of_sound(C=C)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

property C: float

Speed of sound [m/s]

property P: float

Pressure [Pa]

property RO: float

Density [kg/m^3]

property T: float

Temperature [K]

get_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density (RO [kg/m^3]) using the ideal gas law input: pressure (P [Pa]) and temperature (T [K]) example: RO = get_density(P=P, T=T)

get_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure (P [Pa]) using the ideal gas law input: temperature (T [K]) and density (RO [kg/m^3]) example: P = get_pressure(T=T, RO=RO)

get_speed_of_sound(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates speed of sound (C [m/s]) input: temperature (T [K]) example: C = get_speed_of_sound(T=T)

get_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature (T [K]) using the ideal gas law input: pressure (P [Pa]) and density (RO [kg/m^3]) example: T = get_temperature(P=P, RO=RO)

get_temperature_from_speed_of_sound(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates temperature (T [K]) from speed of sound (C [m/s]) input: speed of sound (C [m/s]) example: T = get_temperature_from_speed_of_sound(C=C)

class g3d.calc.calculators.G3DMovingExpansionCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to moving expansion regions

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_U_from_C_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local speed of sound (C [m/s]) and speed of sound ahead of expansion region (RO4 [kg/m^3]) input: local speed of sound (C [m/s]), speed of sound ahead of expansion region (C4 [m/s]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_C_ratio(C=C, C4=C4)

get_U_from_density_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), and temperature ahead of expansion region (T4 [K]) input: local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_density_ratio(RO=RO, RO4=RO4, T4=T4)

get_U_from_pressure_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), and temperature ahead of expansion region (T4 [K]) input: local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_pressure_ratio(P=P, P4=P4, T4=T4)

get_U_from_temperature_ratio(*args, **kwargs)

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local temperature (T [K]), and temperature ahead of expansion region (T4 [K]) input: local temperature (T [K]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_temperature_ratio(T=T, T4=T4)

get_density(*args, **kwargs)

calculates density for a location inside a moving expansion region (RO [kg/m^3]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) example RO = get_density(U=U, T4=T4, RO4=RO4)

get_pressure(*args, **kwargs)

calculates pressure for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) example P = get_pressure(U=U, T4=T4, P4=P4)

get_speed_of_sound(*args, **kwargs)

calculates speed of sound for a location inside a moving expansion region (C [m/s]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example C = get_speed_of_sound(U=U, T4=T4)

get_temperature(*args, **kwargs)

calculates temperature for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example T = get_temperature(U=U, T4=T4)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_U_from_C_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local speed of sound (C [m/s]) and speed of sound ahead of expansion region (RO4 [kg/m^3]) input: local speed of sound (C [m/s]), speed of sound ahead of expansion region (C4 [m/s]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_C_ratio(C=C, C4=C4)

get_U_from_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), and temperature ahead of expansion region (T4 [K]) input: local density (RO [kg/m^3]), density ahead of expansion region (RO4 [kg/m^3]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_density_ratio(RO=RO, RO4=RO4, T4=T4)

get_U_from_pressure_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), and temperature ahead of expansion region (T4 [K]) input: local pressure (P [Pa]), pressure head of expansion region (P4 [Pa]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_pressure_ratio(P=P, P4=P4, T4=T4)

get_U_from_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates local flow velocity for a location inside a moving expansion region (U [m/s]) from local temperature (T [K]), and temperature ahead of expansion region (T4 [K]) input: local temperature (T [K]), temperature ahead of expansion region (T4 [K]) example U = get_U_from_temperature_ratio(T=T, T4=T4)

get_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density for a location inside a moving expansion region (RO [kg/m^3]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), density ahead of expansion wave (RO4 [kg/m^3]) example RO = get_density(U=U, T4=T4, RO4=RO4)

get_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]), pressure ahead of expansion wave (P4 [Pa]) example P = get_pressure(U=U, T4=T4, P4=P4)

get_speed_of_sound(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates speed of sound for a location inside a moving expansion region (C [m/s]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example C = get_speed_of_sound(U=U, T4=T4)

get_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature for a location inside a moving expansion region (P [Pa]) from local velocity (U [m/s]) and temperature ahead of expansion region (T4 [K]) input: local flow velocity (U [m/s]), temperature ahead of expansion region (T4 [K]) example T = get_temperature(U=U, T4=T4)

class g3d.calc.calculators.G3DMovingShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to moving shock waves

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_PR21_from_Mr(*args, **kwargs)

find_PR21_from_Ms(*args, **kwargs)

find_PR21_from_PR51(*args, **kwargs)

find_PR21_from_TR51(*args, **kwargs)

find_PR21_from_up(*args, **kwargs)

get_Mr(*args, **kwargs)

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock Mach number (Ms []) input: incident shock Mach number (Ms []) example: Mr = get_Mr(Ms=Ms)

get_Mr_from_PR21(*args, **kwargs)

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock pressure ratio (PR21 []) input: incident shock Mach number (Ms []) example: Mr = get_Mr_from_PR21(PR21=PR21)

get_Ms(*args, **kwargs)

calculates incident shock Mach number (Ms []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example: Ms = get_Ms(PR21=PR21)

get_PR21_from_Mr(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from reflected shock Mach number (Mr []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock Mach number (Mr []) example PR21 = get_PR21_from_Mr(Mr=Mr)

get_PR21_from_Ms(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from shock Mach number (Ms []) input: incident shock Mach number (Ms []) example PR21 = get_PR21_from_Ms(Ms=Ms)

get_PR21_from_PR51(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from the ratio of pressure behind the reflected shock (P5) and the pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow pressure ratio (PR51 []) example PR21 = get_PR21_from_PR51(PR51=PR51)

get_PR21_from_TR51(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from the ratio of temperature behind the reflected shock (T5) and the temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow temperature ratio (TR51 []) example PR21 = get_PR21_from_TR51(TR51=TR51)

get_PR21_from_up(*args, **kwargs)

calculates pressure ratio of incident shock (PR21 []) from induced flow velocity (Up [m/s]) the pressure ratio is calculated using the built-in Newton-Raphson solver input: induced flow velocity (Up [m/s]), temperature of the undisturbed flow ahead of the incident shock (T1 [K]) example PR21 = get_PR21_from_up(Up=Up, T1=T1)

get_PR51_from_PR21(*args, **kwargs)

calculates ratio of pressure behind reflected shock (P5) and pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: PR51 = get_PR51_from_PR21(PR21=PR21)

get_TR51_from_PR21(*args, **kwargs)

calculates ratio of temperature behind reflected shock (T5) and temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: TR51 = get_TR51_from_PR21(PR21=PR21)

get_density_ratio(*args, **kwargs)

calculates shock density ratio (RR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example RR21 = get_density_ratio(PR21=PR21)

get_temperature_ratio(*args, **kwargs)

calculates shock temperature ratio (TR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example TR21 = get_temperature_ratio(PR21=PR21)

get_up(*args, **kwargs)

calculates induced flow velocity (Up [m/s], velocity behind incident shock) corresponding to specified shock pressure ratio (PR21 []) and temperature in front of incident shock (T1 [K]) input: shock pressure ratio (PR21 []), temperature in front of incident shock (T1 [K]) example: Up = get_up(PR21=PR21, T1=T1)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_PR21_from_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_Mr()

find_PR21_from_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_Ms()

find_PR21_from_PR51(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_PR51()

find_PR21_from_TR51(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_PR21_from_TR51()

find_PR21_from_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_up()

get_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock Mach number (Ms []) input: incident shock Mach number (Ms []) example: Mr = get_Mr(Ms=Ms)

get_Mr_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates reflected shock Mach number (Mr []) corresponding to specified incident shock pressure ratio (PR21 []) input: incident shock Mach number (Ms []) example: Mr = get_Mr_from_PR21(PR21=PR21)

get_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates incident shock Mach number (Ms []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example: Ms = get_Ms(PR21=PR21)

get_PR21_from_Mr(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from reflected shock Mach number (Mr []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock Mach number (Mr []) example PR21 = get_PR21_from_Mr(Mr=Mr)

get_PR21_from_Ms(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from shock Mach number (Ms []) input: incident shock Mach number (Ms []) example PR21 = get_PR21_from_Ms(Ms=Ms)

get_PR21_from_PR51(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from the ratio of pressure behind the reflected shock (P5) and the pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow pressure ratio (PR51 []) example PR21 = get_PR21_from_PR51(PR51=PR51)

get_PR21_from_TR51(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates pressure ratio of incident shock (PR21 []) from the ratio of temperature behind the reflected shock (T5) and the temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) the pressure ratio is calculated using the built-in Newton-Raphson solver input: reflected shock to undisturbed flow temperature ratio (TR51 []) example PR21 = get_PR21_from_TR51(TR51=TR51)

get_PR21_from_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio of incident shock (PR21 []) from induced flow velocity (Up [m/s]) the pressure ratio is calculated using the built-in Newton-Raphson solver input: induced flow velocity (Up [m/s]), temperature of the undisturbed flow ahead of the incident shock (T1 [K]) example PR21 = get_PR21_from_up(Up=Up, T1=T1)

get_PR51_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates ratio of pressure behind reflected shock (P5) and pressure in the undisturbed flow ahead of the incident shock (P1) (PR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: PR51 = get_PR51_from_PR21(PR21=PR21)

get_TR51_from_PR21(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates ratio of temperature behind reflected shock (T5) and temperature in the undisturbed flow ahead of the incident shock (T1) (TR51 []) from specified incident shock pressure ratio (PR21 []) input: incident shock pressure ratio (PR21 []) example: TR51 = get_TR51_from_PR21(PR21=PR21)

get_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates shock density ratio (RR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example RR21 = get_density_ratio(PR21=PR21)

get_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates shock temperature ratio (TR21 []) corresponding to specified shock pressure ratio (PR21 []) input: shock pressure ratio (PR21 []) example TR21 = get_temperature_ratio(PR21=PR21)

get_up(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates induced flow velocity (Up [m/s], velocity behind incident shock) corresponding to specified shock pressure ratio (PR21 []) and temperature in front of incident shock (T1 [K]) input: shock pressure ratio (PR21 []), temperature in front of incident shock (T1 [K]) example: Up = get_up(PR21=PR21, T1=T1)

class g3d.calc.calculators.G3DNewtonRaphsonSolver(*args: Any, **kwargs: Any)[source]

Bases: G3DCode

Newton-Raphson solver

Attributes:
check_lower_bound

Check lower bound (bool, default value: False)

check_upper_bound

Check upper bound (bool, default value: False)

coarse_delta

Delta used in coarse search (default 1.e-2)

delta

Delta used for numerical differentiation (default 1.e-4)

end_value

Search end value

lower_bound

Lower function bound, one-sided numerical differentiation used if needed

max_iter

Maximum number of Newton-Raphson iterations (default 100)

scipy_kwargs

Scipy Newton-Raphson parameters

solver_mode

Newton-Raphson solver mode: native (default) or scipy

start_value

Newton search start value

tag

tag (string) used for identification

target_value

Function target value

tolerance

Newton-Raphson tolerance = abs(value - target_value), (default 1.e-6)

upper_bound

Upper function bound, one-sided numerical differentiation used if needed

verbose

Verbose mode => prints iteration information (default False)

Methods

copy(e)

copies data from specified entity input: entity example: copy(e)

find_start_value(func, *args, **kwargs)

Finds start value using coarse search for provided function

get_settings_from_solver(newton)

copy settings from provided Newton-Raphson solver object input: Newton-Raphson solver object

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

native_solve(func, *args, **kwargs)

Executes native Newton-Raphson for provided function and parameters

print()

Prints solver settings

reset()

Resets Newton-Raphson solver parameters to their default values

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Set parameters from provided key => value input

solve(func, *args, **kwargs)

Executes scipy Newton-Raphson for provided function and parameters

update_settings(**kwargs)

Updates Newton-Raphson solver parameters

property check_lower_bound: bool

False)

Type:

Check lower bound (bool, default value

property check_upper_bound: bool

False)

Type:

Check upper bound (bool, default value

property coarse_delta: float

Delta used in coarse search (default 1.e-2)

property delta: float

Delta used for numerical differentiation (default 1.e-4)

property end_value: float

Search end value

find_start_value(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Finds start value using coarse search for provided function

get_settings_from_solver(newton: G3DNewtonRaphsonSolver) → None[source]

copy settings from provided Newton-Raphson solver object input: Newton-Raphson solver object

property lower_bound: float

Lower function bound, one-sided numerical differentiation used if needed

property max_iter: int

Maximum number of Newton-Raphson iterations (default 100)

native_solve(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Executes native Newton-Raphson for provided function and parameters

print() → None[source]

Prints solver settings

reset() → None[source]

Resets Newton-Raphson solver parameters to their default values

property scipy_kwargs: dict[Any, Any]

Scipy Newton-Raphson parameters

set_from_key_value(key: str, value: Any) → bool[source]

Set parameters from provided key => value input

solve(func: Callable[[float], float], *args: Any, **kwargs: Any) → float[source]

Executes scipy Newton-Raphson for provided function and parameters

property solver_mode: Any

native (default) or scipy

Type:

Newton-Raphson solver mode

property start_value: float

Newton search start value

property target_value: float

Function target value

property tolerance: float

Newton-Raphson tolerance = abs(value - target_value), (default 1.e-6)

update_settings(**kwargs: Any) → None[source]

Updates Newton-Raphson solver parameters

property upper_bound: float

Upper function bound, one-sided numerical differentiation used if needed

property verbose: bool

Verbose mode => prints iteration information (default False)

class g3d.calc.calculators.G3DNormalShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to normal shocks

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_downstream_Astar(*args, **kwargs)

calculate choke cross-section area downstream of normal shock (As2 [m^2]) as function of upstream Mach number (M1 []),and upstream choke cross-section area (As1 [m^2]) input: upstream Mach number (M1 []), upstream choke cross-section area (As1 [m^2], default value: 1.0) example: As2 = get_downstream_Astar(M1=M1, As1=As1)

get_downstream_Mach(*args, **kwargs)

calculate Mach number downstream of normal shock (M2 []) as function of upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: M2 = get_downstream_Mach(M1=M1)

get_downstream_density(*args, **kwargs)

calculate density downstream of normal shock (RO2 [kg/m^3]) as function of upstream Mach number (M1 []), and upstream density (RO1 [kg/m^3]) input: upstream Mach number (M1 []), upstream density (RO1 [kg/m^3], default value: 1.0) example: RO2 = get_downstream_density(M1=M1, RO1=RO1)

get_downstream_pressure(*args, **kwargs)

calculate pressure downstream of normal shock (P2 [Pa]) as function of upstream Mach number (M1 []), and upstream pressure (P1 [Pa]) input: upstream Mach number (M1 []), upstream pressure (P1 [Pa], default value: 1.0) example: P2 = get_downstream_pressure(M1=M1, P1=P1)

get_downstream_temperature(*args, **kwargs)

calculate temperature downstream of normal shock (T2 [K]) as function of upstream Mach number (M1 []), and upstream temperature (T1 [K]) input: upstream Mach number (M1 []), upstream temperature (T1 [K], default value: 1.0) example: T2 = get_downstream_pressure(M1=M1, T1=T1)

get_downstream_total_pressure(*args, **kwargs)

calculate total pressure downstream of normal shock (Po2 [Pa]) as function of upstream Mach number (M1 []), and upstream total pressure (Po1 [Pa]) input: upstream Mach number (M1 []), upstream total pressure (Po1 [Pa], default value: 1.0) example: Po2 = get_downstream_total_pressure(M1=M1, Po1=Po1)

get_entropy_increase(*args, **kwargs)

calculate normal shock entropy increase from upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: dS = get_entropy_increase(M1=M1)

get_upstream_Astar(*args, **kwargs)

calculate choke cross-section area upstream of normal shock (As1 [m^2]) as function of downstream Mach number (M2 []),and downstream choke cross-section area (As2 [m^2]) input: downstream Mach number (M2 []), downstream choke cross-section area (As2 [m^2], default value: 1.0) example: As1 = get_upstream_Astar(M2=M2, As2=As2)

get_upstream_Mach(*args, **kwargs)

calculate Mach number upstream of normal shock (M1 []) as function of downstream Mach number (M2 []) input: downstream Mach number (M2 []) example: M1 = get_upstream_Mach(M2=M2s)

get_upstream_Mach_from_density_ratio(*args, ...)

calculate upstream Mach number (M1 []) from normal shock density ratio (RR []) input: density ratio (RR []) example: M1 = get_upstream_Mach_from_density_ratio(RR=RR)

get_upstream_Mach_from_pressure_ratio(*args, ...)

calculate upstream Mach number (M1 []) from normal shock pressure ratio (PR []) input: pressure ratio (PR []) example: M1 = get_upstream_Mach_from_pressure_ratio(PR=PR)

get_upstream_Mach_from_temperature_ratio(...)

calculate upstream Mach number (M1 []) from normal shock temperature ratio (TR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (TR []) example: M1 = get_upstream_Mach_from_temperature_ratio(TR=TR)

get_upstream_Mach_from_total_pressure_ratio(...)

calculate upstream Mach number (M1 []) from normal shock total pressure ratio (PoR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (PoR []) example: M1 = get_upstream_Mach_from_total_pressure_ratio(PoR=PoR)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_downstream_Astar(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate choke cross-section area downstream of normal shock (As2 [m^2]) as function of upstream Mach number (M1 []),and upstream choke cross-section area (As1 [m^2]) input: upstream Mach number (M1 []), upstream choke cross-section area (As1 [m^2], default value: 1.0) example: As2 = get_downstream_Astar(M1=M1, As1=As1)

get_downstream_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number downstream of normal shock (M2 []) as function of upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: M2 = get_downstream_Mach(M1=M1)

get_downstream_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate density downstream of normal shock (RO2 [kg/m^3]) as function of upstream Mach number (M1 []), and upstream density (RO1 [kg/m^3]) input: upstream Mach number (M1 []), upstream density (RO1 [kg/m^3], default value: 1.0) example: RO2 = get_downstream_density(M1=M1, RO1=RO1)

get_downstream_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate pressure downstream of normal shock (P2 [Pa]) as function of upstream Mach number (M1 []), and upstream pressure (P1 [Pa]) input: upstream Mach number (M1 []), upstream pressure (P1 [Pa], default value: 1.0) example: P2 = get_downstream_pressure(M1=M1, P1=P1)

get_downstream_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate temperature downstream of normal shock (T2 [K]) as function of upstream Mach number (M1 []), and upstream temperature (T1 [K]) input: upstream Mach number (M1 []), upstream temperature (T1 [K], default value: 1.0) example: T2 = get_downstream_pressure(M1=M1, T1=T1)

get_downstream_total_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate total pressure downstream of normal shock (Po2 [Pa]) as function of upstream Mach number (M1 []), and upstream total pressure (Po1 [Pa]) input: upstream Mach number (M1 []), upstream total pressure (Po1 [Pa], default value: 1.0) example: Po2 = get_downstream_total_pressure(M1=M1, Po1=Po1)

get_entropy_increase(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate normal shock entropy increase from upstream Mach number (M1 []) input: upstream Mach number (M1 []) example: dS = get_entropy_increase(M1=M1)

get_upstream_Astar(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate choke cross-section area upstream of normal shock (As1 [m^2]) as function of downstream Mach number (M2 []),and downstream choke cross-section area (As2 [m^2]) input: downstream Mach number (M2 []), downstream choke cross-section area (As2 [m^2], default value: 1.0) example: As1 = get_upstream_Astar(M2=M2, As2=As2)

get_upstream_Mach(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number upstream of normal shock (M1 []) as function of downstream Mach number (M2 []) input: downstream Mach number (M2 []) example: M1 = get_upstream_Mach(M2=M2s)

get_upstream_Mach_from_density_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock density ratio (RR []) input: density ratio (RR []) example: M1 = get_upstream_Mach_from_density_ratio(RR=RR)

get_upstream_Mach_from_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock pressure ratio (PR []) input: pressure ratio (PR []) example: M1 = get_upstream_Mach_from_pressure_ratio(PR=PR)

get_upstream_Mach_from_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock temperature ratio (TR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (TR []) example: M1 = get_upstream_Mach_from_temperature_ratio(TR=TR)

get_upstream_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M1 []) from normal shock total pressure ratio (PoR []) upstream Mach number is calculated using the built-in Newton-Raphson solver input: density ratio (PoR []) example: M1 = get_upstream_Mach_from_total_pressure_ratio(PoR=PoR)

class g3d.calc.calculators.G3DNozzleCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

class collecting functions related to nozzle flows (Q1D one-dimensional flows with smooth cross-section area changes)

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

area_ratio(*args, **kwargs)

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_Mach_from_area_ratio(*args, **kwargs)

find_Mach_internal_shock(*args, **kwargs)

get_Mach_from_area_ratio(*args, **kwargs)

calculates Mach number (M []) corresponding to the specified area ratio (AR []) the Mach number is calculated using the built-in Newton-Raphson solver the flow is assumed to be subsonic unless mode='supersonic' is specified input: area ratio (AR []) additional input: mode = 'subsonic' (default if not specified) or mode = 'supersonic' example: M = get_Mach_from_area_ratio(AR=AR)

get_Mach_internal_shock(*args, **kwargs)

calculate Mach number (M1 []) just upstream of shock for choked nozzle flow with internal shock calculations are made using the built-in Newton-Raphson solver input: inlet total pressure (Po [Pa], total pressure upstream of shock), throat area (At [m^2]), exit area (Ae [m^2]), nozzle exit pressure (Pe [Pa]) example: M1 = get_Mach_internal_shock(Po=Po, At=At, Ae=Ae, Pe=Pe)

get_area_ratio(*args, **kwargs)

calculates area ratio (AR []) for specified Mach number (M []) using the area-Mach-number relation input: Mach number (M []) example: AR = get_area_ratio(M=M)

get_choked_area(*args, **kwargs)

calculates choked cross-section area (At [m^2]) for specified choked massflow (mp [kg/s]), total pressure (Po [Pa]), and total temperature (To [K]) input: massflow (mp [kg/s]), total pressure (Po [Pa]), total temperature (To [K]) example: As = get_choked_area(mp=mp, Po=Po, To=To)

get_choked_mass_flow(*args, **kwargs)

calculates choked massflow (mp [kg/s]) for specified upstream total pressure (Po [Pa]), total temperature (To [K]), and throat area (At [m^2]) input: total pressure (Po [Pa]), total temperature (To [K]), throat area (At [m^2]) example: me = get_choked_mass_flow(Po=Po, To=To, At=At)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

internal_shock_get_exit_Mach_number(*args, ...)

calculates exit Mach number (Me []) for nozzle flow with internal shock input: total pressure upstream of shock (Po [Pa], same as nozzle inlet total pressure), static pressure downstream of nozzle exit (Pb [Pa]), nozzle exit-to-throat area ratio (AR=Ae/At []) example: Me = internal_shock_get_exit_Mach_number(Po=Po, Pb=Pb, AR=AR)

internal_shock_get_exit_conditions(*args, ...)

calculates exit Mach number and pressure (Me [], Pe [Pa]) for nozzle flow with internal shock some values are calculated using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Me, Pe = internal_shock_get_exit_conditions(M1=M1, Po=Po, At=At, Ae=Ae)

internal_shock_get_exit_pressure(*args, **kwargs)

calculates exit pressure (Pe [Pa]) for nozzle flow with internal shock calculations are done using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Pe = internal_shock_get_exit_pressure(M1=M1, Po=Po, At=At, Ae=Ae)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

moc(Me[, n, t0])

simple Methods-Of-Characteristics (MOC) deign of 2D planar divergent nozzle shape input: exit Mach number (design condition/supercritical flow) (Me []), number of characteristic lines (n, default value: 10), start angle (t0 [rad], default value: 0.01) example: Km, Kp, t, v, M, mu, x, y = moc(Me=Me, n=n, t0=t0)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_area_ratio()

find_Mach_from_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_from_area_ratio()

find_Mach_internal_shock(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_Mach_internal_shock()

get_Mach_from_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates Mach number (M []) corresponding to the specified area ratio (AR []) the Mach number is calculated using the built-in Newton-Raphson solver the flow is assumed to be subsonic unless mode=’supersonic’ is specified input: area ratio (AR []) additional input: mode = ‘subsonic’ (default if not specified) or mode = ‘supersonic’ example: M = get_Mach_from_area_ratio(AR=AR)

get_Mach_internal_shock(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculate Mach number (M1 []) just upstream of shock for choked nozzle flow with internal shock calculations are made using the built-in Newton-Raphson solver input: inlet total pressure (Po [Pa], total pressure upstream of shock), throat area (At [m^2]), exit area (Ae [m^2]), nozzle exit pressure (Pe [Pa]) example: M1 = get_Mach_internal_shock(Po=Po, At=At, Ae=Ae, Pe=Pe)

get_area_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates area ratio (AR []) for specified Mach number (M []) using the area-Mach-number relation input: Mach number (M []) example: AR = get_area_ratio(M=M)

get_choked_area(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked cross-section area (At [m^2]) for specified choked massflow (mp [kg/s]), total pressure (Po [Pa]), and total temperature (To [K]) input: massflow (mp [kg/s]), total pressure (Po [Pa]), total temperature (To [K]) example: As = get_choked_area(mp=mp, Po=Po, To=To)

get_choked_mass_flow(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates choked massflow (mp [kg/s]) for specified upstream total pressure (Po [Pa]), total temperature (To [K]), and throat area (At [m^2]) input: total pressure (Po [Pa]), total temperature (To [K]), throat area (At [m^2]) example: me = get_choked_mass_flow(Po=Po, To=To, At=At)

internal_shock_get_exit_Mach_number(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates exit Mach number (Me []) for nozzle flow with internal shock input: total pressure upstream of shock (Po [Pa], same as nozzle inlet total pressure), static pressure downstream of nozzle exit (Pb [Pa]), nozzle exit-to-throat area ratio (AR=Ae/At []) example: Me = internal_shock_get_exit_Mach_number(Po=Po, Pb=Pb, AR=AR)

internal_shock_get_exit_conditions(*args: Any, **kwargs: Any) → Tuple[float64, ...] | list[Tuple[float64, ...]][source]

calculates exit Mach number and pressure (Me [], Pe [Pa]) for nozzle flow with internal shock some values are calculated using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Me, Pe = internal_shock_get_exit_conditions(M1=M1, Po=Po, At=At, Ae=Ae)

internal_shock_get_exit_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates exit pressure (Pe [Pa]) for nozzle flow with internal shock calculations are done using the built-in Newton-Raphson solver input: nozzle inlet Mach number (M1 []), nozzle inlet total pressure (Po [Pa]), throat area (At [m^2]), nozzle exit area (Ae [m^2]) example: Pe = internal_shock_get_exit_pressure(M1=M1, Po=Po, At=At, Ae=Ae)

moc(Me: float, n: int = 10, t0: float = 0.01) → Tuple[ndarray, ...][source]

simple Methods-Of-Characteristics (MOC) deign of 2D planar divergent nozzle shape input: exit Mach number (design condition/supercritical flow) (Me []), number of characteristic lines (n, default value: 10), start angle (t0 [rad], default value: 0.01) example: Km, Kp, t, v, M, mu, x, y = moc(Me=Me, n=n, t0=t0)

class g3d.calc.calculators.G3DObliqueShockCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to oblique shocks

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

analyze_oblique_shock(*args, **kwargs)

calculates shock angle (beta [rad*]), downstream flow Mach number (M2 []), shock pressure ratio (PR21 []), and shock temperature ratio (TR21 []) corresponding to the specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated flow deflection angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: beta, M2, PR21, TR21 = analyze_oblique_shock(M1=M1, theta=theta)

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_M1_from_theta_and_M2(*args, **kwargs)

find_Mach_min(*args, **kwargs)

find_beta(*args, **kwargs)

get_M1_from_theta_and_M2(*args, **kwargs)

calculates flow Mach number upstream of oblique shock (M1 []) from specified downstream flow Mach number (M2 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: downstream flow Mach number (M2 []), flow deflection angle (theta [rad*]) example: M2 = get_M1_from_theta_and_M2(M2=M2, theta=theta)

get_Mach(*args, **kwargs)

calculate upstream Mach number (M []) corresponding to specified shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]), shock angle (beta [rad*]) example: M = get_Mach(theta=theta, beta=beta)

get_Mach_angle(*args, **kwargs)

calculates Mach angle (mu [rad*]) corresponding to specified flow Mach number (M []) * the mach angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: Mach number (M []) example: mu = get_Mach_angle(M=M)

get_Mach_min(*args, **kwargs)

calculates the minimum flow Mach number (M []) for a specified flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]) example: M = get_Mach_min(theta=theta)

get_angles_from_PR_and_M1(*args, **kwargs)

calculates shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) corresponding to specified pressure ratio (PR []) and upstream flow Mach number (M1 []) * shock angle and flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: pressure ratio (PR []), upstream flow Mach number (M1 []) example: beta, theta = get_angles_from_PR_and_M1(PR=PR, M1=M1)

get_beta(*args, **kwargs)

calculates shock angle (beta [rad*]) for specified flow Mach number (M []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated shock angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the shock angle is obtained using the built-in Newton-Raphson solver input: flow Mach number (M []), flow deflection angle (theta [rad*]) example: beta = get_beta(M=M, theta=theta)

get_density_ratio(*args, **kwargs)

calculates density ratio (ROR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: ROR = get_density_ratio(M1=M1, beta=beta)

get_downstream_Mach(*args, **kwargs)

calculates downstream flow Mach number (M2 []) from upstream flow Mach number (M1 []), shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream flow Mach number (M1 []), shock angle (beta [rad*]), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach(M1=M1, beta=beta, theta=theta)

get_downstream_Mach_from_theta_and_M1(*args, ...)

calculates flow Mach number downstream of oblique shock (M2 []) from specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach_from_theta_and_M1(M1=M1, theta=theta)

get_normal_Mach_1(*args, **kwargs)

calculates the upstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn1 []) using the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: Mn1 = get_normal_Mach_1(M1=M1, beta=beta)

get_normal_Mach_2(*args, **kwargs)

calculates the downstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn2 []) using the upstream shock-normal Mach number (Mn1 []) input: upstream shock-normal Mach number (Mn1 []) example: Mn2 = get_normal_Mach_2(Mn1=Mn1)

get_pressure_ratio(*args, **kwargs)

calculates pressure ratio (PR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: PR = get_pressure_ratio(M1=M1, beta=beta)

get_temperature_ratio(*args, **kwargs)

calculates temperature ratio (TR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: TR = get_pressure_ratio(M1=M1, beta=beta)

get_theta(*args, **kwargs)

calculates flow deflection angle (theta [rad*]) from flow Mach number (M []) and shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated deflection angle in degrees as well) input: flow Mach number (M []), shock angle (beta [rad*]) example: theta = get_theta(M=M, beta=beta)

get_theta_beta_Mach_array(M1[, N])

extracts shock angle vector and flow deflection angle vector for specified upstream flow Mach number (M1 []) input: upstream flow Mach number (M1 []), vector length (N, default value: 100) example: theta, beta = get_theta_beta_Mach_array(M1, N)

get_theta_max(*args, **kwargs)

calculates maximum flow deflection angle (theta_max [rad*]) for a specified flow Mach number (M []) * the calculated flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: flow Mach number (M []) example: theta_max = get_theta_max(M=M)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

analyze_oblique_shock(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]), downstream flow Mach number (M2 []), shock pressure ratio (PR21 []), and shock temperature ratio (TR21 []) corresponding to the specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated flow deflection angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: beta, M2, PR21, TR21 = analyze_oblique_shock(M1=M1, theta=theta)

find_M1_from_theta_and_M2(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_M1_from_theta_and_M2()

find_Mach_min(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

Deprecated since version 2.6: redirects to get_Mach_min()

find_beta(*args, **kwargs)[source]

Deprecated since version 2.6: redirects to get_beta()

get_M1_from_theta_and_M2(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates flow Mach number upstream of oblique shock (M1 []) from specified downstream flow Mach number (M2 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: downstream flow Mach number (M2 []), flow deflection angle (theta [rad*]) example: M2 = get_M1_from_theta_and_M2(M2=M2, theta=theta)

get_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculate upstream Mach number (M []) corresponding to specified shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]), shock angle (beta [rad*]) example: M = get_Mach(theta=theta, beta=beta)

get_Mach_angle(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates Mach angle (mu [rad*]) corresponding to specified flow Mach number (M []) * the mach angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: Mach number (M []) example: mu = get_Mach_angle(M=M)

get_Mach_min(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates the minimum flow Mach number (M []) for a specified flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: flow deflection angle (theta [rad*]) example: M = get_Mach_min(theta=theta)

get_angles_from_PR_and_M1(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) corresponding to specified pressure ratio (PR []) and upstream flow Mach number (M1 []) * shock angle and flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: pressure ratio (PR []), upstream flow Mach number (M1 []) example: beta, theta = get_angles_from_PR_and_M1(PR=PR, M1=M1)

get_beta(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates shock angle (beta [rad*]) for specified flow Mach number (M []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated shock angle in degrees as well) the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the shock angle is obtained using the built-in Newton-Raphson solver input: flow Mach number (M []), flow deflection angle (theta [rad*]) example: beta = get_beta(M=M, theta=theta)

get_density_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates density ratio (ROR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: ROR = get_density_ratio(M1=M1, beta=beta)

get_downstream_Mach(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates downstream flow Mach number (M2 []) from upstream flow Mach number (M1 []), shock angle (beta [rad*]) and flow deflection angle (theta [rad*]) * shock angle and flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream flow Mach number (M1 []), shock angle (beta [rad*]), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach(M1=M1, beta=beta, theta=theta)

get_downstream_Mach_from_theta_and_M1(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates flow Mach number downstream of oblique shock (M2 []) from specified upstream flow Mach number (M1 []) and flow deflection angle (theta [rad*]) * flow deflection angle should be given in radians unless angle_type=AngleType.DEGREES is specified the oblique shock will be assumed to fall within the weak shock solution unless mode=CFlowRegime.STRONG is specified the built-in Newton-Raphson solver is used for some of the calculations input: upstream flow Mach number (M1 []), flow deflection angle (theta [rad*]) example: M2 = get_downstream_Mach_from_theta_and_M1(M1=M1, theta=theta)

get_normal_Mach_1(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates the upstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn1 []) using the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: Mn1 = get_normal_Mach_1(M1=M1, beta=beta)

get_normal_Mach_2(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates the downstream shock-normal Mach number (the flow Mach number calculated using the velocity component normal to the shock) (Mn2 []) using the upstream shock-normal Mach number (Mn1 []) input: upstream shock-normal Mach number (Mn1 []) example: Mn2 = get_normal_Mach_2(Mn1=Mn1)

get_pressure_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates pressure ratio (PR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: PR = get_pressure_ratio(M1=M1, beta=beta)

get_temperature_ratio(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates temperature ratio (TR []) over an oblique shock with the upstream flow Mach number (M1 []) and the shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified input: upstream Mach number (M1 []), shock angle (beta [rad*]) example: TR = get_pressure_ratio(M1=M1, beta=beta)

get_theta(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates flow deflection angle (theta [rad*]) from flow Mach number (M []) and shock angle (beta [rad*]) * shock angle should be given in radians unless angle_type=AngleType.DEGREES is specified (please note that angle_type=AngleType.DEGREES will result in a calculated deflection angle in degrees as well) input: flow Mach number (M []), shock angle (beta [rad*]) example: theta = get_theta(M=M, beta=beta)

get_theta_beta_Mach_array(M1: float, N: int = 100) → Tuple[ndarray, ...][source]

extracts shock angle vector and flow deflection angle vector for specified upstream flow Mach number (M1 []) input: upstream flow Mach number (M1 []), vector length (N, default value: 100) example: theta, beta = get_theta_beta_Mach_array(M1, N)

get_theta_max(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates maximum flow deflection angle (theta_max [rad*]) for a specified flow Mach number (M []) * the calculated flow deflection angle will be given in radians unless angle_type=AngleType.DEGREES is specified input: flow Mach number (M []) example: theta_max = get_theta_max(M=M)

class g3d.calc.calculators.G3DShockTubeCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

Class collecting functions related to shock-tube problems

Attributes:
gas

Gas object

gas1

Driver gas (high-pressure chamber)

gas2

Driven gas (low-pressure chamber)

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

find_PR21_from_PR41(*args, **kwargs)

get_PR21_from_PR41(*args, **kwargs)

finds incident shock pressure ratio (PR21 []) matching specified shock-tube pressure ratio (PR41 [], driver section pressure over driven section pressure), driver section temperature (T4 [K]), and driven section temperature (T1 [K]).

get_PR41(*args, **kwargs)

calculates driver/driven gas pressure ratio (PR41 [], shock tube initial condition) from incident shock pressure ratio (PR21 []), driven section temperature (T1 [k]), and driver section temperature (T4 [K]) input: incident shock wave pressure ratio (PR21 [K]), driven section temperature (T1 [K]), driver section temperature (T4 [K]) example: PR41 = get_PR41(PR21=PR21, T1=T1, T4=T4)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

find_PR21_from_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

Deprecated since version 2.6: redirects to get_PR21_from_PR41()

property gas1: Gas

Driver gas (high-pressure chamber)

property gas2: Gas

Driven gas (low-pressure chamber)

get_PR21_from_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

finds incident shock pressure ratio (PR21 []) matching specified shock-tube pressure ratio (PR41 [], driver section pressure over driven section pressure), driver section temperature (T4 [K]), and driven section temperature (T1 [K]). the pressure ration is calculated using the built-in Newton-Raphson solver. input: driver pressure of driven pressure (PR41 []), driver section temperature (T4 [K]), driven section temperature (T1 [K]) example: PR21 = get_PR21_from_PR41(PR41=PR41, T4=T4, T1=T1)

get_PR41(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates driver/driven gas pressure ratio (PR41 [], shock tube initial condition) from incident shock pressure ratio (PR21 []), driven section temperature (T1 [k]), and driver section temperature (T4 [K]) input: incident shock wave pressure ratio (PR21 [K]), driven section temperature (T1 [K]), driver section temperature (T4 [K]) example: PR41 = get_PR41(PR21=PR21, T1=T1, T4=T4)

class g3d.calc.calculators.G3DStagnationCalculator(*args: Any, **kwargs: Any)[source]

Bases: G3DGenericCalculator

class collecting functions related to reference states stagnation parameters and critical (sonic) parameters

Attributes:
gas

Gas object

newton

Newton-Raphson solver

tag

tag (string) used for identification

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

get_Mach_from_total_density_ratio(*args, ...)

calculates Mach number (M []) from total-to-static density ratio (ROo / RO []) input: total density (ROo [kg/m^3]) and static density (RO [kg/m^3]) example: M = get_Mach_from_total_density_ratio(ROo=ROo, RO=RO)

get_Mach_from_total_pressure_ratio(*args, ...)

calculates Mach number (M []) from total-to-static pressure ratio (Po / P []) input: total pressure (Po [Pa]) and static pressure (P [Pa]) example: M = get_Mach_from_total_pressure_ratio(Po=Po, P=P)

get_Mach_from_total_temperature_ratio(*args, ...)

calculates Mach number (M []) from total-to-static temperature ratio (To / T []) input: total temperature (To [K]) and static temperature (T [K]) example: M = get_Mach_from_total_temperature_ratio(To=To, T=T)

get_critical_density(*args, **kwargs)

calculates critical density (ROs [kg/m^3]) from total density (ROo [kg/m^3]) input: total density (ROo [kg/m^3], default value: 1.0) example: ROs = get_critical_density(ROo=ROo)

get_critical_pressure(*args, **kwargs)

calculates critical pressure (Ps [Pa]) from total pressure (Po [Pa]) input: total pressure (Po [Pa], default value: 1.0) example: Ps = get_critical_pressure(Po=Po)

get_critical_temperature(*args, **kwargs)

calculates critical temperature (Ts [K]) from total temperature (To [K]) input: total temperature (To [K], default value: 1.0) example: Ts = get_critical_temperature(To=To)

get_static_density(*args, **kwargs)

calculates static density (RO [kg/m^3]) from Mach number (M []) and total density (ROo [kg/m^3]) input: Mach number (M []), total density (ROo [kg/m^3]) example: RO = get_static_density(M=M, ROo=ROo)

get_static_pressure(*args, **kwargs)

calculates static pressure (P [Pa]) from Mach number (M []) and total pressure (Po [Pa]) input: Mach number (M []), total pressure (Po [Pa]) example: P = get_static_pressure(M=M, Po=Po)

get_static_temperature(*args, **kwargs)

calculates static temperature (T [K]) from Mach number (M []) and total temperature (To [K]) input: Mach number (M []), total temperature (To [K]) example: T = get_static_temperature(M=M, To=To)

get_total_density(*args, **kwargs)

calculates total density (ROo [kg/m^3]) from Mach number (M []) and static density (RO [kg/m^3]) input: Mach number (M []), static density (RO [kg/m^3]) example: ROo = get_total_density(M=M, RO=RO)

get_total_pressure(*args, **kwargs)

calculates total pressure (Po [Pa]) from Mach number (M []) and static pressure (P [Pa]) input: Mach number (M []), static pressure (P [Pa]) example: Po = get_total_pressure(M=M, P=P)

get_total_temperature(*args, **kwargs)

calculates total temperature (To [K]) from Mach number (M []) and static temperature (T [K]) input: Mach number (M []), static temperature (T [K]) example: To = get_total_temperature(M=M, T=T)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Checks if provided key is in list of defined keys and updates calculator settings accordingly

get_Mach_from_total_density_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static density ratio (ROo / RO []) input: total density (ROo [kg/m^3]) and static density (RO [kg/m^3]) example: M = get_Mach_from_total_density_ratio(ROo=ROo, RO=RO)

get_Mach_from_total_pressure_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static pressure ratio (Po / P []) input: total pressure (Po [Pa]) and static pressure (P [Pa]) example: M = get_Mach_from_total_pressure_ratio(Po=Po, P=P)

get_Mach_from_total_temperature_ratio(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates Mach number (M []) from total-to-static temperature ratio (To / T []) input: total temperature (To [K]) and static temperature (T [K]) example: M = get_Mach_from_total_temperature_ratio(To=To, T=T)

get_critical_density(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical density (ROs [kg/m^3]) from total density (ROo [kg/m^3]) input: total density (ROo [kg/m^3], default value: 1.0) example: ROs = get_critical_density(ROo=ROo)

get_critical_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical pressure (Ps [Pa]) from total pressure (Po [Pa]) input: total pressure (Po [Pa], default value: 1.0) example: Ps = get_critical_pressure(Po=Po)

get_critical_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates critical temperature (Ts [K]) from total temperature (To [K]) input: total temperature (To [K], default value: 1.0) example: Ts = get_critical_temperature(To=To)

get_static_density(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static density (RO [kg/m^3]) from Mach number (M []) and total density (ROo [kg/m^3]) input: Mach number (M []), total density (ROo [kg/m^3]) example: RO = get_static_density(M=M, ROo=ROo)

get_static_pressure(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static pressure (P [Pa]) from Mach number (M []) and total pressure (Po [Pa]) input: Mach number (M []), total pressure (Po [Pa]) example: P = get_static_pressure(M=M, Po=Po)

get_static_temperature(*args: Any, **kwargs: Any) → float64 | list[float64] | float[source]

calculates static temperature (T [K]) from Mach number (M []) and total temperature (To [K]) input: Mach number (M []), total temperature (To [K]) example: T = get_static_temperature(M=M, To=To)

get_total_density(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total density (ROo [kg/m^3]) from Mach number (M []) and static density (RO [kg/m^3]) input: Mach number (M []), static density (RO [kg/m^3]) example: ROo = get_total_density(M=M, RO=RO)

get_total_pressure(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total pressure (Po [Pa]) from Mach number (M []) and static pressure (P [Pa]) input: Mach number (M []), static pressure (P [Pa]) example: Po = get_total_pressure(M=M, P=P)

get_total_temperature(*args: Any, **kwargs: Any) → tuple[Any, ...] | list[Any] | Any[source]

calculates total temperature (To [K]) from Mach number (M []) and static temperature (T [K]) input: Mach number (M []), static temperature (T [K]) example: To = get_total_temperature(M=M, T=T)

class g3d.calc.calculators.Q1DODESolver(*args: Any, **kwargs: Any)[source]

Bases: G3DCalculator

quasi-one-dimensional ODE solver handles cross-section area changes, heat addition, and friction

Attributes:
L

Pipe length (L [m])

dksi

Axial spacing between function evaluations

f_fun

Friction factor as a function of axial coordinate f(x) []

gas

Gas object

h

Axial spacing used for numerical differentiation (h [m], default value: 1.e-4)

newton

Newton-Raphson solver

p1

Initial pressure (p1 [Pa])

q_fun

Added heat as a function of axial coordinate q(x) [J/kg]

r

Cross-section radius (r [m], used unless function r_func is specified)

r_fun

Cross-section radius as a function of axial coordinate r(x) [m]

rho1

Initial density (rho1 [kg/m^3])

tag

tag (string) used for identification

u1

Initial velocity (u1 [m/s])

x1

Start coordinate (x1 [m], default value: 0.)

Methods

Newton_Raphson_solver(func, *args, **kwargs)

Runs Newton-Raphson solver on specified function

backup()

Backup of stored variables

copy(e)

copies data from specified entity input: entity example: copy(e)

header(*args, **kwargs)

prints a header with specified information input: info optional input: dashes (default='='), scrw (default=80), number of blank lines after dashes n_space (default=1) example: header(info='header info')

hline(*args, **kwargs)

prints horizontal line optional input (kwargs): dashes (default='-'), scrw (default=80) example: hline(dashes='*', scrw=90)

jobname_append(name)

extends jobname with the specified string input: name example: jobname_append(name)

newton_reset()

print()

Prints allocated variables

reset(*args, **kwargs)

Resets solver parameters to their default values

reset_newton()

Resets Newton-Raphson solver to its default state

restore()

Restore variable state from backup

set(*args, **kwargs)

sets code parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Set parameters from provided key => value input

solve(*args, **kwargs)

Q1D ODE solver for investigations of combined affects of area changes, heat addition, and friction input: functions describing area distribution (r_fun - r(x) [m]), heat addition (q(x) [J/kg]), and friction factor (f_fun - f(x) [], default value: None), initial conditions: axial position (x1 [m], default value: 0.), density (rho1 [kg/m^3], default value: 1.), velocity (u1 [m/s], default value: 0.), pressure (p1 [Pa], default value: 1.e5), axial increment per step (dksi [m], default value: 0.), pipe length (L [m], default value: 1.e20), delta (h [m], default value: 1.e-4) example: x, rho, u, p, T, M, A = solve(r_fun=r_fun, q_fun=q_fun, f_fun=f_fun, x1=x1, rho1=rho1, u1=u1, p1=p1, dksi=dksi, L=L, h=h)

property L: float

Pipe length (L [m])

property dksi: float

Axial spacing between function evaluations

property f_fun: Callable[[float], float]

Friction factor as a function of axial coordinate f(x) []

property h: float

1.e-4)

Type:

Axial spacing used for numerical differentiation (h [m], default value

property p1: float

Initial pressure (p1 [Pa])

property q_fun: Callable[[float], float]

Added heat as a function of axial coordinate q(x) [J/kg]

property r: float

Cross-section radius (r [m], used unless function r_func is specified)

property r_fun: Callable[[float], float]

Cross-section radius as a function of axial coordinate r(x) [m]

reset(*args: Any, **kwargs: Any) → None[source]

Resets solver parameters to their default values

property rho1: float

Initial density (rho1 [kg/m^3])

set_from_key_value(key: str, value: Any) → bool[source]

Set parameters from provided key => value input

solve(*args: Any, **kwargs: Any) → Tuple[ndarray, ...][source]

Q1D ODE solver for investigations of combined affects of area changes, heat addition, and friction input: functions describing area distribution (r_fun - r(x) [m]), heat addition (q(x) [J/kg]), and friction factor (f_fun - f(x) [], default value: None), initial conditions: axial position (x1 [m], default value: 0.), density (rho1 [kg/m^3], default value: 1.), velocity (u1 [m/s], default value: 0.), pressure (p1 [Pa], default value: 1.e5), axial increment per step (dksi [m], default value: 0.), pipe length (L [m], default value: 1.e20), delta (h [m], default value: 1.e-4) example: x, rho, u, p, T, M, A = solve(r_fun=r_fun, q_fun=q_fun, f_fun=f_fun, x1=x1, rho1=rho1, u1=u1, p1=p1, dksi=dksi, L=L, h=h)

property u1: float

Initial velocity (u1 [m/s])

property x1: float

0.)

Type:

Start coordinate (x1 [m], default value