cape.units
: Unit Conversion Module¶
CAPE includes this unit-conversion module to interpret various units for inputs and post-processing. Many CFD solvers, and some trajectory tools that are used to provide flight conditions, expect imperial units, which can be challenging to interpret and difficult to use in complications.
The main function of this module is called mks()
, which takes a
string as input and tries to convert it to a numerical output as
multiple of meters, kilograms, and seconds (and Kelvins and amperes or
several other fundamental units as needed). For example it will return
0.0254 if the input is "inch"
, which is the length of an inch in
meters.
>>> mks("inch") 0.0254
This function also takes more complexly defined units using exponents, multiples and ratios, and SI prefixes. For example, this converts thousand pounds per square foot to the appropriate mks unit, which is Pascals.
>>> mks("klbf/ft^2") 4.7880e+04
The module also contains several simple float
values, such as
psf for the value of pounds per square feet in Pascals. There is a
dict
called units_dict that contains a full dictionary of
recognized unit names.
>>> units_dict['psf'] 47.88025903135141
- cape.units.mks(unit_lbl)¶
Convert a string for arbitrary nits to numerical MKS value
- Call:
>>> val = mks(unit_lbl)
- Examples:
>>> mks("kg") 1.0 >>> mks("lbf/ft^2") 47.880
- Inputs:
- unit_lbl:
str
|unicode
String describing units
- unit_lbl:
- Outputs:
- val:
float
Units converted to numerical value assuming MKS system
- val:
- Versions:
2018-04-12
@dalle
: Version 1.0