Cantera 2.6.0

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MultiPhaseEquil Class Reference
Chemical Equilibrium

`#include <MultiPhaseEquil.h>`

Collaboration diagram for MultiPhaseEquil:
[legend]

## Public Member Functions
| MultiPhaseEquil (MultiPhase *mix, bool start=true, int loglevel=0)
| Construct a multiphase equilibrium manager for a multiphase mixture. More...
size_t | constituent (size_t m)
void | getStoichVector (size_t rxn, vector_fp &nu)
int | iterations ()
doublereal | equilibrate (int XY, doublereal err=1.0e-9, int maxsteps=1000, int loglevel=-99)
doublereal | error ()
std::string | reactionString (size_t j)
void | setInitialMixMoles (int loglevel=0)
size_t | componentIndex (size_t n)
void | reportCSV (const std::string &reportFile)
double | phaseMoles (size_t iph) const

## Protected Member Functions
void | getComponents (const std::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. More...
int | setInitialMoles (int loglevel=0)
| Estimate the initial mole numbers. More...
void | computeN ()
doublereal | 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. More...
void | unsort (vector_fp &x)
| Re-arrange a vector of species properties in sorted form (components first) into unsorted, sequential form. More...
void | step (doublereal omega, vector_fp &deltaN, int loglevel=0)
doublereal | computeReactionSteps (vector_fp &dxi)
| Compute the change in extent of reaction for each reaction. More...
void | updateMixMoles ()
void | finish ()
| Clean up the composition. More...
double | moles (size_t ns) const
double & | moles (size_t ns)
int | solutionSpecies (size_t n) const
bool | isStoichPhase (size_t n) const
doublereal | mu (size_t n) const
std::string | speciesName (size_t n) const
size_t | nFree () const
| Number of degrees of freedom. More...

## Protected Attributes
size_t | m_nel_mix
size_t | m_nsp_mix
size_t | m_nel
size_t | m_nsp
size_t | m_eloc
int | m_iter
MultiPhase * | m_mix
doublereal | m_press
doublereal | m_temp
std::vector< size_t > | m_order
DenseMatrix | m_N
DenseMatrix | m_A
vector_fp | m_work
vector_fp | m_work2
vector_fp | m_work3
vector_fp | m_moles
vector_fp | m_lastmoles
vector_fp | m_dxi
vector_fp | m_deltaG_RT
vector_fp | m_mu
std::vector< bool > | m_majorsp
std::vector< size_t > | m_sortindex
vector_int | m_lastsort
vector_int | m_dsoln
vector_int | m_incl_element
vector_int | m_incl_species
std::vector< size_t > | m_species
std::vector< size_t > | m_element
std::vector< bool > | m_solnrxn
bool | m_force

## Detailed Description

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, "Chemical Reaction Equilibrium."

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.

## Constructor & Destructor Documentation

## ◆ MultiPhaseEquil()

MultiPhaseEquil | ( | MultiPhase * | mix,
|  | bool | start = `true`,
|  | int | loglevel = `0`
| ) |  |

Construct a multiphase equilibrium manager for a multiphase mixture.

Parameters

  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 20 of file MultiPhaseEquil.cpp.

References Array2D::data(), MultiPhase::elementMoles(), MultiPhase::elementName(), Cantera::multiply(), MultiPhase::nAtoms(), MultiPhase::nElements(), MultiPhaseEquil::nFree(), MultiPhase::nSpecies(), MultiPhase::pressure(), DenseMatrix::resize(), MultiPhaseEquil::setInitialMoles(), MultiPhase::solutionSpecies(), MultiPhase::speciesMoles(), MultiPhase::speciesName(), MultiPhase::speciesPhaseIndex(), MultiPhase::temperature(), MultiPhase::tempOK(), and MultiPhaseEquil::unsort().

## ◆ ~MultiPhaseEquil()

virtual ~MultiPhaseEquil | ( |  | ) |
| inline virtual

Definition at line 44 of file MultiPhaseEquil.h.

## Member Function Documentation

## ◆ constituent()

size_t constituent | ( | size_t | m | ) |
| inline

Definition at line 46 of file MultiPhaseEquil.h.

## ◆ getStoichVector()

void getStoichVector | ( | size_t | rxn,
|  | vector_fp & | nu
| ) |  |
| inline

Definition at line 54 of file MultiPhaseEquil.h.

## ◆ iterations()

int iterations | ( |  | ) |
| inline

Definition at line 64 of file MultiPhaseEquil.h.

## ◆ equilibrate()

doublereal equilibrate | ( | int | XY,
|  | doublereal | err = `1.0e-9`,
|  | int | maxsteps = `1000`,
|  | int | loglevel = `-99`
| ) |  |

Definition at line 161 of file MultiPhaseEquil.cpp.

## ◆ error()

doublereal error | ( |  | ) |

Definition at line 635 of file MultiPhaseEquil.cpp.

## ◆ reactionString()

std::string reactionString | ( | size_t | j | ) |
| inline

Definition at line 72 of file MultiPhaseEquil.h.

## ◆ setInitialMixMoles()

void setInitialMixMoles | ( | int | loglevel = `0` | ) |
| inline

Definition at line 75 of file MultiPhaseEquil.h.

## ◆ componentIndex()

size_t componentIndex | ( | size_t | n | ) |
| inline

Definition at line 80 of file MultiPhaseEquil.h.

## ◆ reportCSV()

void reportCSV | ( | const std::string & | reportFile | ) |

Definition at line 667 of file MultiPhaseEquil.cpp.

## ◆ phaseMoles()

double phaseMoles | ( | size_t | iph | ) | const

Definition at line 662 of file MultiPhaseEquil.cpp.

## ◆ getComponents()

void getComponents | ( | const std::vector< size_t > & | order | ) |
| 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, Chemical Reaction Equilibrium Analysis.

The component species are taken to be the first M species in array 'species' that have linearly-independent compositions.

Parameters

  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 256 of file MultiPhaseEquil.cpp.

References MultiPhase::nAtoms(), MultiPhaseEquil::nFree(), Cantera::npos, MultiPhase::solutionSpecies(), and Cantera::Tiny.

## ◆ setInitialMoles()

int setInitialMoles | ( | int | loglevel = `0` | ) |
| 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 199 of file MultiPhaseEquil.cpp.

References MultiPhase::getValidChemPotentials(), and MultiPhaseEquil::nFree().

Referenced by MultiPhaseEquil::MultiPhaseEquil().

## ◆ computeN()

void computeN | ( |  | ) |
| protected

Definition at line 599 of file MultiPhaseEquil.cpp.

## ◆ stepComposition()

doublereal stepComposition | ( | int | loglevel = `0` | ) |
| 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 433 of file MultiPhaseEquil.cpp.

References MultiPhaseEquil::computeReactionSteps(), MultiPhase::getValidChemPotentials(), Cantera::multiply(), MultiPhaseEquil::nFree(), Cantera::Tiny, and MultiPhaseEquil::unsort().

## ◆ unsort()

void unsort | ( | vector_fp & | x | ) |
| protected

Re-arrange a vector of species properties in sorted form (components first) into unsorted, sequential form.

Definition at line 399 of file MultiPhaseEquil.cpp.

Referenced by MultiPhaseEquil::MultiPhaseEquil(), and MultiPhaseEquil::stepComposition().

## ◆ step()

void step | ( | doublereal | omega,
|  | vector_fp & | deltaN,
|  | int | loglevel = `0`
| ) |  |
| protected

Definition at line 407 of file MultiPhaseEquil.cpp.

## ◆ computeReactionSteps()

doublereal computeReactionSteps | ( | vector_fp & | dxi | ) |
| protected

Compute the change in extent of reaction for each reaction.

Definition at line 516 of file MultiPhaseEquil.cpp.

References Cantera::GasConstant, MultiPhase::getValidChemPotentials(), MultiPhaseEquil::nFree(), MultiPhase::nPhases(), Phase::nSpecies(), MultiPhase::phase(), MultiPhase::phaseMoles(), MultiPhase::speciesMoles(), MultiPhase::speciesPhaseIndex(), and Cantera::Tiny.

Referenced by MultiPhaseEquil::stepComposition().

## ◆ updateMixMoles()

void updateMixMoles | ( |  | ) |
| protected

Definition at line 181 of file MultiPhaseEquil.cpp.

## ◆ finish()

void finish | ( |  | ) |
| 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 190 of file MultiPhaseEquil.cpp.

References MultiPhase::setMoles().

## ◆ moles() [1/2]

double moles | ( | size_t | ns | ) | const
| inline protected

Definition at line 142 of file MultiPhaseEquil.h.

## ◆ moles() [2/2]

double & moles | ( | size_t | ns | ) |
| inline protected

Definition at line 145 of file MultiPhaseEquil.h.

## ◆ solutionSpecies()

int solutionSpecies | ( | size_t | n | ) | const
| inline protected

Definition at line 148 of file MultiPhaseEquil.h.

## ◆ isStoichPhase()

bool isStoichPhase | ( | size_t | n | ) | const
| inline protected

Definition at line 151 of file MultiPhaseEquil.h.

## ◆ mu()

doublereal mu | ( | size_t | n | ) | const
| inline protected

Definition at line 154 of file MultiPhaseEquil.h.

## ◆ speciesName()

std::string speciesName | ( | size_t | n | ) | const
| inline protected

Definition at line 157 of file MultiPhaseEquil.h.

## ◆ nFree()

size_t nFree | ( |  | ) | const
| inline protected

Number of degrees of freedom.

Definition at line 163 of file MultiPhaseEquil.h.

Referenced by MultiPhaseEquil::computeReactionSteps(), MultiPhaseEquil::getComponents(), MultiPhaseEquil::MultiPhaseEquil(), MultiPhaseEquil::setInitialMoles(), and MultiPhaseEquil::stepComposition().

## Member Data Documentation

## ◆ m_nel_mix

size_t m_nel_mix
| protected

Definition at line 167 of file MultiPhaseEquil.h.

## ◆ m_nsp_mix

size_t m_nsp_mix
| protected

Definition at line 167 of file MultiPhaseEquil.h.

## ◆ m_nel

size_t m_nel
| protected

Definition at line 168 of file MultiPhaseEquil.h.

## ◆ m_nsp

size_t m_nsp
| protected

Definition at line 168 of file MultiPhaseEquil.h.

## ◆ m_eloc

size_t m_eloc
| protected

Definition at line 169 of file MultiPhaseEquil.h.

## ◆ m_iter

int m_iter
| protected

Definition at line 170 of file MultiPhaseEquil.h.

## ◆ m_mix

MultiPhase* m_mix
| protected

Definition at line 171 of file MultiPhaseEquil.h.

## ◆ m_press

doublereal m_press
| protected

Definition at line 172 of file MultiPhaseEquil.h.

## ◆ m_temp

doublereal m_temp
| protected

Definition at line 172 of file MultiPhaseEquil.h.

## ◆ m_order

std::vector<size_t> m_order
| protected

Definition at line 173 of file MultiPhaseEquil.h.

## ◆ m_N

DenseMatrix m_N
| protected

Definition at line 174 of file MultiPhaseEquil.h.

## ◆ m_A

DenseMatrix m_A
| protected

Definition at line 174 of file MultiPhaseEquil.h.

## ◆ m_work

vector_fp m_work
| protected

Definition at line 175 of file MultiPhaseEquil.h.

## ◆ m_work2

vector_fp m_work2
| protected

Definition at line 175 of file MultiPhaseEquil.h.

## ◆ m_work3

vector_fp m_work3
| protected

Definition at line 175 of file MultiPhaseEquil.h.

## ◆ m_moles

vector_fp m_moles
| protected

Definition at line 176 of file MultiPhaseEquil.h.

## ◆ m_lastmoles

vector_fp m_lastmoles
| protected

Definition at line 176 of file MultiPhaseEquil.h.

## ◆ m_dxi

vector_fp m_dxi
| protected

Definition at line 176 of file MultiPhaseEquil.h.

## ◆ m_deltaG_RT

vector_fp m_deltaG_RT
| protected

Definition at line 177 of file MultiPhaseEquil.h.

## ◆ m_mu

vector_fp m_mu
| protected

Definition at line 177 of file MultiPhaseEquil.h.

## ◆ m_majorsp

std::vector<bool> m_majorsp
| protected

Definition at line 178 of file MultiPhaseEquil.h.

## ◆ m_sortindex

std::vector<size_t> m_sortindex
| protected

Definition at line 179 of file MultiPhaseEquil.h.

## ◆ m_lastsort

vector_int m_lastsort
| protected

Definition at line 180 of file MultiPhaseEquil.h.

## ◆ m_dsoln

vector_int m_dsoln
| protected

Definition at line 181 of file MultiPhaseEquil.h.

## ◆ m_incl_element

vector_int m_incl_element
| protected

Definition at line 182 of file MultiPhaseEquil.h.

## ◆ m_incl_species

vector_int m_incl_species
| protected

Definition at line 182 of file MultiPhaseEquil.h.

## ◆ m_species

std::vector<size_t> m_species
| protected

Definition at line 186 of file MultiPhaseEquil.h.

## ◆ m_element

std::vector<size_t> m_element
| protected

Definition at line 187 of file MultiPhaseEquil.h.

## ◆ m_solnrxn

std::vector<bool> m_solnrxn
| protected

Definition at line 188 of file MultiPhaseEquil.h.

## ◆ m_force

bool m_force
| protected

Definition at line 189 of file MultiPhaseEquil.h.

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

- MultiPhaseEquil.h
- MultiPhaseEquil.cpp