chemmisol 0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
chemmisol::solver::F< X, M > Class Template Reference

#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
 

Detailed Description

template<typename X, typename M>
class chemmisol::solver::F< X, M >

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.

Constructor & Destructor Documentation

◆ F()

template<typename X , typename M >
chemmisol::solver::F< X, M >::F ( const ChemicalSystem system)

Initializes a function F to find the equilibrium of the provided chemical system.

Parameters
systemChemical system to solve.

Member Function Documentation

◆ reducedActivities()

template<typename X , typename M >
X chemmisol::solver::F< X, M >::reducedActivities ( ) const

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.

Returns
Vector containing activities of not fixed species in the solved system.

◆ completeActivities()

template<typename X , typename M >
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.

Parameters
reduced_activitiesReduced vector of activities, without entries for species associated to fixed components.
Returns
Vector containing activities of all species.

◆ componentsIndexes()

template<typename X , typename M >
const std::vector< std::size_t > & chemmisol::solver::F< X, M >::componentsIndexes ( ) const
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.

◆ reactionOffset()

template<typename X , typename M >
std::size_t chemmisol::solver::F< X, M >::reactionOffset ( ) const
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.

Note
By construction, the reaction offset is equal to the count of law of conservation of mass equations, i.e. the count of not fixed components.

◆ speciesIndexes()

template<typename X , typename M >
const std::vector< std::size_t > & chemmisol::solver::F< X, M >::speciesIndexes ( ) const
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.

◆ f()

template<typename X , typename M >
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.

Parameters
reduced_activitiesCurrent activities for species not associated to a fixed component.
Returns
Vector value of f, result of the mass conservation law applied to not fixed components and distances to equilibrium of each reaction.

◆ df()

template<typename X , typename M >
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().

Member Data Documentation

◆ INVALID_INDEX

template<typename X , typename M >
const std::size_t chemmisol::solver::F< X, M >::INVALID_INDEX = -1
static

Special index value used to specify that no entry exist for some species.


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