Unit conversion utility.
Provides functions for converting dimensional values from a given unit system. The main use is for converting values specified in input files to Cantera's native unit system, which is SI units except for the use of kmol as the base unit of quantity, that is, kilogram, meter, second, kelvin, ampere, and kmol.
String representations of units can be written using multiplication, division, and exponentiation. Spaces are ignored. Positive, negative, and decimal exponents are permitted. Examples:
kg*m/s^2
J/kmol
m*s^-2
J/kg/K
Metric prefixes are recognized for all units, such as nm, hPa, mg, EJ, mL, kcal.
Special functions for converting activation energies allow these values to be expressed as either energy per quantity, energy (for example, eV), or temperature by applying a factor of the Avogadro number or the gas constant where needed.
Definition at line 168 of file Units.h.
|
| UnitSystem (std::initializer_list< string > units) |
| Create a unit system with the specified default units. More...
|
|
| UnitSystem () |
| Default constructor for unit system (needed as VS2019 does not recognize an optional argument with a default value) More...
|
|
map< string, string > | defaults () const |
| Return default units used by the unit system. More...
|
|
void | setDefaults (std::initializer_list< string > units) |
| Set the default units to convert from when explicit units are not provided. More...
|
|
void | setDefaults (const map< string, string > &units) |
| Set the default units using a map of dimension to unit pairs. More...
|
|
void | setDefaultActivationEnergy (const string &e_units) |
| Set the default units to convert from when using the convertActivationEnergy function. More...
|
|
double | convert (double value, const string &src, const string &dest) const |
| Convert value from the units of src to the units of dest . More...
|
|
double | convert (double value, const Units &src, const Units &dest) const |
|
double | convertTo (double value, const string &dest) const |
| Convert value to the specified dest units from the appropriate units for this unit system (defined by setDefaults ) More...
|
|
double | convertTo (double value, const Units &dest) const |
|
double | convertFrom (double value, const string &src) const |
| Convert value from the specified src units to units appropriate for this unit system (defined by setDefaults ) More...
|
|
double | convertFrom (double value, const Units &src) const |
|
double | convert (const AnyValue &val, const string &dest) const |
| Convert a generic AnyValue node to the units specified in dest . More...
|
|
double | convert (const AnyValue &val, const Units &dest) const |
|
double | convertRateCoeff (const AnyValue &val, const Units &dest) const |
| Convert a generic AnyValue node representing a reaction rate coefficient to the units specified in dest . More...
|
|
vector< double > | convert (const vector< AnyValue > &vals, const string &dest) const |
| Convert an array of AnyValue nodes to the units specified in dest . More...
|
|
vector< double > | convert (const vector< AnyValue > &vals, const Units &dest) const |
|
double | convertActivationEnergy (double value, const string &src, const string &dest) const |
| Convert value from the units of src to the units of dest , allowing for the different dimensions that can be used for activation energies. More...
|
|
double | convertActivationEnergyTo (double value, const string &dest) const |
| Convert value to the units specified by dest from the default activation energy units. More...
|
|
double | convertActivationEnergyTo (double value, const Units &dest) const |
|
double | convertActivationEnergyFrom (double value, const string &src) const |
| Convert value from the units specified by src to the default activation energy units. More...
|
|
double | convertActivationEnergy (const AnyValue &val, const string &dest) const |
| Convert a generic AnyValue node to the units specified in dest . More...
|
|
AnyMap | getDelta (const UnitSystem &other) const |
| Get the changes to the defaults from other to this UnitSystem. More...
|
|