Multiphase chemical equilibrium solver. More...
#include <MultiPhaseEquil.h>
Multiphase chemical equilibrium solver.
Class MultiPhaseEquil is designed to be used to set a mixture containing one or more phases to a state of chemical equilibrium. It implements the VCS algorithm, described in Smith and Missen [44].
This class only handles chemical equilibrium at a specified temperature and pressure. To compute equilibrium holding other properties fixed, it is necessary to iterate on T and P in an "outer" loop, until the specified properties have the desired values. This is done, for example, in method equilibrate of class MultiPhase.
This class is primarily meant to be used internally by the equilibrate method of class MultiPhase, although there is no reason it cannot be used directly in application programs if desired.
Definition at line 32 of file MultiPhaseEquil.h.
Public Member Functions | |
MultiPhaseEquil (MultiPhase *mix, bool start=true, int loglevel=0) | |
Construct a multiphase equilibrium manager for a multiphase mixture. | |
size_t | constituent (size_t m) |
void | getStoichVector (size_t rxn, vector< double > &nu) |
int | iterations () |
double | equilibrate (int XY, double err=1.0e-9, int maxsteps=1000, int loglevel=-99) |
double | error () |
string | reactionString (size_t j) |
void | setInitialMixMoles (int loglevel=0) |
size_t | componentIndex (size_t n) |
void | reportCSV (const string &reportFile) |
double | phaseMoles (size_t iph) const |
Protected Member Functions | |
void | getComponents (const vector< size_t > &order) |
This method finds a set of component species and a complete set of formation reactions for the non-components in terms of the components. | |
int | setInitialMoles (int loglevel=0) |
Estimate the initial mole numbers. | |
void | computeN () |
double | stepComposition (int loglevel=0) |
Take one step in composition, given the gradient of G at the starting point, and a vector of reaction steps dxi. | |
void | unsort (vector< double > &x) |
Re-arrange a vector of species properties in sorted form (components first) into unsorted, sequential form. | |
void | step (double omega, vector< double > &deltaN, int loglevel=0) |
double | computeReactionSteps (vector< double > &dxi) |
Compute the change in extent of reaction for each reaction. | |
void | updateMixMoles () |
void | finish () |
Clean up the composition. | |
double | moles (size_t ns) const |
double & | moles (size_t ns) |
int | solutionSpecies (size_t n) const |
bool | isStoichPhase (size_t n) const |
double | mu (size_t n) const |
string | speciesName (size_t n) const |
size_t | nFree () const |
Number of degrees of freedom. | |
Protected Attributes | |
size_t | m_nel_mix |
size_t | m_nsp_mix |
size_t | m_nel = 0 |
size_t | m_nsp = 0 |
size_t | m_eloc = 1000 |
int | m_iter |
MultiPhase * | m_mix |
double | m_press |
double | m_temp |
vector< size_t > | m_order |
DenseMatrix | m_N |
DenseMatrix | m_A |
vector< double > | m_work |
vector< double > | m_work2 |
vector< double > | m_work3 |
vector< double > | m_moles |
vector< double > | m_lastmoles |
vector< double > | m_dxi |
vector< double > | m_deltaG_RT |
vector< double > | m_mu |
vector< bool > | m_majorsp |
vector< size_t > | m_sortindex |
vector< int > | m_lastsort |
vector< int > | m_dsoln |
vector< int > | m_incl_element |
vector< int > | m_incl_species |
vector< size_t > | m_species |
vector< size_t > | m_element |
vector< bool > | m_solnrxn |
bool | m_force = true |
MultiPhaseEquil | ( | MultiPhase * | mix, |
bool | start = true , |
||
int | loglevel = 0 |
||
) |
Construct a multiphase equilibrium manager for a multiphase mixture.
mix | Pointer to a multiphase mixture object. |
start | If true, the initial composition will be determined by a linear Gibbs minimization, otherwise the initial mixture composition will be used. |
loglevel | Desired level of debug printing. loglevel = 0 suppresses printing. Higher values request more verbose logging output. |
Definition at line 18 of file MultiPhaseEquil.cpp.
|
inlinevirtual |
Definition at line 44 of file MultiPhaseEquil.h.
|
inline |
Definition at line 46 of file MultiPhaseEquil.h.
|
inline |
Definition at line 54 of file MultiPhaseEquil.h.
|
inline |
Definition at line 64 of file MultiPhaseEquil.h.
double equilibrate | ( | int | XY, |
double | err = 1.0e-9 , |
||
int | maxsteps = 1000 , |
||
int | loglevel = -99 |
||
) |
Definition at line 155 of file MultiPhaseEquil.cpp.
double error | ( | ) |
Definition at line 626 of file MultiPhaseEquil.cpp.
|
inline |
Definition at line 72 of file MultiPhaseEquil.h.
|
inline |
Definition at line 75 of file MultiPhaseEquil.h.
|
inline |
Definition at line 80 of file MultiPhaseEquil.h.
void reportCSV | ( | const string & | reportFile | ) |
Definition at line 658 of file MultiPhaseEquil.cpp.
double phaseMoles | ( | size_t | iph | ) | const |
Definition at line 653 of file MultiPhaseEquil.cpp.
|
protected |
This method finds a set of component species and a complete set of formation reactions for the non-components in terms of the components.
In most cases, many different component sets are possible, and therefore neither the components returned by this method nor the formation reactions are unique. The algorithm used here is described in Smith and Missen [44].
The component species are taken to be the first M species in array 'species' that have linearly-independent compositions.
order | On entry, vector order should contain species index numbers in the order of decreasing desirability as a component. For example, if it is desired to choose the components from among the major species, this array might list species index numbers in decreasing order of mole fraction. If array 'species' does not have length = nSpecies(), then the species will be considered as candidates to be components in declaration order, beginning with the first phase added. |
Definition at line 249 of file MultiPhaseEquil.cpp.
|
protected |
Estimate the initial mole numbers.
This is done by running each reaction as far forward or backward as possible, subject to the constraint that all mole numbers remain non-negative. Reactions for which \( \Delta \mu^0 \) are positive are run in reverse, and ones for which it is negative are run in the forward direction. The end result is equivalent to solving the linear programming problem of minimizing the linear Gibbs function subject to the element and non- negativity constraints.
Definition at line 192 of file MultiPhaseEquil.cpp.
|
protected |
Definition at line 591 of file MultiPhaseEquil.cpp.
|
protected |
Take one step in composition, given the gradient of G at the starting point, and a vector of reaction steps dxi.
Definition at line 425 of file MultiPhaseEquil.cpp.
|
protected |
Re-arrange a vector of species properties in sorted form (components first) into unsorted, sequential form.
Definition at line 392 of file MultiPhaseEquil.cpp.
|
protected |
Definition at line 400 of file MultiPhaseEquil.cpp.
|
protected |
Compute the change in extent of reaction for each reaction.
Definition at line 508 of file MultiPhaseEquil.cpp.
|
protected |
Definition at line 174 of file MultiPhaseEquil.cpp.
|
protected |
Clean up the composition.
The solution algorithm can leave some species in stoichiometric condensed phases with very small negative mole numbers. This method simply sets these to zero.
Definition at line 183 of file MultiPhaseEquil.cpp.
|
inlineprotected |
Definition at line 142 of file MultiPhaseEquil.h.
|
inlineprotected |
Definition at line 145 of file MultiPhaseEquil.h.
|
inlineprotected |
Definition at line 148 of file MultiPhaseEquil.h.
|
inlineprotected |
Definition at line 151 of file MultiPhaseEquil.h.
|
inlineprotected |
Definition at line 154 of file MultiPhaseEquil.h.
|
inlineprotected |
Definition at line 157 of file MultiPhaseEquil.h.
|
inlineprotected |
Number of degrees of freedom.
Definition at line 163 of file MultiPhaseEquil.h.
|
protected |
Definition at line 167 of file MultiPhaseEquil.h.
|
protected |
Definition at line 167 of file MultiPhaseEquil.h.
|
protected |
Definition at line 168 of file MultiPhaseEquil.h.
|
protected |
Definition at line 169 of file MultiPhaseEquil.h.
|
protected |
Definition at line 170 of file MultiPhaseEquil.h.
|
protected |
Definition at line 171 of file MultiPhaseEquil.h.
|
protected |
Definition at line 172 of file MultiPhaseEquil.h.
|
protected |
Definition at line 173 of file MultiPhaseEquil.h.
|
protected |
Definition at line 173 of file MultiPhaseEquil.h.
|
protected |
Definition at line 174 of file MultiPhaseEquil.h.
|
protected |
Definition at line 175 of file MultiPhaseEquil.h.
|
protected |
Definition at line 175 of file MultiPhaseEquil.h.
|
protected |
Definition at line 176 of file MultiPhaseEquil.h.
|
protected |
Definition at line 176 of file MultiPhaseEquil.h.
|
protected |
Definition at line 176 of file MultiPhaseEquil.h.
|
protected |
Definition at line 177 of file MultiPhaseEquil.h.
|
protected |
Definition at line 177 of file MultiPhaseEquil.h.
|
protected |
Definition at line 177 of file MultiPhaseEquil.h.
|
protected |
Definition at line 178 of file MultiPhaseEquil.h.
|
protected |
Definition at line 178 of file MultiPhaseEquil.h.
|
protected |
Definition at line 179 of file MultiPhaseEquil.h.
|
protected |
Definition at line 180 of file MultiPhaseEquil.h.
|
protected |
Definition at line 181 of file MultiPhaseEquil.h.
|
protected |
Definition at line 182 of file MultiPhaseEquil.h.
|
protected |
Definition at line 183 of file MultiPhaseEquil.h.
|
protected |
Definition at line 183 of file MultiPhaseEquil.h.
|
protected |
Definition at line 187 of file MultiPhaseEquil.h.
|
protected |
Definition at line 188 of file MultiPhaseEquil.h.
|
protected |
Definition at line 189 of file MultiPhaseEquil.h.
|
protected |
Definition at line 190 of file MultiPhaseEquil.h.