Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
ReactionEquation Class Reference

A type used to represent the equation of a reaction. More...

#include <ReactionEquation.hpp>

Public Member Functions

 ReactionEquation ()
 Construct a default ReactionEquation object.
 
 ReactionEquation (Pairs< Species, double > const &species)
 Construct an ReactionEquation object with given species and respective stoichiometric coefficients.
 
 ReactionEquation (String const &equation, SpeciesList const &species)
 Construct a ReactionEquation object by parsing a formatted string. More...
 
auto empty () const -> bool
 Return true if the rection equation is empty.
 
auto size () const -> Index
 Return the number of species in the reaction equation.
 
auto species () const -> Vec< Species >
 Return the species in the reaction equation.
 
auto coefficients () const -> Vec< double >
 Return the stoichiometric coefficients of the species in the reaction equation.
 
auto coefficient (const String &name) const -> double
 Return the stoichiometric coefficient of a species in the reaction equation.
 
 operator String () const
 Convert this ReactionEquation object into a string.
 
auto begin () const
 Return begin const iterator of this ReactionEquation object (for STL compatibility reasons).
 
auto begin ()
 Return begin iterator of this ReactionEquation object (for STL compatibility reasons).
 
auto end () const
 Return end const iterator of this ReactionEquation object (for STL compatibility reasons).
 
auto end ()
 Return end iterator of this ReactionEquation object (for STL compatibility reasons).
 
 ReactionEquation (String const &equation)
 Construct a ReactionEquation object by parsing a formatted string. More...
 
 ReactionEquation (Chars equation)
 

Detailed Description

A type used to represent 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-";
ReactionEquation()
Construct a default ReactionEquation object.

Constructor & Destructor Documentation

◆ ReactionEquation() [1/2]

ReactionEquation ( String const &  equation)

Construct a ReactionEquation object by parsing a formatted string.

Below are examples of how to create a ReactionEquation object 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 stoichiometric coefficients can be ommited from the equation. The operator * must be used when this is not the case.

◆ ReactionEquation() [2/2]

ReactionEquation ( String const &  equation,
SpeciesList const &  species 
)

Construct a ReactionEquation object by parsing a formatted string.

This method is similar to ReactionEquation(String const&), but the Species objects in the constructed ReactionEquation object are fetched from a given list of species.


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