33 explicit Units(
double factor=1.0,
double mass=0,
double length=0,
34 double time=0,
double temperature=0,
double current=0,
41 explicit Units(
const std::string& units,
bool force_unity=
false);
56 std::string
str(
bool skip_unity=
true)
const;
62 bool operator==(
const Units& other)
const;
66 double dimension(
const std::string& primary)
const;
76 double m_temperature_dim;
78 double m_quantity_dim;
106 UnitStack(std::initializer_list<std::pair<Units, double>> units)
123 void join(
double exponent);
132 std::vector<std::pair<Units, double>>
stack;
164 UnitSystem(std::initializer_list<std::string> units);
171 std::map<std::string, std::string>
defaults()
const;
180 void setDefaults(std::initializer_list<std::string> units);
195 void setDefaults(
const std::map<std::string, std::string>& units);
202 double convert(
double value,
const std::string& src,
203 const std::string& dest)
const;
204 double convert(
double value,
const Units& src,
const Units& dest)
const;
208 double convertTo(
double value,
const std::string& dest)
const;
209 double convertTo(
double value,
const Units& dest)
const;
213 double convertFrom(
double value,
const std::string& src)
const;
214 double convertFrom(
double value,
const Units& src)
const;
220 double convert(
const AnyValue& val,
const std::string& dest)
const;
221 double convert(
const AnyValue& val,
const Units& dest)
const;
227 const std::string& dest)
const;
229 const Units& dest)
const;
234 const std::string& dest)
const;
250 const std::string& dest)
const;
double m_activation_energy_factor
Factor to convert activation energy from this unit system to J/kmol.
bool m_explicit_activation_energy
True if activation energy units are set explicitly, rather than as a combination of energy and quanti...
double m_time_factor
Factor to convert time from this unit system to seconds.
double m_pressure_factor
Factor to convert pressure from this unit system to Pa.
UnitSystem()
Default constructor for unit system (needed as VS2019 does not recognize an optional argument with a ...
double m_energy_factor
Factor to convert energy from this unit system to J.
double m_length_factor
Factor to convert length from this unit system to meters.
double convert(double value, const std::string &src, const std::string &dest) const
Convert value from the units of src to the units of dest.
void setDefaultActivationEnergy(const std::string &e_units)
Set the default units to convert from when using the convertActivationEnergy function.
double convertFrom(double value, const std::string &src) const
Convert value from the specified src units to units appropriate for this unit system (defined by setD...
double convertActivationEnergy(double value, const std::string &src, const std::string &dest) const
Convert value from the units of src to the units of dest, allowing for the different dimensions that ...
std::map< std::string, std::string > defaults() const
Return default units used by the unit system.
double m_mass_factor
Factor to convert mass from this unit system to kg.
double convertTo(double value, const std::string &dest) const
Convert value to the specified dest units from the appropriate units for this unit system (defined by...
double m_quantity_factor
Factor to convert quantity from this unit system to kmol.
double convertActivationEnergyTo(double value, const std::string &dest) const
Convert value to the units specified by dest from the default activation energy units.
void setDefaults(std::initializer_list< std::string > units)
Set the default units to convert from when explicit units are not provided.
double convertActivationEnergyFrom(double value, const std::string &src) const
Convert value from the units specified by src to the default activation energy units.
AnyMap getDelta(const UnitSystem &other) const
Get the changes to the defaults from other to this UnitSystem.
std::map< std::string, std::string > m_defaults
Map of dimensions (mass, length, etc.) to names of specified default units.
A representation of the units associated with a dimensional quantity.
double m_energy_dim
pseudo-dimension to track explicit energy units
std::string str(bool skip_unity=true) const
Provide a string representation of these Units.
double m_pressure_dim
pseudo-dimension to track explicit pressure units
void scale(double k)
Scale the unit by the factor k
double m_factor
conversion factor to Cantera base units
Units pow(double exponent) const
Raise these Units to a power, changing both the conversion factor and the dimensions of these Units.
Units & operator*=(const Units &other)
Multiply two Units objects, combining their conversion factors and dimensions.
bool convertible(const Units &other) const
Returns true if the specified Units are dimensionally consistent.
double dimension(const std::string &primary) const
Return dimension of primary unit component ("mass", "length", "time", "temperature",...
double factor() const
Return the factor for converting from this unit to Cantera's base units.
Units(double factor=1.0, double mass=0, double length=0, double time=0, double temperature=0, double current=0, double quantity=0)
Create a Units object with the specified dimensions.
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Unit aggregation utility.
double standardExponent() const
Effective exponent of standard unit.
size_t size() const
Size of UnitStack.
void update(const Units &units, double exponent)
Update exponent of item with matching units; if it does not exist, add unit-exponent pair at end of s...
Units standardUnits() const
Get standard unit used by UnitStack.
UnitStack(std::initializer_list< std::pair< Units, double > > units)
Alternative constructor allows for direct assignment of vector.
Units product() const
Calculate product of units-exponent stack.
void join(double exponent)
Join (update) exponent of standard units, where the updated exponent is the sum of the pre-existing e...
std::vector< std::pair< Units, double > > stack
Stack uses vector of pairs.
void setStandardUnits(Units &standardUnits)
Set standard units.