units.py

This module provides a data type that represents a physical quantity together with its unit. It is possible to add and subtract these quantities if the units are compatible and a quantity can be converted to another compatible unit. Multiplication, subtraction, and raising to integer powers are allowed without restriction, and the result will have the correct unit. A quantity can be raised to a non-integer power only if the result can be represented by integer powers of the base units.

The module provides a basic set of predefined physical quantities in its built-in library; however, it also supports generation of personal libararies which can be saved and reused.

This module is based on the PhysicalQuantities module in Scientific Python, by Konrad Hinsen. Modifications by Justin Gray.

openmdao.units.units.get_conversion_tuple(src_units, target_units)[source]

Return the factor and offset between the 2 compatible units.

Args:

value : float

Quantity you would like to convert.

src_units : string

Valid unit string that declares the source units.

target_units : string

Valid unit string that declares the target units.

Returns:

tuple(float, float) : Tuple containing the conversion factor and offset.

openmdao.units.units.convert_units(value, units, convunits)[source]

Return the given value (given in units) converted to convunits.

Args:

value : float

Quantity you would like to convert.

units : string

Valid unit string that declares the source units.

convunits : string

Valid unit string that declares the target units.

Returns:

float : Converted quantity.