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

Detailed Description

Define a type that describes the equation of a reaction.

The equation of a reaction is assumed as a sequence of pairs (species, stoichiometry). It is shown below how the equation of reaction \(\mathrm{CO_{2}(g)+H_{2}O\rightleftharpoons H^{+}+HCO_{3}^{-}}\) can be defined by two equivalent ways:

ReactionEquation equation1 = {{"CO2(g)", -1}, {"H2O(l)", -1}, {"H+", 1}, {"HCO3-", 1}};
ReactionEquation equation2 = "CO2(g) + H2O(l) = H+ + HCO3-";

#include <ReactionEquation.hpp>

Public Member Functions

 ReactionEquation ()
 Construct a default ReactionEquation instance.
 
 ReactionEquation (std::string equation)
 Construct a ReactionEquation instance by parsing a string. More...
 
 ReactionEquation (const std::map< std::string, double > &equation)
 Construct a ReactionEquation instance from a list of species names and a list of stoichiometries. More...
 
auto empty () const -> bool
 Return true if the rection equation is empty.
 
auto numSpecies () const -> unsigned
 Return the number of species in the reaction equation.
 
auto stoichiometry (std::string species) const -> double
 Return the stoichiometry of a species in the reaction equation. More...
 
auto equation () const -> const std::map< std::string, double > &
 Return the reaction equation as a map of species names and stoichiometries.
 
 operator std::string () const
 Convert the ReactionEquation instance into a string.
 

Constructor & Destructor Documentation

Reaktoro::ReactionEquation::ReactionEquation ( std::string  equation)

Construct a ReactionEquation instance by parsing a string.

Below are examples of how to set a reaction equation via a formatted string.

ReactionEquation equation1("Calcite + H+ = Ca++ + HCO3-");
ReactionEquation equation2("CO2(g) + H2O(l) = H+ + HCO3-");
ReactionEquation equation3("Dolomite + 2*H+ = Ca++ + Mg++ + 2*HCO3-");

Note that unity stoichiometry coefficients can be ommited from the equation. The operator * must be used when this is not the case.

Parameters
equationThe string representing the rection equation
Reaktoro::ReactionEquation::ReactionEquation ( const std::map< std::string, double > &  equation)

Construct a ReactionEquation instance from a list of species names and a list of stoichiometries.

Parameters
speciesThe names of the participating chemical species
coeffsThe stoichiometries of the participating chemical species

Member Function Documentation

auto Reaktoro::ReactionEquation::stoichiometry ( std::string  species) const -> double

Return the stoichiometry of a species in the reaction equation.

Parameters
speciesThe name of the species.

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