Flight Condition
About
Airspeed conversions (true/calibrated/equivalent/Mach), atmospheric data, and
more with built-in unit checking. Specific sub-modules include:
flightcondition
: input altitude to compute common flight condition data.
Easily swap between true airspeed, calibrated airspeed, equivalent airspeed,
and Mach number. Includes atmospheric data.atmosphere
: input altitude to compute atmospheric
data. Many relevant, derived quantities are included. The upper limit is
86 km for the
1993 International Standard Atmosphere model and
10,000 kilometers for the NRL MSIS model.units
: built-in unit-checking and conversion using the
pint package.
See the web application here: https://flightcondition.streamlit.app
Author
Matthew C. Jones matt.c.jones.aoe@gmail.com
Installation
Install Commands
Install using the pip
package-management system. The
easiest method is to open the terminal and run:
pip install flightcondition
Alternatively, manually download the
source code, unpack, and run:
pip install <path/to/flightcondition>
Dependencies
- numpy: package for scientific computing.
- pint: package for dealing with units.
- pymsis: package for NRL MSIS
atmospheric model.
Usage
Import all utilities with,
from flightcondition import *
or more explicitly as shown in the following examples.
Flight Condition
The FlightCondition
class is used to compute and interact with common flight
condition data. Inputs include altitude, velocity in some format, and an
optional length scale.
Input Arguments
Input arguments include:
- Altitude:
h
(aliases include: alt
, altitude
) - Velocity (pick one):
- True airspeed:
TAS
(aliases include: tas
, true_airspeed
,
U_inf
, V_inf
) - Calibrated airspeed:
CAS
(aliases include: cas
,
calibrated_airspeed
) - Equivalent airspeed:
EAS
(aliases include: eas
,
equivalent_airspeed
) - Mach number:
M
(aliases include: mach
, Mach
, M_inf
,
mach_number
)
- Length-scale (optional):
L
(aliases include: ell
, bylen
,
length
, length_scale
, l
)
Input quantities must be dimensionalized - see the usage below. Alternatively
use KTAS
, KCAS
, or KEAS
for convenience. For example, KCAS=233
is equivalent to CAS=233*unit('knots')
.
Output Quantities
The following tables list the quantities and the variables used to access them.
Quantities may be accessed by either (a) their abbreviated variable, e.g.
.TAS
, or (b) by their full names, e.g. byname.true_airspeed
. They
may also be accessed through their particular sub-category: byalt
, byvel
,
or bylen
, e.g. .byvel.TAS
or .byvel.byname.true_airspeed
.
Altitude Quantity | Variable | Full Name (via .byname. ) |
---|
Geometric altitude | h | geometric_altitude |
Geopotential altitude | H | geopotential_altitude |
Pressure | p | pressure |
Temperature | T | temperature |
Density | rho | density |
Sound speed | a | sounds_speed |
Dynamic viscosity | mu | dynamic_viscosity |
Kinematic viscosity | nu | kinematic_viscosity |
Thermal conductivity | k | thermal_conductivity |
Gravity | g | gravity |
Mean free path | MFP | mean_free_path |
Velocity Quantity | Name | Full Name (via .byname. ) |
---|
True airspeed (TAS) | TAS | true_airspeed |
Calibrated airspeed (CAS) | CAS | calibrated_airspeed |
Equivalent airspeed (EAS) | EAS | equivalent_airspeed |
Mach number | M | mach_number |
Mach angle | mu_M | mach_angle |
Dynamic pressure | q_inf | dynamic_pressure |
Impact pressure | q_c | impact_pressure |
Stagnation pressure | p0 | stagnation_pressure |
Stagnation temperature | T0 | stagnation_temperature |
Recovery temperature (laminar) | Tr_lamr | recovery_temperature_laminar |
Recovery temperature (turbulent) | Tr_turb | recovery_temperature_turbulent |
Reynolds number per unit length | Re_by_L | recovery_temperature_turbulent |
Length-Scale Quantity | Name | Full Name (via .byname. ) |
---|
Length scale | L | length_scale |
Reynolds number | Re | reynolds_number |
Boundary layer thickness (laminar) | h_BL_lamr | boundary_thickness_laminar |
Boundary layer thickness (turbulent) | h_BL_turb | boundary_thickness_turbulent |
Flat plate skin friction coefficient (laminar) | Cf_lamr | friction_coefficient_laminar |
Flat plate skin friction coefficient (turbulent) | Cf_turb | friction_coefficient_turbulent |
Example Usage
from flightcondition import FlightCondition, unit
fc = FlightCondition(h=3*unit('km'), M=0.5)
KTAS = fc.TAS.to('knots')
KCAS = fc.CAS.to('knots')
KEAS = fc.EAS.to('knots')
print(f"Flying at {KTAS.magnitude:.4g} KTAS,"
f" which is {KCAS.magnitude:.4g} KCAS,"
f" or {KEAS.magnitude:.4g} KEAS")
h, p, T, rho, nu, a = fc.h, fc.p, fc.T, fc.rho, fc.nu, fc.a
print(f"The ambient temperature at {h.to('km'):.4g} is {T:.4g}")
fc.EAS = 300 * unit('knots')
fc.h = 12 * unit('kft')
fc = FlightCondition(h=[0, 9.8425, 20]*unit('kft'),
EAS=275.14*unit('kt'),
L=10*unit('m'))
print(f"\nThe dynamic pressure in psi is {fc.q_inf.to('psi'):.3g}")
print(f"The Reynolds number is {fc.Re:.3g}")
h_yplus100 = fc.wall_distance_from_yplus(100)
print(f"The wall distance where y+=100 is {h_yplus100.to('in'):.3g}")
print(fc.TAS == fc.byname.true_airspeed)
print(fc.byvel.TAS == fc.byvel.byname.true_airspeed)
Atmosphere
The Atmosphere
class can be used to compute and interact with common standard
atmosphere data and derived quantities. See the list of output quantities in
the FlightCondition
documentation above.
See also layer
for layer properties such as layer.name
for the layer name.
Note that all Atmosphere
properties can be accessed through the
FlightCondition
class, however, this class stands on its own if the
additional velocity and length-scale quantities are not desired.
Input Arguments
The input argument is geometric altitude h
. Aliases include alt
and
altitude
. Note that these geometric altitude must be input as dimensional
length quantities - see the usage below. Alternatively input
un-dimensionalized numbers using h_kft
or h_km
for kilofeet and kilometers
respectively.
Example Usage
from flightcondition import Atmosphere, unit
h = [0.0, 44.2, 81.0] * unit('km')
atm = Atmosphere(h)
p, T, rho, nu, a, k = atm.p, atm.T, atm.rho, atm.nu, atm.a, atm.k
print(f"\nThe pressure in psi is {p.to('psi'):.3g}")
print( f"\nThe mean free path = {atm.MFP:.3g}")
Units
Conveniently input, output, and convert units using
pint units.
from flightcondition import unit, printv
h = 33 * unit('km')
print(h.to('kft'))
printv(h, to='kft')
U_inf = 20 * unit('knots')
rho_inf = 1.225 * unit('kg/m^3')
q_inf = 0.5*rho_inf*U_inf**2
printv(q_inf, to='psi')
Note that pint does not support conflicting unit
registries so avoid interactions between flightcondition.unit
and a separate
pint.UnitRegistry
.
Command Line Interface
A command line interface (CLI) is included for convenience but with limited
functionality. Run flightcondition -h
for help.
An example call is given for the flight condition of 233
knots-equivalent-airspeed at 23 kilofeet with a length scale of 4 feet and
abbreviated output:
flightcondition --h 23 kft --EAS 233 knots --L 4 ft --no-full-output
===========================================================
Flight Condition (units=US, full_output=False)
===========================================================
------------------ Altitude Quantities ------------------
geometric_altitude h = 23 kft
pressure p = 857.25 lbf/ft²
temperature T = 436.74 °R
density rho = 1.1435×10⁻³ slug/ft³
sound_speed a = 1024.5 ft/s
kinematic_viscosity nu = 2.8509×10⁻⁴ ft²/s
------------------ Velocity Quantities ------------------
mach_number M = 0.55344
true_airspeed TAS = 335.93 kt
calibrated_airspeed CAS = 238.14 kt
equivalent_airspeed EAS = 233 kt
reynolds_per_length Re_by_L = 1.6573×10⁵ 1/in
------------------ Length Quantities ------------------
length_scale L = 4 ft
reynolds_number Re = 7.9551×10⁶
Alternatively use the --KEAS 233
syntactic sugar to omit the knots
unit.
See also --KTAS
and --KCAS
.
Web Application
See the web application here: https://flightcondition.streamlit.app
Assumptions
- When using
model=standard
, Atmospheric quantities follow the
1993 International Standard Atmosphere model. - When using
model=msis
, atmospheric quantities follow the NRL MSIS model.
Note that model=msis
is automatically enabled for altitudes higher than
80 kilometers. - Velocity computations include varying degrees of the following assumptions.
Note that several assumptions break down for hypersonic flow.
- Continuum flow (mean free path is much smaller than the characteristic
length scale)
- Ideal gas
- Thermally perfect gas
- Calorically perfect gas
- Adiabatic
- Reversible (
CAS
, q_c
, p_0
)
Unit Testing
flightcondition
is maintained using unit tests to maintain functionality and
accuracy. Even so, see the Disclaimer below.
License
flightcondition
is licensed under the MIT LICENSE. See the
LICENSE
document.
Disclaimer
The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. In no event shall the
authors or copyright holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the software or the use or other dealings in the
software.