chemmisol 0.1
|
#include <species.h>
Public Member Functions | |
ChemicalComponent (ChemicalSpecies *species, std::size_t index, double total_quantity) | |
ChemicalSpecies * | getSpecies () |
const ChemicalSpecies * | getSpecies () const |
std::size_t | getIndex () const |
virtual bool | isFixed () const |
double | getTotalQuantity () const |
void | setTotalQuantity (double quantity) |
void | setTotalConcentration (double concentration) |
Describes a chemical component that can be used to define reactions in a chemical system.
Any component is automatically associated to a ChemicalSpecies with the same name.
A reaction system is defined from two kinds of chemical species: components and compounds.
A component is a canonical species that cannot be divided, i.e. that cannot be expressed as a species produced from other components. On the other hand, compound species can always be expressed from components. It is the responsibility of the user to properly specify components and reactions in a ChemicalSystem so that the reaction system is consistent. Exceptions such as MissingProducedSpeciesInReaction or InvalidSpeciesInReaction might be thrown when it is not the case.
Chemical components are notably associated to a total quantity, a very important concept in the context of equilibrium solving.
When a component is fixed, the quantity of its associated species is always equal to the total quantity of the component.
Otherwise, the total quantity of a component is defined as the sum of the quantity of species associated to the component itself and the quantities of all species compound from this component, weighted by the stoichiometric coefficient associated to the component in the reaction producing exactly one unit of the compound.
Solvents (such as H2O) are currently considered as fixed components in Chemmisol.
Let's define a system with the following components: H+ and PO4.
The following reactions can be defined to introduce the OH- and H3PO4 produced species as follows:
H2O <-> OH- + H+ PO4 + 3H+ <-> H3PO4
The first reaction can be rewritten as follows so that it produces exactly one unit of OH-:
H2O - H+ <-> OH-
The total quantity N of the PO4 and H+ components are then defined as follows:
N(PO4) = n(PO4) + n(H3PO4) N(H+) = n(H+) - n(OH-) + 3 * n(H3PO4)
where n denotes the quantity of each chemical species. Notice that n(PO4) and n(H+) denote the quantities of PO4 and H+ species, that are likely not equal to total quantities of PO4 and H+ components.
It is the purpose of the ChemicalSystem equilibrium solver to dispatch the total quantities of components between compound species so that the above relations actually holds. This constraint is known in physics as the law of conservation of mass. See ChemicalSystem::massConservationLaw() for more details.
|
inline |
Defines a ChemicalComponent.
species | The chemical species instance associated to this component. |
index | Index used to retrieve the component in data structures used internally by the ChemicalSystem. The index can also be used to uniquely identify each component of a system. |
total_quantity | Initial total quantity of the component. |
|
inline |
Returns a reference to the species associated to this component.
|
inline |
Returns a reference to the species associated to this component.
|
inline |
Index used to retrieve the component in data structures used internally by the ChemicalSystem. The index can also be used to uniquely identify each component of a system.
|
inlinevirtual |
Returns true if this component is fixed. Returns false by default, but can be overridden by subclasses.
Reimplemented in chemmisol::FixedChemicalComponent.
|
inline |
Returns the total quantity of this component.
|
inline |
Sets the total quantity of this component.
When the component is part of a ChemicalSystem, ChemicalSystem::setTotalQuantity() should be used.
|
inline |
Sets the total quantity of the component to a quantity that corresponds to the quantity of the associated species at the provided concentration.
Equivalent to setTotalQuantity(species->quantity(concentration))
.
When the component is part of a ChemicalSystem, ChemicalSystem::setTotalConcentration() should be used.