Skip to content
Snippets Groups Projects

readable function names

Merged Malte Nyhuis requested to merge function_names into master
4 files
+ 43
76
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 13
37
@@ -3,42 +3,42 @@ import numpy as np
from ntrfc.fluid.fluid import mach_number, total_pressure
def p_t_is_from_mach(kappa, mach_number, static_pressure):
def total_pressure_from_mach_number(kappa, mach_number, static_pressure):
# Calculates total pressure in isentropic flow
# Source: https://www.grc.nasa.gov/www/BGH/isentrop.html
total_pressure = static_pressure * pow(1.0 + (kappa - 1.0) / 2.0 * pow(mach_number, 2.0), (kappa / (kappa - 1.0)))
return total_pressure
def p_is_from_mach(kappa, ma, p_t_is):
def static_pressure_from_mach_number(kappa, ma, p_t_is):
# Calculates static pressure in isentropic flow
# Source: https://www.grc.nasa.gov/www/BGH/isentrop.html
p_is = p_t_is / pow(1.0 + (kappa - 1.0) / 2.0 * pow(ma, 2.0), (kappa / (kappa - 1.0)))
return p_is
def temp_t_is(kappa, ma, T):
def total_temperature_from_mach_number(kappa, ma, T):
# Calculates total temperature in isentropic flow
# Source: https://www.grc.nasa.gov/www/BGH/isentrop.html
T_t_is = T / (((1.0 + (kappa - 1.0) * 0.5 * ma ** 2.0)) ** (-1.0))
return T_t_is
def temp_is(kappa, ma, Tt):
def static_temperature_from_mach_number(kappa, ma, Tt):
# Calculates static temperature in isentropic flow
# Source: https://www.grc.nasa.gov/www/BGH/isentrop.html
T = Tt / (1 + ((kappa - 1) / 2.0) * ma ** 2)
return T
def mach_is_x(kappa, p_blade, p_frestream):
def local_isentropic_mach_number(kappa, p_blade, p_frestream):
# Calculates local isentropic Mach number
y = np.sqrt(2 / (kappa - 1) * ((p_frestream / p_blade) ** ((kappa - 1) / kappa) - 1))
return y
def isentropic_mach_number(isentropic_pressure, kappa, static_pressure, mach, gas_constant, static_temperature):
def calculate_isentropic_mach_number(isentropic_pressure, kappa, static_pressure, mach, gas_constant, static_temperature):
"""
Calculates the isentropic Mach number.
@@ -55,8 +55,8 @@ def isentropic_mach_number(isentropic_pressure, kappa, static_pressure, mach, ga
"""
# Calculate the total pressure
total_pressure = p_t_is_from_mach(kappa, mach_number(mach, kappa, gas_constant, static_temperature),
static_pressure)
total_pressure = total_pressure_from_mach_number(kappa, mach_number(mach, kappa, gas_constant, static_temperature),
static_pressure)
# Calculate the dynamic pressure
dynamic_pressure = total_pressure - isentropic_pressure
@@ -68,34 +68,10 @@ def isentropic_mach_number(isentropic_pressure, kappa, static_pressure, mach, ga
return isentropic_mach_number
def ma_is(outflow_static_pressure, isentropic_exponent, pressure, velocity, gas_constant, temperature):
"""
Calculate the isentropic Mach number at the outflow of a system.
Parameters:
outflow_static_pressure (float): static pressure at the outflow (Pa)
isentropic_exponent (float): isentropic exponent of the gas
pressure (float): pressure at a reference point in the flow (Pa)
density (float): density at the reference point (kg/m^3)
velocity (float): velocity at the reference point (m/s)
gas_constant (float): gas constant of the gas (J/kg*K)
temperature (float): temperature at the reference point (K)
Returns:
float: isentropic Mach number at the outflow
"""
reference_point_total_pressure = total_pressure(isentropic_exponent,
mach_number(velocity, isentropic_exponent, gas_constant,
temperature), pressure)
q2th = reference_point_total_pressure - outflow_static_pressure
isentropic_mach_number = np.sqrt(2.0 / (isentropic_exponent - 1.0) * (
pow(1.0 + (q2th / outflow_static_pressure), (isentropic_exponent - 1.0) / isentropic_exponent) - 1.0))
return isentropic_mach_number
def isentropic_reynolds_number(kappa, specific_gas_constant, chord_length, sutherland_reference_viscosity,
mach_number, pressure, temperature,
sutherland_reference_temperature):
def calculate_isentropic_reynolds_number(kappa, specific_gas_constant, chord_length, sutherland_reference_viscosity,
mach_number, pressure, temperature,
sutherland_reference_temperature):
"""
Calculates the isentropic Reynolds number at a point in a gas flow.
@@ -114,14 +90,14 @@ def isentropic_reynolds_number(kappa, specific_gas_constant, chord_length, suthe
Returns:
- the isentropic Reynolds number at the point
"""
total_temperature = isentropic_total_temperature(kappa, mach_number, temperature)
total_temperature = calculate_isentropic_total_temperature(kappa, mach_number, temperature)
iso_temperature = total_temperature / (1 + (kappa - 1) / 2 * mach_number ** 2)
y = (kappa / specific_gas_constant) ** 0.5 * chord_length / sutherland_reference_viscosity * (
mach_number * pressure * (iso_temperature + sutherland_reference_temperature) / iso_temperature ** 2)
return y
def isentropic_total_temperature(kappa, mach_number, temperature):
def calculate_isentropic_total_temperature(kappa, mach_number, temperature):
"""
Calculates the isentropic total temperature at a point in a gas.
Loading