atmosphere Module
Contains the following atmospheric functions:
density = atm_density(alt, mach)
mach = atm_mach(alt, velocity)
velocity = atm_velocity(alt, mach)
pressure = atm_pressure(alt)
temperature = atm_temperature(alt)
sos = atm_speed_of_sound(alt)
mu = atm_dynamic_viscosity_mu(alt)
nu = atm_kinematic_viscosity_nu(alt)
eas = atm_equivalent_airspeed(alt, mach)
- rho, machs, velocity = make_flfacts_alt_sweep_constant_mach(
mach, alts, eas_limit=1000., alt_units=’m’, velocity_units=’m/s’, density_units=’kg/m^3’, eas_units=’m/s’)
- rho, machs, velocity = make_flfacts_mach_sweep_constant_alt(
alt, machs, eas_limit=1000., alt_units=’m’, velocity_units=’m/s’, density_units=’kg/m^3’, eas_units=’m/s’)
All the default units are in English units because the source equations are in English units.
- pyNastran.utils.atmosphere.atm_calibrated_airspeed(alt: float, mach: float, alt_units: str = 'ft', cas_units: str = 'ft/s') float[source]
Calibrated airspeed
- Parameters:
- altfloat
altitude in alt_units
- machfloat
Mach Number
- $ M
- $
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- cas_unitsstr; default=’ft/s’
the calibrated airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- Returns:
- casfloat
Calibrated airspeed in cas_units
- https://aerotoolbox.com/airspeed-conversions/
- pyNastran.utils.atmosphere.atm_density(alt: float, R: float = 1716.0, alt_units: str = 'ft', density_units: str = 'slug/ft^3') float[source]
Freestream Density f$ rho_{infty} f$
- Parameters:
- altfloat
altitude in feet or meters
- Rfloat; default=1716.
gas constant for air in english units (???)
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- density_unitsstr; default=’slug/ft^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- Returns:
- rhofloat
density f$ rho f$ in density_units
- Based on the formula P=pRT
- f[ large rho=frac{p}{R T} f]
- pyNastran.utils.atmosphere.atm_dynamic_pressure(alt: float, mach: float, alt_units: str = 'ft', pressure_units: str = 'psf') float[source]
Freestream Dynamic Pressure f$ q_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- machfloat
Mach Number f$ M f$
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- pressure_unitsstr; default=’psf’
the pressure units; psf, psi, Pa, kPa, MPa
- Returns:
- dynamic_pressurefloat
Returns dynamic pressure in pressure_units
- The common method that requires many calculations…
- f[ large q = frac{1}{2} rho V^2 f]
- f[ large p = rho R T f]
- f[ large M = frac{V}{a} f]
- f[ large a = sqrt{gamma R T} f]
- so…
- f[ large q = frac{gamma}{2} p M^2 f]
- pyNastran.utils.atmosphere.atm_dynamic_viscosity_mu(alt: float, alt_units: str = 'ft', visc_units: str = '(lbf*s)/ft^2') float[source]
Freestream Dynamic Viscosity f$ mu_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- visc_unitsstr; default=’(lbf*s)/ft^2’
the viscosity units; (lbf*s)/ft^2, (N*s)/m^2, Pa*s, psf*s
- Returns:
- mufloat
dynamic viscosity f$ mu_{infty} f$ in (lbf*s)/ft^2 or (N*s)/m^2 (SI)
See also
sutherland_viscoscity ..
- pyNastran.utils.atmosphere.atm_equivalent_airspeed(alt: float, mach: float, alt_units: str = 'ft', eas_units: str = 'ft/s') float[source]
Freestream equivalent airspeed
- Parameters:
- altfloat
altitude in alt_units
- machfloat
Mach Number
- $ M
- $
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- eas_unitsstr; default=’ft/s’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- Returns:
- easfloat
equivalent airspeed in eas_units
- EAS = TAS * sqrt(rho/rho0)
- p = rho * R * T
- rho = p/(RT)
- rho/rho0 = p/T * T0/p0
- TAS = a * M
- EAS = a * M * sqrt(p/T * T0/p0)
- EAS = a * M * sqrt(p*T0 / (T*p0))
- pyNastran.utils.atmosphere.atm_kinematic_viscosity_nu(alt: float, alt_units: str = 'ft', visc_units: str = 'ft^2/s') float[source]
Freestream Kinematic Viscosity f$ nu_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- visc_unitsstr; default=’slug/ft^3’
the kinematic viscosity units; ft^2/s, m^2/s
- Returns:
- nufloat
kinematic viscosity f$ nu_{infty} f$ in visc_units
- f[ large nu = frac{mu}{rho} f]
See also
sutherland_viscoscity ..
Todo
better debug ..
- pyNastran.utils.atmosphere.atm_mach(alt: float, V: float, alt_units: str = 'ft', velocity_units: str = 'ft/s') float[source]
Freestream Mach Number
- Parameters:
- altfloat
altitude in alt_units
- Vfloat
Velocity in velocity_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’ft/s’
the velocity units; ft/s, in/s, knots, m/s, cm/s, mm/s
- Returns:
- machfloat
Mach Number f$ M f$
- f[ large M = frac{V}{a} f]
- pyNastran.utils.atmosphere.atm_pressure(alt: float, alt_units: str = 'ft', pressure_units: str = 'psf') float[source]
Freestream Pressure f$ p_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- pressure_unitsstr; default=’psf’
the pressure units; psf, psi, Pa, kPa, MPa
- Returns:
- pressurefloat
Returns pressure in pressure_units
Note
from BAC-7006-3352-001-V1.pdf # Bell Handbook of Aerodynamic Heatingn page ~236 - Table C.1n These equations were used b/c they are valid to 300k ft.n Extrapolation is performed above that.n
- pyNastran.utils.atmosphere.atm_speed_of_sound(alt: float, alt_units: str = 'ft', velocity_units: str = 'ft/s', gamma: float = 1.4) float[source]
Freestream Speed of Sound f$ a_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’ft/s’
the velocity units; ft/s, m/s, in/s, knots
- gamma: float; default=1.4
the specific heat ratio Cp/Cv; gamma=1.4 for air
- Returns:
- speed_of_sound, afloat
Returns speed of sound in velocity_units
- f[ large a = sqrt{gamma R T} f]
- pyNastran.utils.atmosphere.atm_temperature(alt: float, alt_units: str = 'ft', temperature_units: str = 'R') float[source]
Freestream Temperature f$ T_{infty} f$
- Parameters:
- altfloat
Altitude in alt_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- temperature_unitsstr; default=’R’
the altitude units; R, K
- Returns:
- Tfloat
temperature in degrees Rankine or Kelvin (SI)
Note
from BAC-7006-3352-001-V1.pdf # Bell Handbook of Aerodynamic Heatingn page ~236 - Table C.1n These equations were used because they are valid to 300k ft.n Extrapolation is performed above that.
- pyNastran.utils.atmosphere.atm_unit_reynolds_number(alt: float, mach: float, alt_units: str = 'ft', reynolds_units: str = '1/ft') float[source]
Returns the Reynolds Number per unit length.
- Parameters:
- altfloat
Altitude in alt_units
- machfloat
Mach Number f$ M f$
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- reynolds_unitsstr; default=’1/ft’
the altitude units; 1/ft, 1/m, 1/in
- Returns:
- ReynoldsNumber/Lfloat
the Reynolds Number per unit length
- f[ large Re_L = frac{ rho V}{mu} = frac{p M a}{mu R T} f]
Note
this version of Reynolds number directly calculates the base quantities, so multiple calls to atm_press and atm_temp are not made
- pyNastran.utils.atmosphere.atm_velocity(alt: float, mach: float, alt_units: str = 'ft', velocity_units: str = 'ft/s') float[source]
Freestream Velocity f$ V_{infty} f$
- Parameters:
- altfloat
altitude in alt_units
- machfloat
Mach Number f$ M f$
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’ft/s’
the velocity units; ft/s, m/s, in/s, knots
- Returns:
- velocityfloat
Returns velocity in velocity_units
- f[ large V = M a f]
- pyNastran.utils.atmosphere.cas_to_mach(alt: float, vcas: float, alt_units: str = 'ft', cas_units: str = 'ft/s')[source]
Get Mach Number from calibrated airspeed
- Parameters:
- altfloat
Altitude in alt_units
- vcasfloat
Calibrated airspeed in cas_units
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- cas_unitsstr; default=’ft/s’
the calibrated airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- Returns:
- altfloat
Altitude in alt_units
- cas = a0 * mach_comp
- mach_comp = vcas/a0
- mach_comp = np.sqrt(5 * ((qc/p0+1)**(1/3.5) - 1))
- qc = p0 * ((1 + 0.2*mach_comp**2)**3.5 - 1)
- qc = p * ((1 + 0.2*mach**2)**3.5 - 1)
- mach = sqrt(5 * ((qc/p+1)**(1/3.5) - 1))
- pyNastran.utils.atmosphere.constant_alt_line_alt_mach(alt: float, mach0: float, mach1: ndarray, num: int = 20, alt_units: str = 'ft', eas_units: str = 'knots') None[source]
creates a constant altitude line between two mach numbers
- pyNastran.utils.atmosphere.constant_mach_line_alt1_alt2(mach: float, alt0: float, alt1: ndarray, num: int = 20, alt_units: str = 'ft', eas_units: str = 'knots') tuple[ndarray, ndarray, ndarray][source]
creates a constant mach line between two altitutdes
- pyNastran.utils.atmosphere.create_atmosphere_table(quantities: list[str], mach: float, alt_min: float, alt_max: float, nalt: int = 0, dalt: float = 0.0, alt_units: str = 'ft', density_units: str = 'slug/ft^3', pressure_units: str = 'psf', temperature_units: str = 'R', velocity_units: str = 'ft/s', dynamic_viscosity_units: str = '(lbf*s)/ft^2') array[source]
- Parameters:
- quantities list[str]
- alt_minfloat
- alt_maxfloat
- naltint
- daltfloat
- alt_unitsstr; default=’m’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’m/s’
the velocity units; ft/s, m/s, in/s, knots
- density_unitsstr; default=’kg/m^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- pressure_unitsstr; default=’psf’
the pressure units; psf, psi, Pa, kPa, MPa
- temperature_unitsstr; default=’R’
the altitude units; R, K
- dynamic_viscosity_unitsstr; default=’(lbf*s)/ft^2’
the dynamic viscosity, mu; (lbf*s)/ft^2, (N*s)/m^2, Pa*s, psf*s
- out = create_atmosphere_table(
quantities, mach, alt_min=0, alt_max=10000, dalt=1000.)
- out[:, 0] # alt
- [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
- pyNastran.utils.atmosphere.eas_from_alts_machs(alts: list[float] | ndarray, machs: list[float] | ndarray, alt_units: str = 'ft', eas_units: str = 'knots') ndarray[source]
- pyNastran.utils.atmosphere.get_alt_for_density(density: float, density_units: str = 'slug/ft^3', alt0: float = 0.0, alt_units: str = 'ft', nmax: int = 20, tol: float = 0.1) float[source]
Gets the altitude associated with a given air density.
- Parameters:
- densityfloat
the air density in slug/ft^3
- density_unitsstr; default=’slug/ft^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- alt_unitsstr; default=’ft’
sets the units for the output altitude; ft, m, kft
- nmaxint; default=20
max number of iterations for convergence
- tolfloat; default=0.1
tolerance in alt_units
- Returns:
- altfloat
the altitude in feet
- pyNastran.utils.atmosphere.get_alt_for_eas_with_constant_mach(equivalent_airspeed: float, mach: float, velocity_units: str = 'ft/s', alt_units: str = 'ft', nmax: int = 20, tol: float = 0.1) float[source]
Gets the altitude associated with an equivalent airspeed.
- Parameters:
- equivalent_airspeedfloat
the equivalent airspeed in velocity_units
- machfloat
the mach to hold constant
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- velocity_unitsstr; default=ft/s
the velocity units; ft/s, m/s, in/s, knots
- nmaxint; default=20
max number of iterations for convergence
- tolfloat; default=5.
tolerance in alt_units
- Returns:
- altfloat
the altitude in alt units
- pyNastran.utils.atmosphere.get_alt_for_mach_eas(mach: float, eas: float, eas_units: str = 'knots', alt_units: str = 'ft', nmax: int = 20, tol: float = 0.1) float[source]
Gets the altitude associated with an equivalent airspeed.
- Parameters:
- machfloat
the Mach number
- easfloat
the equivalent airspeed in eas_units
- eas_unitsstr; default=’knots’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- nmaxint; default=20
max number of iterations for convergence
- tolfloat; default=0.1
altitude tolerance in alt_units
- Returns:
- altfloat
the altitude in alt_units
- pyNastran.utils.atmosphere.get_alt_for_pressure(pressure: float, pressure_units: str = 'psf', alt_units: str = 'ft', nmax: int = 20, tol: float = 0.1) float[source]
Gets the altitude associated with a pressure.
- Parameters:
- pressurefloat
the pressure lb/ft^2 (SI=Pa)
- pressure_unitsstr; default=’psf’
the pressure units; psf, psi, Pa, kPa, MPa
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- nmaxint; default=20
max number of iterations for convergence
- tolfloat; default=0.1
altitude tolerance in alt_units
- Returns:
- altfloat
the altitude in alt_units
- pyNastran.utils.atmosphere.get_alt_for_q_with_constant_mach(q: float, mach: float, pressure_units: str = 'psf', alt_units: str = 'ft', nmax: int = 20, tol: float = 0.1) float[source]
Gets the altitude associated with a dynamic pressure.
- Parameters:
- qfloat
the dynamic pressure lb/ft^2 (SI=Pa)
- machfloat
the mach to hold constant
- pressure_unitsstr; default=’psf’
the pressure units; psf, psi, Pa, kPa, MPa
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- nmaxint; default=20
max number of iterations for convergence
- tolfloat; default=0.1
tolerance in alt_units
- Returns:
- altfloat
the altitude in alt_units
- pyNastran.utils.atmosphere.get_mach_for_alt_eas(alt: float, eas: float, eas_units: str = 'knots', alt_units: str = 'ft', gamma: float = 1.4) float[source]
Gets the altitude associated with an equivalent airspeed.
- Parameters:
- altfloat
the altitude in alt_units
- easfloat
the equivalent airspeed in eas_units
- eas_unitsstr; default=’knots’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- alt_unitsstr; default=’ft’
the altitude units; ft, kft, m
- gammafloat; default=1.4
gas constant
- Returns:
- altfloat
the altitude in alt_units
- pyNastran.utils.atmosphere.make_flfacts_alt_sweep_constant_mach(mach: float, alts: np.ndarray, eas_limit: float = 1000.0, alt_units: str = 'm', velocity_units: str = 'm/s', density_units: str = 'kg/m^3', eas_units: str = 'm/s') tuple[NDArrayNfloat, NDArrayNfloat, NDArrayNfloat][source]
Makes a sweep across altitude for a constant Mach number.
- Parameters:
- machfloat
Mach Number
- $ M
- $
- altslist[float]
Altitude in alt_units
- eas_limitfloat
Equivalent airspeed limiter in eas_units
- alt_unitsstr; default=’m’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’m/s’
the velocity units; ft/s, in/s, knots, m/s, cm/s, mm/s
- density_unitsstr; default=’kg/m^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- eas_unitsstr; default=’m/s’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- pyNastran.utils.atmosphere.make_flfacts_alt_sweep_constant_tas(tas: float, alts: ndarray, alt_units: str = 'm', velocity_units: str = 'm/s', density_units: str = 'kg/m^3', eas_limit: float = 1000.0, eas_units: str = 'm/s') tuple[ndarray, ndarray, ndarray][source]
Veas = Vtas * sqrt(rho/rho0) Vtas = Veas * sqrt(rho0/rho) Vtas = sos * Mach Mach = Vtas / sos = Veas/sos * sqrt(rho0/rho)
- pyNastran.utils.atmosphere.make_flfacts_eas_sweep_constant_alt(alt: float, eass: list[float], eas_min: float = 0.0, alt_units: str = 'm', velocity_units: str = 'm/s', density_units: str = 'kg/m^3', eas_units: str = 'm/s') tuple[NDArrayNfloat, NDArrayNfloat, NDArrayNfloat][source]
Makes a sweep across equivalent airspeed for a constant altitude.
- Parameters:
- altfloat
Altitude in alt_units
- easslist[float]
Equivalent airspeed in eas_units
- alt_unitsstr; default=’m’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’m/s’
the velocity units; ft/s, in/s, knots, m/s, cm/s, mm/s
- density_unitsstr; default=’kg/m^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- eas_unitsstr; default=’m/s’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- pyNastran.utils.atmosphere.make_flfacts_eas_sweep_constant_mach(mach: float, eass: np.ndarray, gamma: float = 1.4, minus_eas: list[float] | None = None, alt_units: str = 'ft', velocity_units: str = 'ft/s', density_units: str = 'slug/ft^3', eas_units: str = 'knots') tuple[NDArrayNfloat, NDArrayNfloat, NDArrayNfloat, NDArrayNfloat][source]
Makes a sweep across equivalent airspeed for a constant altitude.
- Parameters:
- machfloat
Constant mach number
- easslist[float]
Equivalent airspeed in eas_units
- alt_unitsstr; default=’m’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’m/s’
the velocity units; ft/s, m/s, in/s, knots
- density_unitsstr; default=’kg/m^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- eas_unitsstr; default=’m/s’
the equivalent airspeed units; ft/s, m/s, in/s, knots
- gammafloat; default=1.4
the gas constant
- minus_easfloat; default=0.0
tag the velocity with a -1
- Veas = Vtas * sqrt(rho/rho0)
- a * mach = Vtas
- a = sqrt(gamma*R*T)
- p = rho*R*T -> rho = p/(R*T)
- Vtas = Veas * sqrt(rho0 / rho)
- Veas = mach * sqrt(gamma*R*T) * sqrt(p/(R*T*rho0))
- Veas = mach * sqrt(gamma*p / rho0)
- Veas^2 / mach^2 = gamma * p / rho0
- p = Veas^2 / mach^2 * rho0/gamma
- pyNastran.utils.atmosphere.make_flfacts_mach_sweep_constant_alt(alt: float, machs: list[float], eas_limit: float = 1000.0, eas_min: float = 0.0, alt_units: str = 'm', velocity_units: str = 'm/s', density_units: str = 'kg/m^3', eas_units: str = 'm/s') tuple[NDArrayNfloat, NDArrayNfloat, NDArrayNfloat][source]
Makes a sweep across Mach number for a constant altitude.
- Parameters:
- altfloat
Altitude in alt_units
- machslist[float]
Mach Number
- $ M
- $
- eas_limitfloat
Equivalent airspeed limiter in eas_units
- alt_unitsstr; default=’m’
the altitude units; ft, kft, m
- velocity_unitsstr; default=’m/s’
the velocity units; ft/s, in/s, knots, m/s, cm/s, mm/s
- density_unitsstr; default=’kg/m^3’
the density units; slug/ft^3, slinch/in^3, kg/m^3, g/cm^3, Mg/mm^3
- eas_unitsstr; default=’m/s’
the equivalent airspeed units; ft/s, in/s, knots, m/s, cm/s, mm/s
- pyNastran.utils.atmosphere.make_flfacts_tas_sweep_constant_alt(alt: float, tass: ndarray, eas_limit: float = 1000.0, alt_units: str = 'm', velocity_units: str = 'm/s', density_units: str = 'kg/m^3', eas_units: str = 'm/s') tuple[ndarray, ndarray, ndarray][source]
TODO: not validated
- pyNastran.utils.atmosphere.sutherland_viscoscity(T: float) float[source]
Helper function that calculates the dynamic viscosity f$ mu f$ of air at a given temperature.
- Parameters:
- Tfloat
Temperature T is in Rankine
- Returns:
- mufloat
dynamic viscosity f$ mu f$ of air in (lbf*s)/ft^2
Note
prints a warning if T>5400 deg R
- Sutherland’s Equationn
- From Aerodynamics for Engineers 4th Editionn
- John J. Bertin 2002n
- page 6 eq 1.5bn