11#ifndef CT_LEGACY_UNITS_H
12#define CT_LEGACY_UNITS_H
72 doublereal
toSI(
const std::string& units_) {
78 doublereal f = 1.0, fctr;
79 std::string u = units_, tok, tsub;
80 std::string::size_type k;
86 k = u.find_first_of(
"/-");
92 size_t tsize = tok.size();
95 }
else if (tok[tsize - 1] ==
'2') {
96 tsub = tok.substr(0,tsize-1);
99 }
else if (tok[tsize - 1] ==
'3') {
100 tsub = tok.substr(0,tsize-1);
103 }
else if (tok[tsize - 1] ==
'4') {
104 tsub = tok.substr(0,tsize-1);
106 fctr *= fctr*fctr*fctr;
107 }
else if (tok[tsize - 1] ==
'5') {
108 tsub = tok.substr(0,tsize-1);
110 fctr *= fctr*fctr*fctr*fctr;
111 }
else if (tok[tsize - 1] ==
'6') {
112 tsub = tok.substr(0,tsize-1);
114 fctr *= fctr*fctr*fctr*fctr*fctr;
123 throw CanteraError(
"Unit::toSI",
"unknown unit: '{}'", tsub);
127 }
else if (action ==
'/') {
134 u = u.substr(k+1,u.size());
149 std::map<std::string, doublereal>
m_u;
172 m_u[
"micron"] = 1.0e-6;
175 m_u[
"Angstrom"] = 1.0e-10;
176 m_u[
"Angstroms"] = 1.0e-10;
182 m_u[
"kcal"] = 4184.0;
190 m_u[
"gmol"] = 1.0e-3;
191 m_u[
"mole"] = 1.0e-3;
207 m_u[
"atm"] = 1.01325e5;
221 m_u[
"coulomb"] = 1.0;
236 m_u[
"centipoise"] = 0.001;
242 m_u[
"liter"] = 0.001;
Base class for exceptions thrown by Cantera classes.
static void deleteUnit()
Destroy the static Unit class.
static std::mutex units_mutex
Decl for static locker for Units singleton.
doublereal actEnergyToSI(const std::string &units_)
Return the multiplier required to convert an activation energy to SI units.
doublereal toSI(const std::string &units_)
Return the multiplier required to convert a dimensional quantity with units specified by string 'unit...
static Unit * s_u
pointer to the single instance of Unit
std::map< std::string, doublereal > m_u
Map between a string and a units double value.
std::map< std::string, doublereal > m_act_u
Map between a string and a units double value for activation energy units.
virtual ~Unit()
Empty Destructor.
Unit()
Units class constructor, containing the default mappings between strings and units.
static Unit * units()
Initialize the static Unit class.
This file contains definitions of constants, types and terms that are used in internal routines and a...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double Faraday
Faraday constant [C/kmol].
const double Avogadro
Avogadro's Number [number/kmol].
const double GasConstant
Universal Gas Constant [J/kmol/K].