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

Detailed Description

A class used for defining an inverse equilibrium problem.

In an inverse equilibrium problem, not all elements have known molar amounts. Their amount constraints are replaced by other equilibrium constraints such as fixed species amount or activity, or the volume or total amount of a phase. Since the amounts of elements are not known a priori, an inverse equilibrium calculation tries to determine amounts of titrants that can control the specified equilibrium constraints. The amount of the titrants are unknown, and its addition or removal is done over the calculation so that the equilibrium state is driven towards a state where all given equilibrium constraints are satisfied.

#include <EquilibriumInverseProblem.hpp>

Public Member Functions

 EquilibriumInverseProblem (const ChemicalSystem &system)
 Construct an EquilibriumInverseProblem instance.
 
 EquilibriumInverseProblem (const EquilibriumInverseProblem &other)
 Construct a copy of an EquilibriumInverseProblem instance.
 
virtual ~EquilibriumInverseProblem ()
 Destroy this EquilibriumInverseProblem instance.
 
auto operator= (EquilibriumInverseProblem other) -> EquilibriumInverseProblem &
 Assign a copy of an EquilibriumInverseProblem instance.
 
auto setPartition (const Partition &partition) -> EquilibriumInverseProblem &
 Set the partition of the chemical system. More...
 
auto setTemperature (double val) -> EquilibriumInverseProblem &
 Set the temperature for the equilibrium calculation (in units of K). More...
 
auto setTemperature (double val, std::string units) -> EquilibriumInverseProblem &
 Set the temperature for the equilibrium calculation. More...
 
auto setPressure (double val) -> EquilibriumInverseProblem &
 Set the pressure for the equilibrium calculation (in units of Pa). More...
 
auto setPressure (double val, std::string units) -> EquilibriumInverseProblem &
 Set the pressure for the equilibrium calculation. More...
 
auto setElementInitialAmounts (const Vector &values) -> EquilibriumInverseProblem &
 Set the initial known molar amounts of the elements in the equilibrium partition. More...
 
auto add (std::string name, double amount, std::string units) -> EquilibriumInverseProblem &
 Add a given amount of a compound or species to the initial equilibrium recipe. More...
 
auto fixSpeciesAmount (std::string species, double value, std::string units) -> EquilibriumInverseProblem &
 Fix the molar amount of a species at equilibrium. More...
 
auto fixSpeciesAmount (std::string species, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the molar amount of a species at equilibrium with given titrant. More...
 
auto fixSpeciesMass (std::string species, double value, std::string units) -> EquilibriumInverseProblem &
 Fix the mass of a species at equilibrium. More...
 
auto fixSpeciesMass (std::string species, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the mass of a species at equilibrium with given titrant. More...
 
auto fixSpeciesActivity (std::string species, double value) -> EquilibriumInverseProblem &
 Fix the activity of a species at equilibrium. More...
 
auto fixSpeciesActivity (std::string species, double value, std::string titrant) -> EquilibriumInverseProblem &
 Fix the activity of a species at equilibrium with given titrant. More...
 
auto fixSpeciesActivity (std::string species, double value, std::string titrant1, std::string titrant2) -> EquilibriumInverseProblem &
 Fix the activity of a species at equilibrium with either one of the two given titrants. More...
 
auto fixSpeciesFugacity (std::string species, double value, std::string units) -> EquilibriumInverseProblem &
 Fix the fugacity of a gaseous species. More...
 
auto fixSpeciesFugacity (std::string species, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the fugacity of a gaseous species with given titrant. More...
 
auto fixPhaseAmount (std::string phase, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the total molar amount of a phase at equilibrium with given titrant. More...
 
auto fixPhaseMass (std::string phase, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the total mass of a phase at equilibrium with given titrant. More...
 
auto fixPhaseVolume (std::string phase, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the volume of a phase at equilibrium with given titrant. More...
 
auto fixPhaseSetVolume (const std::vector< std::string > &phases, double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the total volume of a set of phases at equilibrium with given titrant. More...
 
auto pH (double value) -> EquilibriumInverseProblem &
 Fix the pH of the aqueous solution. More...
 
auto pH (double value, std::string titrant) -> EquilibriumInverseProblem &
 Fix the pH of the aqueous solution with given titrant. More...
 
auto pH (double value, std::string titrant1, std::string titrant2) -> EquilibriumInverseProblem &
 Fix the pH of the aqueous solution with either one of the two given titrants. More...
 
auto pE (double value) -> EquilibriumInverseProblem &
 Fix the pe of the aqueous solution. More...
 
auto pE (double value, std::string titrant) -> EquilibriumInverseProblem &
 Fix the pe of the aqueous solution with given half reaction. More...
 
auto Eh (double value, std::string units) -> EquilibriumInverseProblem &
 Fix the Eh of the aqueous solution (in units of volts). More...
 
auto Eh (double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the Eh of the aqueous solution with given half reaction. More...
 
auto alkalinity (double value, std::string units, std::string titrant) -> EquilibriumInverseProblem &
 Fix the total alkalinity of the aqueous solution. More...
 
auto system () const -> const ChemicalSystem &
 Return a reference to the ChemicalSystem instance used to create this EquilibriumProblem instance.
 
auto partition () const -> const Partition &
 Return a reference to the Partition instance used to create this EquilibriumProblem instance.
 
auto temperature () const -> double
 Return the temperature for the equilibrium calculation (in units of K)
 
auto pressure () const -> double
 Return the pressure for the equilibrium calculation (in units of Pa)
 
auto numConstraints () const -> Index
 Return the number of constraints used in the inverse equilibrium problem.
 
auto numTitrants () const -> Index
 Return the number of titrants used in the inverse equilibrium problem.
 
auto formulaMatrixTitrants () const -> Matrix
 Return the formula matrix of the titrants. More...
 
auto elementInitialAmounts () const -> Vector
 Return the initial amounts of elements in the equilibrium partition. More...
 
auto titrantInitialAmounts () const -> Vector
 Return the initial amounts of titrants as initial guess for the inverse equilibrium calculation.
 
auto residualEquilibriumConstraints (const Vector &x, const ChemicalState &state) const -> ResidualEquilibriumConstraints
 Return the residuals of the equilibrium constraints and their partial derivatives. More...
 
auto solve (ChemicalState &state) -> EquilibriumResult
 Solve the inverse equilibrium problem. More...
 

Member Function Documentation

auto Reaktoro::EquilibriumInverseProblem::setPartition ( const Partition partition) -> EquilibriumInverseProblem&

Set the partition of the chemical system.

Use this method to specify the equilibrium, kinetic, and inert species.

auto Reaktoro::EquilibriumInverseProblem::setTemperature ( double  val) -> EquilibriumInverseProblem&

Set the temperature for the equilibrium calculation (in units of K).

By default, the temperature is 25 °C.

Parameters
valThe temperature value (in units of K).
auto Reaktoro::EquilibriumInverseProblem::setTemperature ( double  val,
std::string  units 
) -> EquilibriumInverseProblem&

Set the temperature for the equilibrium calculation.

By default, the temperature is 25 °C.

Parameters
valThe temperature value.
unitsThe units of the temperature (K, degC, degF, degR, kelvin, celsius, fahrenheit, rankine).
auto Reaktoro::EquilibriumInverseProblem::setPressure ( double  val) -> EquilibriumInverseProblem&

Set the pressure for the equilibrium calculation (in units of Pa).

By default, the pressure is 1 bar.

Parameters
valThe pressure value (in units of Pa).
auto Reaktoro::EquilibriumInverseProblem::setPressure ( double  val,
std::string  units 
) -> EquilibriumInverseProblem&

Set the pressure for the equilibrium calculation.

By default, the pressure is 1 bar.

Parameters
valThe pressure value.
unitsThe units of the pressure (Pa, kPa, MPa, GPa, atm, mmHg, inHg, psi, kpsi, Mpsi, psf, bar, torr, inH2O, ftH2O, pascal).
auto Reaktoro::EquilibriumInverseProblem::setElementInitialAmounts ( const Vector values) -> EquilibriumInverseProblem&

Set the initial known molar amounts of the elements in the equilibrium partition.

These are the amounts of the equilibrium elements before unknown amounts of titrants are added.

auto Reaktoro::EquilibriumInverseProblem::add ( std::string  name,
double  amount,
std::string  units 
) -> EquilibriumInverseProblem&

Add a given amount of a compound or species to the initial equilibrium recipe.

Parameters
nameThe name of the compound or species
amountThe amount of the compound or species
unitsThe units of the amount (must be convertible to either mol or kg)
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesAmount ( std::string  species,
double  value,
std::string  units 
) -> EquilibriumInverseProblem&

Fix the molar amount of a species at equilibrium.

Parameters
speciesThe name of the species for which its amount is given.
valueThe value of the species amount (in units of mol).
unitsThe units of the species amount (must be convertible to mol)
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesAmount ( std::string  species,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the molar amount of a species at equilibrium with given titrant.

Parameters
speciesThe name of the species for which its amount is given.
valueThe value of the species amount.
unitsThe units of the species amount (must be convertible to mol)
titrantThe titrant that controls the species amount.
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesMass ( std::string  species,
double  value,
std::string  units 
) -> EquilibriumInverseProblem&

Fix the mass of a species at equilibrium.

Parameters
speciesThe name of the species for which its amount is given.
valueThe value of the species mass.
unitsThe units of the species mass (must be convertible to kg)
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesMass ( std::string  species,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the mass of a species at equilibrium with given titrant.

Parameters
speciesThe name of the species for which its amount is given.
valueThe value of the species amount (in units of kg).
unitsThe units of the species mass (must be convertible to kg)
titrantThe titrant that controls the species mass.
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesActivity ( std::string  species,
double  value 
) -> EquilibriumInverseProblem&

Fix the activity of a species at equilibrium.

Parameters
speciesThe name of the species for which its activity is given.
valueThe value of the species activity.
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesActivity ( std::string  species,
double  value,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the activity of a species at equilibrium with given titrant.

Parameters
speciesThe name of the species for which its activity is given.
valueThe value of the species activity.
titrantThe titrant that controls the species activity.
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesActivity ( std::string  species,
double  value,
std::string  titrant1,
std::string  titrant2 
) -> EquilibriumInverseProblem&

Fix the activity of a species at equilibrium with either one of the two given titrants.

Parameters
speciesThe name of the species for which its activity is given.
valueThe value of the species activity.
titrant1The first titrant that might control the species activity.
titrant2The second titrant that might control the species activity.
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesFugacity ( std::string  species,
double  value,
std::string  units 
) -> EquilibriumInverseProblem&

Fix the fugacity of a gaseous species.

Parameters
speciesThe name of the gaseous species.
valueThe value of the species fugacity.
unitsThe units of the species fugacity (must be convertible to Pa).
auto Reaktoro::EquilibriumInverseProblem::fixSpeciesFugacity ( std::string  species,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the fugacity of a gaseous species with given titrant.

Parameters
speciesThe name of the gaseous species.
valueThe value of the species fugacity.
unitsThe units of the species fugacity (must be convertible to Pa).
titrantThe titrant that controls the fugacity value.
auto Reaktoro::EquilibriumInverseProblem::fixPhaseAmount ( std::string  phase,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the total molar amount of a phase at equilibrium with given titrant.

Parameters
phaseThe name of the phase for which its total molar amount is given.
valueThe value of the phase total amount
unitsThe units of the amount (must be convertible to mol)
titrantThe titrant that controls the phase amount.
auto Reaktoro::EquilibriumInverseProblem::fixPhaseMass ( std::string  phase,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the total mass of a phase at equilibrium with given titrant.

Parameters
phaseThe name of the phase for which its total mass is given.
valueThe value of the phase mass
unitsThe units of the phase mass (must be convertible to kg)
titrantThe titrant that controls the phase mass.
auto Reaktoro::EquilibriumInverseProblem::fixPhaseVolume ( std::string  phase,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the volume of a phase at equilibrium with given titrant.

Parameters
phaseThe name of the phase for which its volume is given.
valueThe value of the phase volume
unitsThe units of the phase volume (must be convertible to m3)
titrantThe titrant that controls the phase volume.
auto Reaktoro::EquilibriumInverseProblem::fixPhaseSetVolume ( const std::vector< std::string > &  phases,
double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the total volume of a set of phases at equilibrium with given titrant.

Parameters
phasesThe names of the phases composing the phase set.
valueThe value of the total volume of the phase set (in units of m3)
unitsThe units of the total volume of the phase set (must be convertible to m3)
titrantThe titrant that controls the total volume of the phase set.
auto Reaktoro::EquilibriumInverseProblem::pH ( double  value) -> EquilibriumInverseProblem&

Fix the pH of the aqueous solution.

Parameters
valueThe pH value of the aqueous solution.
auto Reaktoro::EquilibriumInverseProblem::pH ( double  value,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the pH of the aqueous solution with given titrant.

Parameters
valueThe pH value of the aqueous solution.
titrantThe titrant that control the solution pH.
auto Reaktoro::EquilibriumInverseProblem::pH ( double  value,
std::string  titrant1,
std::string  titrant2 
) -> EquilibriumInverseProblem&

Fix the pH of the aqueous solution with either one of the two given titrants.

Parameters
valueThe pH value of the aqueous solution.
titrant1The first titrant that might control the solution pH.
titrant2The second titrant that might control the solution pH.
auto Reaktoro::EquilibriumInverseProblem::pE ( double  value) -> EquilibriumInverseProblem&

Fix the pe of the aqueous solution.

Parameters
valueThe pe value of the aqueous solution.
auto Reaktoro::EquilibriumInverseProblem::pE ( double  value,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the pe of the aqueous solution with given half reaction.

Parameters
valueThe pe value of the aqueous solution.
titrantThe titrant that control the solution pE.
auto Reaktoro::EquilibriumInverseProblem::Eh ( double  value,
std::string  units 
) -> EquilibriumInverseProblem&

Fix the Eh of the aqueous solution (in units of volts).

Parameters
valueThe Eh value of the aqueous solution.
auto Reaktoro::EquilibriumInverseProblem::Eh ( double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the Eh of the aqueous solution with given half reaction.

Parameters
valueThe Eh value of the aqueous solution.
unitsThe units of the Eh of the aqueous solution (must be convertible to V).
titrantThe titrant that control the solution Eh.
auto Reaktoro::EquilibriumInverseProblem::alkalinity ( double  value,
std::string  units,
std::string  titrant 
) -> EquilibriumInverseProblem&

Fix the total alkalinity of the aqueous solution.

Parameters
valueThe value of the total alkalinity of the aqueous solution.
unitsThe units of the total alkalinity (must be convertible to eq/L).
titrantThe titrant that control the solution alkalinity.
auto Reaktoro::EquilibriumInverseProblem::formulaMatrixTitrants ( ) const -> Matrix

Return the formula matrix of the titrants.

The formula matrix of the titrants is defined as the matrix whose (j,i)th entry contains the stoichiometric coefficient of jth element in the ith titrant. Its dimension is E x T, where T is the number of titrants.

auto Reaktoro::EquilibriumInverseProblem::elementInitialAmounts ( ) const -> Vector

Return the initial amounts of elements in the equilibrium partition.

These are the values of element amounts in the equilibrium partition before unknown amounts of titrants are added.

auto Reaktoro::EquilibriumInverseProblem::residualEquilibriumConstraints ( const Vector x,
const ChemicalState state 
) const -> ResidualEquilibriumConstraints

Return the residuals of the equilibrium constraints and their partial derivatives.

Parameters
xThe amounts of the titrants (in units of mol)
stateThe chemical state of the system
auto Reaktoro::EquilibriumInverseProblem::solve ( ChemicalState state) -> EquilibriumResult

Solve the inverse equilibrium problem.

Parameters
stateThe initial guess for the final chemical state solution.

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