chemmisol 0.1
|
#include <solver.h>
Public Member Functions | |
F (const ChemicalSystem &system) | |
std::size_t | xSize () const |
X | reducedActivities () const |
X | completeActivities (const X &reduced_activities) const |
const std::vector< std::size_t > & | componentsIndexes () const |
std::size_t | reactionOffset () const |
const std::vector< std::size_t > & | speciesIndexes () const |
X | f (const X &reduced_activities) const |
M | df (const X &reduced_activities) const |
Static Public Attributes | |
static const std::size_t | INVALID_INDEX = -1 |
Function used in the Newton method to find the equilibrium state of the ChemicalSystem. See the definition of f() for detailed explanation on the solved equation system.
chemmisol::solver::F< X, M >::F | ( | const ChemicalSystem & | system | ) |
Initializes a function F to find the equilibrium of the provided chemical system.
system | Chemical system to solve. |
Returns the reduced vector of activities.
The reduced vector corresponds to an initial vector A such that A[i] equals the activities of species with index i, from which all entries that corresponds to species associated to fixed components have been removed.
In consequence, it is not guaranteed that A[i] corresponds to the activity of the species with index i, but A[speciesIndexes()[i]] can be used to retrieve the activity of species i if it's not associated to a fixed component.
The complete vector of activities can be rebuilt from the reduced activities using the completeActivities() method.
X chemmisol::solver::F< X, M >::completeActivities | ( | const X & | reduced_activities | ) | const |
Rebuilds a complete vector activity from a reducedActivities() vector, so that the built vector A is such that for any species A[i] equals the activity of species with index i.
Activities for species that are not fixed are taken from the specified reduced_activities vector, and activities for species associated to fixed components are taken from the solved chemical system.
reduced_activities | Reduced vector of activities, without entries for species associated to fixed components. |
|
inline |
Maps the indexes of components to indexes in the f() vector.
If componentsIndexes()[i] is equal to INVALID_INDEX, no entry is available for the component with index i in the f() vector (i.e. the component i is fixed).
Else, f(a)[speciesIndexes()[i]] returns the result of the ChemicalSystem::massConservationLaw() for the component with index i considering the current activities a.
|
inline |
Offset used to retrieve distance to equilibrium of reactions in the f() vector, so that f(a)[reactionOffset()+i] corresponds to the distance to equilibrium for the reaction with index i.
|
inline |
Maps the indexes of species to indexes in the reducedActivities() vector.
If speciesIndex()[i] is equal to INVALID_INDEX, no entry is available for the species with index i in the reduced vector (i.e. the species i is associated to a fixed component).
Else, A[speciesIndexes()[i]] returns the activity of species with index i in the reducedActivity() vector A.
X chemmisol::solver::F< X, M >::f | ( | const X & | reduced_activities | ) | const |
Returns the value of f for the provided reduced activities.
The values of f are of the same size as the vector of reduced activities, and as the following form:
m_0 ... m_n e_0 ... e_p
where:
Considering the definitions of the law of conservation of mass and of the law of mass action, finding the equilibrium state of the chemical system corresponds to find activities such that f(activities)=0
.
reduced_activities | Current activities for species not associated to a fixed component. |
M chemmisol::solver::F< X, M >::df | ( | const X & | reduced_activities | ) | const |
Computes the Jacobian matrix of f() for the specified reduced_activities.
Since the expressions of both the ChemicalSystem::massConservationLaw() and ChemicalSystem::distanceToEquilibrium() are polynomial functions of the reduced activities, it is straightforward to compute the partial derivatives of f().
|
static |
Special index value used to specify that no entry exist for some species.