Utilities to convert to and from mole units. More...
Functions | |
Real | fromMoles (Real moles, const GeochemistryUnit unit, const std::string &species_name, const ModelGeochemicalDatabase &mgd) |
Calculates the amount of "unit"s of species_name in 1 mole, OR in 1 molal, whichever is appropriate. More... | |
Real | toMoles (Real quantity, const GeochemistryUnit unit, const std::string &species_name, const ModelGeochemicalDatabase &mgd) |
Calculates the amount of moles corresponding to "quantity" "unit"s of species name, OR calculates the molality corresponding to "quantity" "unit"s of species name, whichever is appropriate. More... | |
Real | conversionFactor (const GeochemistryUnit unit, unsigned ind, const std::string &name, const std::vector< Real > &mol_weight, const std::vector< Real > &mol_volume, const std::vector< bool > &is_mineral) |
Calculates the number of "unit" in 1 mole of substance, OR calculates the number of "unit" in 1 molal of substance, whichever is appropriate. More... | |
Utilities to convert to and from mole units.
|
strong |
Enumerator | |
---|---|
DIMENSIONLESS | |
MOLES | |
MOLAL | |
KG | |
G | |
MG | |
UG | |
KG_PER_KG_SOLVENT | |
G_PER_KG_SOLVENT | |
MG_PER_KG_SOLVENT | |
UG_PER_KG_SOLVENT | |
CM3 |
Definition at line 19 of file GeochemistryUnitConverter.h.
Real GeochemistryUnitConverter::conversionFactor | ( | const GeochemistryUnit | unit, |
unsigned | ind, | ||
const std::string & | name, | ||
const std::vector< Real > & | mol_weight, | ||
const std::vector< Real > & | mol_volume, | ||
const std::vector< bool > & | is_mineral | ||
) |
Calculates the number of "unit" in 1 mole of substance, OR calculates the number of "unit" in 1 molal of substance, whichever is appropriate.
Example: if unit = G, this function will return the molecular weight of the substance. Example: if unit = CM3, this function returns the molecular volume of the substance, or will produce an error if the substance is not a mineral. Example: if unit = MG_PER_KG, then the molal quantity returned is 1E3 * (molecular weight of the substance). You will probably want to use toMoles or fromMoles rather than this function.
unit | The unit that you wish to convert 1 mol of substance to. If unit is DIMENSIONLESS, MOLES or MOLAL, this returns 1.0. If unit is KG, G, MG, UG or CM3, this function returns the number in 1 mole. If unit is KG_PER_KG_SOLVENT, G_PER_KG_SOLVENT, MG_PER_KG_SOLVENT, UG_PER_KG_SOLVENT, this function returns the number in 1 molal. |
ind | The index of mol_weight and mol_volume and is_mineral corresponding to the substance |
name | The name of the substance |
mol_weight | mol_weight[ind] is the molecular weight (g/mol) of the substance |
mol_volume | mol_volume[ind] is the molecular volume (cm^3/mol) of the substance |
is_mineral | is_mineral[ind] = true iff the substance is a mineral |
Definition at line 61 of file GeochemistryUnitConverter.C.
Referenced by fromMoles().
Real GeochemistryUnitConverter::fromMoles | ( | Real | moles, |
const GeochemistryUnit | unit, | ||
const std::string & | species_name, | ||
const ModelGeochemicalDatabase & | mgd | ||
) |
Calculates the amount of "unit"s of species_name in 1 mole, OR in 1 molal, whichever is appropriate.
Example: if moles = 2.0 and unit = CM3 and species_name = Halite, this function will return the number of cm^3 in 1 mole of Halite. Example: if moles = 2.0 and unit = MG_PER_KG and species_name = Halite, this function will return the number of mg/kg_solvent_water in a 2.0 molal solution of Halite.
moles | the amount of moles of species_name |
unit | the unit to convert to. If unit is DIMENSIONLESS, MOLES or MOLAL, this returns quantity. If unit is KG, G, MG, UG or CM3, then "moles" is the mole number. If unit is KG_PER_KG_SOLVENT, G_PER_KG_SOLVENT, MG_PER_KG_SOLVENT, UG_PER_KG_SOLVENT, then "moles" is assumed to be the molality. |
species_name | the name of the substance - this should appear in mgd |
mgd | the database corresponding to the model, which should contain information about species_name |
Definition at line 17 of file GeochemistryUnitConverter.C.
Referenced by TEST(), and toMoles().
Real GeochemistryUnitConverter::toMoles | ( | Real | quantity, |
const GeochemistryUnit | unit, | ||
const std::string & | species_name, | ||
const ModelGeochemicalDatabase & | mgd | ||
) |
Calculates the amount of moles corresponding to "quantity" "unit"s of species name, OR calculates the molality corresponding to "quantity" "unit"s of species name, whichever is appropriate.
Example: if quantity = 2.0 and unit = CM3 and species_name = Halite, this function will return the number of moles in 2 cm^3 of Halite. Example: if quantity = 2.0 and unit = MG_PER_KG and species_name = Halite, this function will return the molality of a 2 mg/kg_solvent_water Halite solution.
quantity | the amount of substance expressed in "unit" units |
unit | the unit of measurement of to_convert. If unit is DIMENSIONLESS, MOLES or MOLAL, this returns quantity. If unit is KG, G, MG, UG or CM3, this function returns the number of moles. If unit is KG_PER_KG_SOLVENT, G_PER_KG_SOLVENT, MG_PER_KG_SOLVENT, UG_PER_KG_SOLVENT, this function returns the molality. |
species_name | the name of the substance - this should appear in mgd |
mgd | the database corresponding to the model, which should contain information about species_name |
Definition at line 52 of file GeochemistryUnitConverter.C.
Referenced by GeochemicalSystem::checkAndInitialize(), and TEST().