Reaktoro 
A unified framework for modeling chemically reactive systems
Reaktoro::ChemicalState Class Reference

Detailed Description

Provides a computational representation of the state of a multiphase chemical system.

The chemical state of a multiphase system is defined by its temperature \((T)\), pressure \((P)\), and molar composition \((\mathbf{n})\).

Usage

// Create a ChemicalState instance, where system is a ChemicalSystem instance
ChemicalState state(system);
// Set the temperature and pressure states
state.setTemperature(60.0, "celsius");
state.setPressure( 180.0, "bar");
// Set the amount of some species
state.set( "H2O(l)", 1.0, "kg");
state.set( "Na+", 1.0, "mol");
state.set( "Cl-", 1.0, "mol");
state.set("CO2(aq)", 0.5, "mol");
state.set("Calcite", 10.0, "g");
// Output the chemical state instance
std::cout << state << std::endl;
See also
ChemicalSystem

#include <ChemicalState.hpp>

Public Member Functions

 ChemicalState ()
 Construct a default ChemicalState instance.
 
 ChemicalState (const ChemicalSystem &system)
 Construct a ChemicalState instance with standard conditions This constructor creates an instance of ChemicalState with temperature 25 °C, pressure 1 bar, and zero mole amounts for the species. More...
 
 ChemicalState (const ChemicalState &other)
 Construct a copy of a ChemicalState instance.
 
virtual ~ChemicalState ()
 Destroy the instance.
 
auto operator= (ChemicalState other) -> ChemicalState &
 Assign a ChemicalState instance to this instance.
 
auto setTemperature (double val) -> void
 Set the temperature of the chemical state (in units of K)
 
auto setTemperature (double val, std::string units) -> void
 Set the temperature of the chemical state with given units.
 
auto setPressure (double val) -> void
 Set the pressure of the chemical state (in units of Pa)
 
auto setPressure (double val, std::string units) -> void
 Set the pressure of the chemical state with given units.
 
auto setSpeciesAmounts (double val) -> void
 Set the molar amounts of the species with a single value (in units of mol) More...
 
auto setSpeciesAmounts (const Vector &n) -> void
 Set the molar amounts of the species (in units of mol) More...
 
auto setSpeciesAmounts (const Vector &n, const Indices &indices) -> void
 Set the molar amounts of species given by their indices (in units of mol) More...
 
auto setSpeciesAmount (Index index, double amount) -> void
 Set the molar amount of a species (in units of mol) More...
 
auto setSpeciesAmount (std::string name, double amount) -> void
 Set the molar amount of a species (in units of mol) More...
 
auto setSpeciesAmount (Index index, double amount, std::string units) -> void
 Set the amount of a species with given units. More...
 
auto setSpeciesAmount (std::string name, double amount, std::string units) -> void
 Set the amount of a species with given units. More...
 
auto setSpeciesMass (Index index, double mass) -> void
 Set the mass of a species (in units of kg) More...
 
auto setSpeciesMass (std::string name, double mass) -> void
 Set the mass of a species (in units of kg) More...
 
auto setSpeciesMass (Index index, double mass, std::string units) -> void
 Set the mass of a species with given units. More...
 
auto setSpeciesMass (std::string name, double mass, std::string units) -> void
 Set the mass of a species with given units. More...
 
auto setSpeciesDualPotentials (const Vector &z) -> void
 Set the dual potentials of the species (in units of J/mol) The dual potentials of the species are the Lagrange multipliers with respect to the positive bound constraints on the molar amounts of the species in a chemical equilibrium calculation. More...
 
auto setElementDualPotentials (const Vector &y) -> void
 Set the dual potentials of the elements (in units of J/mol) The dual potentials of the elements are the Lagrange multipliers with respect to the balance constraints on the molar amounts of the elements. More...
 
auto scaleSpeciesAmounts (double scalar) -> void
 Scale the molar amounts of the species by a given scalar. More...
 
auto scaleSpeciesAmountsInPhase (Index index, double scalar) -> void
 Scale the molar amounts of the species in a phase by a given scalar. More...
 
auto scalePhaseVolume (Index index, double volume) -> void
 Scale the volume of a phase by adjusting the molar amounts of its species. More...
 
auto scalePhaseVolume (Index index, double volume, std::string units) -> void
 Scale the volume of a phase by adjusting the molar amounts of its species. More...
 
auto scalePhaseVolume (std::string name, double volume) -> void
 Scale the volume of a phase by adjusting the molar amounts of its species. More...
 
auto scalePhaseVolume (std::string name, double volume, std::string units) -> void
 Scale the volume of a phase by adjusting the molar amounts of its species. More...
 
auto scaleFluidVolume (double volume) -> void
 Scale the fluid volume of the chemical system. More...
 
auto scaleFluidVolume (double volume, std::string units) -> void
 Scale the fluid volume of the chemical system with given units. More...
 
auto scaleSolidVolume (double volume) -> void
 Scale the solid volume of the chemical system. More...
 
auto scaleSolidVolume (double volume, std::string units) -> void
 Scale the solid volume of the chemical system with given units. More...
 
auto scaleVolume (double volume) -> void
 Scale the volume of the chemical system by adjusting the molar amounts of all species equally. More...
 
auto system () const -> const ChemicalSystem &
 Return the chemical system instance.
 
auto temperature () const -> double
 Return the temperature of the chemical state (in units of K)
 
auto pressure () const -> double
 Return the pressure of the chemical state (in units of Pa)
 
auto speciesAmounts () const -> const Vector &
 Return the molar amounts of the species (in units of mol)
 
auto speciesAmounts (const Indices &indices) const -> Vector
 Return the molar amounts of given species (in units of mol) More...
 
auto speciesAmount (Index index) const -> double
 Return the molar mass of a chemical species (in units of mol) More...
 
auto speciesAmount (std::string name) const -> double
 Return the molar amount of a chemical species (in units of mol) More...
 
auto speciesAmount (Index index, std::string units) const -> double
 Return the amount of a chemical species with given molar units. More...
 
auto speciesAmount (std::string name, std::string units) const -> double
 Return the amount of a chemical species with given molar units. More...
 
auto speciesDualPotentials () const -> const Vector &
 Return the dual potentials of the species (in units of J/mol)
 
auto elementAmounts () const -> Vector
 Return the molar amounts of the elements (in units of mol)
 
auto elementAmountsInPhase (Index index) const -> Vector
 Return the molar amounts of the elements in a phase (in units of mol) More...
 
auto elementAmountsInSpecies (const Indices &indices) const -> Vector
 Return the molar amounts of the elements in a set of species (in units of mol) More...
 
auto elementAmount (Index index) const -> double
 Return the molar amount of an element (in units of mol) More...
 
auto elementAmount (std::string name) const -> double
 Return the molar amount of an element (in units of mol) More...
 
auto elementAmount (Index index, std::string units) const -> double
 Return the amount of an element with given units. More...
 
auto elementAmount (std::string name, std::string units) const -> double
 Return the amount of an element with given units. More...
 
auto elementAmountInPhase (Index ielement, Index iphase) const -> double
 Return the molar amount of an element in a given phase (in units of mol) More...
 
auto elementAmountInPhase (std::string element, std::string phase) const -> double
 Return the molar amount of an element in a given phase (in units of mol) More...
 
auto elementAmountInPhase (Index ielement, Index iphase, std::string units) const -> double
 Return the amount of an element in a given phase with given units. More...
 
auto elementAmountInPhase (std::string element, std::string phase, std::string units) const -> double
 Return the amount of an element in a given phase with given units. More...
 
auto elementAmountInSpecies (Index ielement, const Indices &ispecies) const -> double
 Return the molar amount of an element in a set of species (in units of mol) More...
 
auto elementAmountInSpecies (Index ielement, const Indices &ispecies, std::string units) const -> double
 Return the amount of an element in a set of species with given units. More...
 
auto elementDualPotentials () const -> const Vector &
 Return the dual potentials of the elements (in units of J/mol)
 
auto phaseAmount (Index index) const -> double
 Return the molar amount of a phase (in units of mol) More...
 
auto phaseAmount (std::string name) const -> double
 Return the molar amount of a phase (in units of mol) More...
 
auto phaseAmount (Index index, std::string units) const -> double
 Return the molar amount of a phase with given units. More...
 
auto phaseAmount (std::string name, std::string units) const -> double
 Return the molar amount of a phase with given units. More...
 
auto phaseStabilityIndices () const -> Vector
 Return the stability indices of the phases with respect to chemical equilibrium. More...
 
auto properties () const -> ChemicalProperties
 Return the chemical properties of the system.
 
auto output (std::string filename) -> void
 Output the ChemicalState instance to a file.
 

Constructor & Destructor Documentation

Reaktoro::ChemicalState::ChemicalState ( const ChemicalSystem system)
explicit

Construct a ChemicalState instance with standard conditions This constructor creates an instance of ChemicalState with temperature 25 °C, pressure 1 bar, and zero mole amounts for the species.

Parameters
systemThe chemical system instance

Member Function Documentation

auto Reaktoro::ChemicalState::setSpeciesAmounts ( double  val) -> void

Set the molar amounts of the species with a single value (in units of mol)

Parameters
valThe single molar amounts of the species
auto Reaktoro::ChemicalState::setSpeciesAmounts ( const Vector n) -> void

Set the molar amounts of the species (in units of mol)

Parameters
nThe vector of molar amounts of the species
auto Reaktoro::ChemicalState::setSpeciesAmounts ( const Vector n,
const Indices indices 
) -> void

Set the molar amounts of species given by their indices (in units of mol)

Parameters
nThe vector of molar amounts of the species
indicesThe indices of the species to be set
auto Reaktoro::ChemicalState::setSpeciesAmount ( Index  index,
double  amount 
) -> void

Set the molar amount of a species (in units of mol)

Parameters
indexThe index of the species
amountThe molar amount of the species
auto Reaktoro::ChemicalState::setSpeciesAmount ( std::string  name,
double  amount 
) -> void

Set the molar amount of a species (in units of mol)

Parameters
nameThe name of the species
amountThe amount of the species
auto Reaktoro::ChemicalState::setSpeciesAmount ( Index  index,
double  amount,
std::string  units 
) -> void

Set the amount of a species with given units.

Parameters
indexThe index of the species
amountThe amount of the species
unitsThe units of the amount (must be convertible to either mol or gram)
auto Reaktoro::ChemicalState::setSpeciesAmount ( std::string  name,
double  amount,
std::string  units 
) -> void

Set the amount of a species with given units.

Parameters
nameThe name of the species
amountThe amount of the species
unitsThe units of the amount (must be convertible to either mol or gram)
auto Reaktoro::ChemicalState::setSpeciesMass ( Index  index,
double  mass 
) -> void

Set the mass of a species (in units of kg)

Parameters
indexThe index of the species
massThe mass of the species
auto Reaktoro::ChemicalState::setSpeciesMass ( std::string  name,
double  mass 
) -> void

Set the mass of a species (in units of kg)

Parameters
nameThe name of the species
massThe mass of the species
auto Reaktoro::ChemicalState::setSpeciesMass ( Index  index,
double  mass,
std::string  units 
) -> void

Set the mass of a species with given units.

Parameters
indexThe index of the species
massThe mass of the species
unitsThe units of the mass
auto Reaktoro::ChemicalState::setSpeciesMass ( std::string  name,
double  mass,
std::string  units 
) -> void

Set the mass of a species with given units.

Parameters
nameThe name of the species
massThe mass of the species
unitsThe units of the mass
auto Reaktoro::ChemicalState::setSpeciesDualPotentials ( const Vector z) -> void

Set the dual potentials of the species (in units of J/mol) The dual potentials of the species are the Lagrange multipliers with respect to the positive bound constraints on the molar amounts of the species in a chemical equilibrium calculation.

They can be seen as measures of stability of a species at equilibrium, with values closer to zero meaning more stability.

Parameters
zThe Lagrange multipliers with respect to the positive constraints.
auto Reaktoro::ChemicalState::setElementDualPotentials ( const Vector y) -> void

Set the dual potentials of the elements (in units of J/mol) The dual potentials of the elements are the Lagrange multipliers with respect to the balance constraints on the molar amounts of the elements.

They can be seen as dual chemical potential of elements.

Parameters
valuesThe Lagrange multipliers with respect to the balance constraints.
auto Reaktoro::ChemicalState::scaleSpeciesAmounts ( double  scalar) -> void

Scale the molar amounts of the species by a given scalar.

Parameters
scalarThe scale factor of the molar amounts
auto Reaktoro::ChemicalState::scaleSpeciesAmountsInPhase ( Index  index,
double  scalar 
) -> void

Scale the molar amounts of the species in a phase by a given scalar.

Parameters
indexThe index of the phase
scalarThe scale factor of the molar amounts
auto Reaktoro::ChemicalState::scalePhaseVolume ( Index  index,
double  volume 
) -> void

Scale the volume of a phase by adjusting the molar amounts of its species.

Parameters
indexThe index of the phase
volumeThe volume of the phase (in units of m3)
auto Reaktoro::ChemicalState::scalePhaseVolume ( Index  index,
double  volume,
std::string  units 
) -> void

Scale the volume of a phase by adjusting the molar amounts of its species.

Parameters
indexThe index of the phase
volumeThe volume of the phase
unitsThe units of the volume of the phase
auto Reaktoro::ChemicalState::scalePhaseVolume ( std::string  name,
double  volume 
) -> void

Scale the volume of a phase by adjusting the molar amounts of its species.

Parameters
nameThe name of the phase
volumeThe volume of the phase (in units of m3)
auto Reaktoro::ChemicalState::scalePhaseVolume ( std::string  name,
double  volume,
std::string  units 
) -> void

Scale the volume of a phase by adjusting the molar amounts of its species.

Parameters
nameThe name of the phase
volumeThe volume of the phase
unitsThe units of the volume of the phase
auto Reaktoro::ChemicalState::scaleFluidVolume ( double  volume) -> void

Scale the fluid volume of the chemical system.

This method scales each fluid phase by the same factor. This factor is defined as the prescribed volume divided by current volume of the fluid phases.

Parameters
volumeThe scaled fluid volume (in units of m3)
auto Reaktoro::ChemicalState::scaleFluidVolume ( double  volume,
std::string  units 
) -> void

Scale the fluid volume of the chemical system with given units.

This method scales each fluid phase by the same factor. This factor is defined as the prescribed volume divided by current volume of the fluid phases.

Parameters
volumeThe scaled fluid volume
unitsThe volume units
auto Reaktoro::ChemicalState::scaleSolidVolume ( double  volume) -> void

Scale the solid volume of the chemical system.

This method scales each solid phase by the same factor. This factor is defined as the prescribed volume divided by current volume of the solid phases.

Parameters
volumeThe scaled solid volume (in units of m3)
auto Reaktoro::ChemicalState::scaleSolidVolume ( double  volume,
std::string  units 
) -> void

Scale the solid volume of the chemical system with given units.

This method scales each solid phase by the same factor. This factor is defined as the prescribed volume divided by current volume of the solid phases.

Parameters
volumeThe scaled solid volume
unitsThe volume units
auto Reaktoro::ChemicalState::scaleVolume ( double  volume) -> void

Scale the volume of the chemical system by adjusting the molar amounts of all species equally.

Parameters
volumeThe volume of the chemical system (in units of m3)
auto Reaktoro::ChemicalState::speciesAmounts ( const Indices indices) const -> Vector

Return the molar amounts of given species (in units of mol)

Parameters
indicesThe indices of the species
auto Reaktoro::ChemicalState::speciesAmount ( Index  index) const -> double

Return the molar mass of a chemical species (in units of mol)

Parameters
indexThe index of the species
auto Reaktoro::ChemicalState::speciesAmount ( std::string  name) const -> double

Return the molar amount of a chemical species (in units of mol)

Parameters
nameThe name of the species
auto Reaktoro::ChemicalState::speciesAmount ( Index  index,
std::string  units 
) const -> double

Return the amount of a chemical species with given molar units.

Parameters
indexThe index of the species
unitsThe units of the species amount
auto Reaktoro::ChemicalState::speciesAmount ( std::string  name,
std::string  units 
) const -> double

Return the amount of a chemical species with given molar units.

Parameters
nameThe name of the species
unitsThe units of the species amount
auto Reaktoro::ChemicalState::elementAmountsInPhase ( Index  index) const -> Vector

Return the molar amounts of the elements in a phase (in units of mol)

Parameters
indexThe index of the phase
auto Reaktoro::ChemicalState::elementAmountsInSpecies ( const Indices indices) const -> Vector

Return the molar amounts of the elements in a set of species (in units of mol)

Parameters
indicesThe indices of the species
auto Reaktoro::ChemicalState::elementAmount ( Index  index) const -> double

Return the molar amount of an element (in units of mol)

Parameters
indexThe index of the element
auto Reaktoro::ChemicalState::elementAmount ( std::string  name) const -> double

Return the molar amount of an element (in units of mol)

Parameters
nameThe name of the element
auto Reaktoro::ChemicalState::elementAmount ( Index  index,
std::string  units 
) const -> double

Return the amount of an element with given units.

Parameters
indexThe index of the element
unitsThe units of the element amount
auto Reaktoro::ChemicalState::elementAmount ( std::string  name,
std::string  units 
) const -> double

Return the amount of an element with given units.

Parameters
nameThe name of the element
unitsThe units of the element amount
auto Reaktoro::ChemicalState::elementAmountInPhase ( Index  ielement,
Index  iphase 
) const -> double

Return the molar amount of an element in a given phase (in units of mol)

Parameters
ielementThe index of the element
iphaseThe index of the phase
auto Reaktoro::ChemicalState::elementAmountInPhase ( std::string  element,
std::string  phase 
) const -> double

Return the molar amount of an element in a given phase (in units of mol)

Parameters
elementThe name of the element
phaseThe name of the phase
auto Reaktoro::ChemicalState::elementAmountInPhase ( Index  ielement,
Index  iphase,
std::string  units 
) const -> double

Return the amount of an element in a given phase with given units.

Parameters
ielementThe index of the element
iphaseThe index of the phase
unitsThe units of the element amount
auto Reaktoro::ChemicalState::elementAmountInPhase ( std::string  element,
std::string  phase,
std::string  units 
) const -> double

Return the amount of an element in a given phase with given units.

Parameters
elementThe name of the element
phaseThe name of the phase
unitsThe units of the element amount
auto Reaktoro::ChemicalState::elementAmountInSpecies ( Index  ielement,
const Indices ispecies 
) const -> double

Return the molar amount of an element in a set of species (in units of mol)

Parameters
ielementThe index of the element
ispeciesThe indices of the species
auto Reaktoro::ChemicalState::elementAmountInSpecies ( Index  ielement,
const Indices ispecies,
std::string  units 
) const -> double

Return the amount of an element in a set of species with given units.

Parameters
ielementThe index of the element
ispeciesThe indices of the species
unitsThe units of the element amount
auto Reaktoro::ChemicalState::phaseAmount ( Index  index) const -> double

Return the molar amount of a phase (in units of mol)

Parameters
indexThe index of the phase
auto Reaktoro::ChemicalState::phaseAmount ( std::string  name) const -> double

Return the molar amount of a phase (in units of mol)

Parameters
nameThe name of the phase
auto Reaktoro::ChemicalState::phaseAmount ( Index  index,
std::string  units 
) const -> double

Return the molar amount of a phase with given units.

Parameters
indexThe index of the phase
unitsThe units of the phase amount
auto Reaktoro::ChemicalState::phaseAmount ( std::string  name,
std::string  units 
) const -> double

Return the molar amount of a phase with given units.

Parameters
nameThe name of the phase
unitsThe units of the phase amount
auto Reaktoro::ChemicalState::phaseStabilityIndices ( ) const -> Vector

Return the stability indices of the phases with respect to chemical equilibrium.

The stability index of a stable phase at chemical equilibrium should be zero or very close to zero. A negative stability index indicates that the corresponding phase is under-saturated, while a positive index indicates the phase is over-saturated.


The documentation for this class was generated from the following files: