Cantera  3.1.0a1
Loading...
Searching...
No Matches
MultiPhase Class Reference

A class for multiphase mixtures. More...

#include <MultiPhase.h>

Detailed Description

A class for multiphase mixtures.

The mixture can contain any number of phases of any type.

This object is the basic tool used by Cantera for use in Multiphase equilibrium calculations.

It is a container for a set of phases. Each phase has a given number of kmoles. Therefore, MultiPhase may be considered an "extrinsic" thermodynamic object, in contrast to the ThermoPhase object, which is an "intrinsic" thermodynamic object.

MultiPhase may be considered to be "upstream" of the ThermoPhase objects in the sense that setting a property within MultiPhase, such as temperature, pressure, or species mole number, affects the underlying ThermoPhase object, but not the other way around.

All phases have the same temperature and pressure, and a specified number of moles for each phase. The phases do not need to have the same elements. For example, a mixture might consist of a gaseous phase with elements (H, C, O, N), a solid carbon phase containing only element C, etc. A master element set will be constructed for the mixture that is the intersection of the elements of each phase.

Below, reference is made to global species and global elements. These refer to the collective species and elements encompassing all of the phases tracked by the object.

The global element list kept by this object is an intersection of the element lists of all the phases that comprise the MultiPhase.

The global species list kept by this object is a concatenated list of all of the species in all the phases that comprise the MultiPhase. The ordering of species is contiguous with respect to the phase id.

Definition at line 56 of file MultiPhase.h.

Public Member Functions

 MultiPhase ()=default
 Constructor.
 
virtual ~MultiPhase ()=default
 Destructor.
 
void addPhases (vector< ThermoPhase * > &phases, const vector< double > &phaseMoles)
 Add a vector of phases to the mixture.
 
void addPhases (MultiPhase &mix)
 Add all phases present in 'mix' to this mixture.
 
void addPhase (ThermoPhase *p, double moles)
 Add a phase to the mixture.
 
size_t nElements () const
 Number of elements.
 
void checkElementIndex (size_t m) const
 Check that the specified element index is in range.
 
void checkElementArraySize (size_t mm) const
 Check that an array size is at least nElements().
 
string elementName (size_t m) const
 Returns the name of the global element m.
 
size_t elementIndex (const string &name) const
 Returns the index of the element with name name.
 
size_t nSpecies () const
 Number of species, summed over all phases.
 
void checkSpeciesIndex (size_t k) const
 Check that the specified species index is in range.
 
void checkSpeciesArraySize (size_t kk) const
 Check that an array size is at least nSpecies().
 
string speciesName (const size_t kGlob) const
 Name of species with global index kGlob.
 
double nAtoms (const size_t kGlob, const size_t mGlob) const
 Returns the Number of atoms of global element mGlob in global species kGlob.
 
void getMoleFractions (double *const x) const
 Returns the global Species mole fractions.
 
void init ()
 Process phases and build atomic composition array.
 
string phaseName (const size_t iph) const
 Returns the name of the n'th phase.
 
int phaseIndex (const string &pName) const
 Returns the index, given the phase name.
 
double phaseMoles (const size_t n) const
 Return the number of moles in phase n.
 
void setPhaseMoles (const size_t n, const double moles)
 Set the number of moles of phase with index n.
 
ThermoPhasephase (size_t n)
 Return a reference to phase n.
 
void checkPhaseIndex (size_t m) const
 Check that the specified phase index is in range Throws an exception if m is greater than nPhases()
 
void checkPhaseArraySize (size_t mm) const
 Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases().
 
double speciesMoles (size_t kGlob) const
 Returns the moles of global species k. units = kmol.
 
size_t speciesIndex (size_t k, size_t p) const
 Return the global index of the species belonging to phase number p with local index k within the phase.
 
size_t speciesIndex (const string &speciesName, const string &phaseName)
 Return the global index of the species belonging to phase name phaseName with species name speciesName.
 
double minTemp () const
 Minimum temperature for which all solution phases have valid thermo data.
 
double maxTemp () const
 Maximum temperature for which all solution phases have valid thermo data.
 
double charge () const
 Total charge summed over all phases (Coulombs).
 
double phaseCharge (size_t p) const
 Charge (Coulombs) of phase with index p.
 
double elementMoles (size_t m) const
 Total moles of global element m, summed over all phases.
 
void getChemPotentials (double *mu) const
 Returns a vector of Chemical potentials.
 
void getValidChemPotentials (double not_mu, double *mu, bool standard=false) const
 Returns a vector of Valid chemical potentials.
 
double temperature () const
 Temperature [K].
 
void equilibrate (const string &XY, const string &solver="auto", double rtol=1e-9, int max_steps=50000, int max_iter=100, int estimate_equil=0, int log_level=0)
 Equilibrate a MultiPhase object.
 
void setTemperature (const double T)
 Set the temperature [K].
 
void setState_TP (const double T, const double Pres)
 Set the state of the underlying ThermoPhase objects in one call.
 
void setState_TPMoles (const double T, const double Pres, const double *Moles)
 Set the state of the underlying ThermoPhase objects in one call.
 
double pressure () const
 Pressure [Pa].
 
double volume () const
 The total mixture volume [m^3].
 
void setPressure (double P)
 Set the pressure [Pa].
 
double enthalpy () const
 The enthalpy of the mixture [J].
 
double IntEnergy () const
 The internal energy of the mixture [J].
 
double entropy () const
 The entropy of the mixture [J/K].
 
double gibbs () const
 The Gibbs function of the mixture [J].
 
double cp () const
 Heat capacity at constant pressure [J/K].
 
size_t nPhases () const
 Number of phases.
 
bool solutionSpecies (size_t kGlob) const
 Return true is species kGlob is a species in a multicomponent solution phase.
 
size_t speciesPhaseIndex (const size_t kGlob) const
 Returns the phase index of the Kth "global" species.
 
double moleFraction (const size_t kGlob) const
 Returns the mole fraction of global species k.
 
void setPhaseMoleFractions (const size_t n, const double *const x)
 Set the Mole fractions of the nth phase.
 
void setMolesByName (const Composition &xMap)
 Set the number of moles of species in the mixture.
 
void setMolesByName (const string &x)
 Set the moles via a string containing their names.
 
void getMoles (double *molNum) const
 Get the mole numbers of all species in the multiphase object.
 
void setMoles (const double *n)
 Sets all of the global species mole numbers.
 
void addSpeciesMoles (const int indexS, const double addedMoles)
 Adds moles of a certain species to the mixture.
 
void getElemAbundances (double *elemAbundances) const
 Retrieves a vector of element abundances.
 
bool tempOK (size_t p) const
 Return true if the phase p has valid thermo data for the current temperature.
 
void uploadMoleFractionsFromPhases ()
 Update the locally-stored composition within this object to match the current compositions of the phase objects.
 
void updatePhases () const
 Set the states of the phase objects to the locally-stored state within this MultiPhase object.
 

Private Member Functions

void calcElemAbundances () const
 Calculate the element abundance vector.
 
double equilibrate_MultiPhaseEquil (int XY, double err, int maxsteps, int maxiter, int loglevel)
 Set the mixture to a state of chemical equilibrium using the MultiPhaseEquil solver.
 

Private Attributes

vector< double > m_moles
 Vector of the number of moles in each phase.
 
vector< ThermoPhase * > m_phase
 Vector of the ThermoPhase pointers.
 
DenseMatrix m_atoms
 Global Stoichiometric Coefficient array.
 
vector< double > m_moleFractions
 Locally stored vector of mole fractions of all species comprising the MultiPhase object.
 
vector< size_t > m_spphase
 Mapping between the global species number and the phase ID.
 
vector< size_t > m_spstart
 Vector of ints containing of first species index in the global list of species for each phase.
 
vector< string > m_enames
 String names of the global elements.
 
vector< int > m_atomicNumber
 Atomic number of each global element.
 
vector< string > m_snames
 Vector of species names in the problem.
 
map< string, size_t > m_enamemap
 Returns the global element index, given the element string name.
 
double m_temp = 298.15
 Current value of the temperature (kelvin)
 
double m_press = OneBar
 Current value of the pressure (Pa)
 
size_t m_nel = 0
 Number of distinct elements in all of the phases.
 
size_t m_nsp = 0
 Number of distinct species in all of the phases.
 
bool m_init = false
 True if the init() routine has been called, and the MultiPhase frozen.
 
size_t m_eloc = npos
 Global ID of the element corresponding to the electronic charge.
 
vector< bool > m_temp_OK
 Vector of bools indicating whether temperatures are ok for phases.
 
double m_Tmin = 1.0
 Minimum temperature for which thermo parameterizations are valid.
 
double m_Tmax = 100000.0
 Minimum temperature for which thermo parameterizations are valid.
 
vector< double > m_elemAbundances
 Vector of element abundances.
 

Constructor & Destructor Documentation

◆ MultiPhase()

MultiPhase ( )
default

Constructor.

The constructor takes no arguments, since phases are added using method addPhase().

◆ ~MultiPhase()

virtual ~MultiPhase ( )
virtualdefault

Destructor.

Does nothing. Class MultiPhase does not take "ownership" (that is, responsibility for destroying) the phase objects.

Member Function Documentation

◆ addPhases() [1/2]

void addPhases ( vector< ThermoPhase * > &  phases,
const vector< double > &  phaseMoles 
)

Add a vector of phases to the mixture.

See the single addPhases command. This just does a bunch of phases at one time

Parameters
phasesVector of pointers to phases
phaseMolesVector of mole numbers in each phase (kmol)

Definition at line 30 of file MultiPhase.cpp.

◆ addPhases() [2/2]

void addPhases ( MultiPhase mix)

Add all phases present in 'mix' to this mixture.

Parameters
mixAdd all of the phases in another MultiPhase object to the current object.

Definition at line 23 of file MultiPhase.cpp.

◆ addPhase()

void addPhase ( ThermoPhase p,
double  moles 
)

Add a phase to the mixture.

This function must be called before the init() function is called, which serves to freeze the MultiPhase.

Parameters
ppointer to the phase object
molestotal number of moles of all species in this phase

Definition at line 39 of file MultiPhase.cpp.

◆ nElements()

size_t nElements ( ) const
inline

Number of elements.

Definition at line 97 of file MultiPhase.h.

◆ checkElementIndex()

void checkElementIndex ( size_t  m) const

Check that the specified element index is in range.

Throws an exception if m is greater than nElements()-1

Definition at line 703 of file MultiPhase.cpp.

◆ checkElementArraySize()

void checkElementArraySize ( size_t  mm) const

Check that an array size is at least nElements().

Throws an exception if mm is less than nElements(). Used before calls which take an array pointer.

Definition at line 710 of file MultiPhase.cpp.

◆ elementName()

string elementName ( size_t  m) const

Returns the name of the global element m.

Parameters
mindex of the global element

Definition at line 717 of file MultiPhase.cpp.

◆ elementIndex()

size_t elementIndex ( const string &  name) const

Returns the index of the element with name name.

Parameters
nameString name of the global element

Definition at line 722 of file MultiPhase.cpp.

◆ nSpecies()

size_t nSpecies ( ) const
inline

Number of species, summed over all phases.

Definition at line 123 of file MultiPhase.h.

◆ checkSpeciesIndex()

void checkSpeciesIndex ( size_t  k) const

Check that the specified species index is in range.

Throws an exception if k is greater than nSpecies()-1

Definition at line 732 of file MultiPhase.cpp.

◆ checkSpeciesArraySize()

void checkSpeciesArraySize ( size_t  kk) const

Check that an array size is at least nSpecies().

Throws an exception if kk is less than nSpecies(). Used before calls which take an array pointer.

Definition at line 739 of file MultiPhase.cpp.

◆ speciesName()

string speciesName ( const size_t  kGlob) const

Name of species with global index kGlob.

Parameters
kGlobglobal species index

Definition at line 746 of file MultiPhase.cpp.

◆ nAtoms()

double nAtoms ( const size_t  kGlob,
const size_t  mGlob 
) const

Returns the Number of atoms of global element mGlob in global species kGlob.

Parameters
kGlobglobal species index
mGlobglobal element index
Returns
the number of atoms.

Definition at line 751 of file MultiPhase.cpp.

◆ getMoleFractions()

void getMoleFractions ( double *const  x) const

Returns the global Species mole fractions.

Write the array of species mole fractions into array x. The mole fractions are normalized to sum to one in each phase.

Parameters
xvector of mole fractions. Length = number of global species.

Definition at line 756 of file MultiPhase.cpp.

◆ init()

void init ( )

Process phases and build atomic composition array.

This method must be called after all phases are added, before doing anything else with the mixture. After init() has been called, no more phases may be added.

Definition at line 106 of file MultiPhase.cpp.

◆ phaseName()

string phaseName ( const size_t  iph) const

Returns the name of the n'th phase.

Parameters
iphphase Index

Definition at line 761 of file MultiPhase.cpp.

◆ phaseIndex()

int phaseIndex ( const string &  pName) const

Returns the index, given the phase name.

Parameters
pNameName of the phase
Returns
the index. A value of -1 means the phase isn't in the object.

Definition at line 766 of file MultiPhase.cpp.

◆ phaseMoles()

double phaseMoles ( const size_t  n) const

Return the number of moles in phase n.

Parameters
nIndex of the phase.

Definition at line 776 of file MultiPhase.cpp.

◆ setPhaseMoles()

void setPhaseMoles ( const size_t  n,
const double  moles 
)

Set the number of moles of phase with index n.

Parameters
nIndex of the phase
molesNumber of moles in the phase (kmol)

Definition at line 781 of file MultiPhase.cpp.

◆ phase()

ThermoPhase & phase ( size_t  n)

Return a reference to phase n.

The state of phase n is also updated to match the state stored locally in the mixture object.

Parameters
nPhase Index
Returns
Reference to the ThermoPhase object for the phase

Definition at line 149 of file MultiPhase.cpp.

◆ checkPhaseIndex()

void checkPhaseIndex ( size_t  m) const

Check that the specified phase index is in range Throws an exception if m is greater than nPhases()

Definition at line 160 of file MultiPhase.cpp.

◆ checkPhaseArraySize()

void checkPhaseArraySize ( size_t  mm) const

Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases().

Used before calls which take an array pointer.

Definition at line 167 of file MultiPhase.cpp.

◆ speciesMoles()

double speciesMoles ( size_t  kGlob) const

Returns the moles of global species k. units = kmol.

Parameters
kGlobGlobal species index k

Definition at line 174 of file MultiPhase.cpp.

◆ speciesIndex() [1/2]

size_t speciesIndex ( size_t  k,
size_t  p 
) const
inline

Return the global index of the species belonging to phase number p with local index k within the phase.

Parameters
klocal index of the species within the phase
pindex of the phase

Definition at line 226 of file MultiPhase.h.

◆ speciesIndex() [2/2]

size_t speciesIndex ( const string &  speciesName,
const string &  phaseName 
)

Return the global index of the species belonging to phase name phaseName with species name speciesName.

Parameters
speciesNameSpecies Name
phaseNamePhase Name
Returns
the global index

If the species or phase name is not recognized, this routine throws a CanteraError.

Definition at line 204 of file MultiPhase.cpp.

◆ minTemp()

double minTemp ( ) const
inline

Minimum temperature for which all solution phases have valid thermo data.

Stoichiometric phases are not considered, since they may have thermo data only valid for conditions for which they are stable.

Definition at line 246 of file MultiPhase.h.

◆ maxTemp()

double maxTemp ( ) const
inline

Maximum temperature for which all solution phases have valid thermo data.

Stoichiometric phases are not considered, since they may have thermo data only valid for conditions for which they are stable.

Definition at line 253 of file MultiPhase.h.

◆ charge()

double charge ( ) const

Total charge summed over all phases (Coulombs).

Definition at line 195 of file MultiPhase.cpp.

◆ phaseCharge()

double phaseCharge ( size_t  p) const

Charge (Coulombs) of phase with index p.

The net charge is computed as

\[ Q_p = N_p \sum_k F z_k X_k \]

where the sum runs only over species in phase p.

Parameters
pindex of the phase for which the charge is desired.

Definition at line 220 of file MultiPhase.cpp.

◆ elementMoles()

double elementMoles ( size_t  m) const

Total moles of global element m, summed over all phases.

Parameters
mIndex of the global element

Definition at line 180 of file MultiPhase.cpp.

◆ getChemPotentials()

void getChemPotentials ( double *  mu) const

Returns a vector of Chemical potentials.

Write into array mu the chemical potentials of all species [J/kmol]. The chemical potentials are related to the activities by

\( \mu_k = \mu_k^0(T, P) + RT \ln a_k. \).

Parameters
muChemical potential vector. Length = num global species. Units = J/kmol.

Definition at line 231 of file MultiPhase.cpp.

◆ getValidChemPotentials()

void getValidChemPotentials ( double  not_mu,
double *  mu,
bool  standard = false 
) const

Returns a vector of Valid chemical potentials.

Write into array mu the chemical potentials of all species with thermo data valid for the current temperature [J/kmol]. For other species, set the chemical potential to the value not_mu. If standard is set to true, then the values returned are standard chemical potentials.

This method is designed for use in computing chemical equilibrium by Gibbs minimization. For solution phases (more than one species), this does the same thing as getChemPotentials. But for stoichiometric phases, this writes into array mu the user-specified value not_mu instead of the chemical potential if the temperature is outside the range for which the thermo data for the one species in the phase are valid. The need for this arises since many condensed phases have thermo data fit only for the temperature range for which they are stable. For example, in the NASA database, the fits for H2O(s) are only done up to 0 C, the fits for H2O(L) are only done from 0 C to 100 C, etc. Using the polynomial fits outside the range for which the fits were done can result in spurious chemical potentials, and can lead to condensed phases appearing when in fact they should be absent.

By setting not_mu to a large positive value, it is possible to force routines which seek to minimize the Gibbs free energy of the mixture to zero out any phases outside the temperature range for which their thermo data are valid.

Parameters
not_muValue of the chemical potential to set species in phases, for which the thermo data is not valid
muVector of chemical potentials. length = Global species, units = J kmol-1
standardIf this method is called with standard set to true, then the composition-independent standard chemical potentials are returned instead of the composition- dependent chemical potentials.

Definition at line 241 of file MultiPhase.cpp.

◆ temperature()

double temperature ( ) const
inline

Temperature [K].

Definition at line 328 of file MultiPhase.h.

◆ setTemperature()

void setTemperature ( const double  T)

Set the temperature [K].

Parameters
Tvalue of the temperature (Kelvin)

Definition at line 694 of file MultiPhase.cpp.

◆ setState_TP()

void setState_TP ( const double  T,
const double  Pres 
)

Set the state of the underlying ThermoPhase objects in one call.

Parameters
TTemperature of the system (kelvin)
Prespressure of the system (pascal)

Definition at line 413 of file MultiPhase.cpp.

◆ setState_TPMoles()

void setState_TPMoles ( const double  T,
const double  Pres,
const double *  Moles 
)

Set the state of the underlying ThermoPhase objects in one call.

Parameters
TTemperature of the system (kelvin)
Prespressure of the system (pascal)
MolesVector of mole numbers of all the species in all the phases (kmol)

Definition at line 423 of file MultiPhase.cpp.

◆ pressure()

double pressure ( ) const
inline

Pressure [Pa].

Definition at line 388 of file MultiPhase.h.

◆ volume()

double volume ( ) const

The total mixture volume [m^3].

Returns the cumulative sum of the volumes of all the phases in the mixture.

Definition at line 460 of file MultiPhase.cpp.

◆ setPressure()

void setPressure ( double  P)
inline

Set the pressure [Pa].

Parameters
PSet the pressure in the MultiPhase object (Pa)

Definition at line 403 of file MultiPhase.h.

◆ enthalpy()

double enthalpy ( ) const

The enthalpy of the mixture [J].

Definition at line 281 of file MultiPhase.cpp.

◆ IntEnergy()

double IntEnergy ( ) const

The internal energy of the mixture [J].

Definition at line 293 of file MultiPhase.cpp.

◆ entropy()

double entropy ( ) const

The entropy of the mixture [J/K].

Definition at line 305 of file MultiPhase.cpp.

◆ gibbs()

double gibbs ( ) const

The Gibbs function of the mixture [J].

Definition at line 269 of file MultiPhase.cpp.

◆ cp()

double cp ( ) const

Heat capacity at constant pressure [J/K].

Note that this does not account for changes in composition of the mixture with temperature.

Definition at line 317 of file MultiPhase.cpp.

◆ nPhases()

size_t nPhases ( ) const
inline

Number of phases.

Definition at line 425 of file MultiPhase.h.

◆ solutionSpecies()

bool solutionSpecies ( size_t  kGlob) const

Return true is species kGlob is a species in a multicomponent solution phase.

Parameters
kGlobindex of the global species

Definition at line 260 of file MultiPhase.cpp.

◆ speciesPhaseIndex()

size_t speciesPhaseIndex ( const size_t  kGlob) const

Returns the phase index of the Kth "global" species.

Parameters
kGlobGlobal species index.
Returns
the index of the owning phase.

Definition at line 786 of file MultiPhase.cpp.

◆ moleFraction()

double moleFraction ( const size_t  kGlob) const

Returns the mole fraction of global species k.

Parameters
kGlobIndex of the global species.

Definition at line 791 of file MultiPhase.cpp.

◆ setPhaseMoleFractions()

void setPhaseMoleFractions ( const size_t  n,
const double *const  x 
)

Set the Mole fractions of the nth phase.

This function sets the mole fractions of the nth phase. Note, the mole number of the phase stays constant

Parameters
nindex of the phase
xVector of input mole fractions.

Definition at line 329 of file MultiPhase.cpp.

◆ setMolesByName() [1/2]

void setMolesByName ( const Composition xMap)

Set the number of moles of species in the mixture.

Parameters
xMapComposition of the species with nonzero mole numbers. Mole numbers that are less than or equal to zero will be set to zero. units = kmol.

Definition at line 342 of file MultiPhase.cpp.

◆ setMolesByName() [2/2]

void setMolesByName ( const string &  x)

Set the moles via a string containing their names.

The string x is in the form of a composition map. Species which are not listed are set to zero.

Parameters
xstring x in the form of a composition map where values are the moles of the species.

Definition at line 352 of file MultiPhase.cpp.

◆ getMoles()

void getMoles ( double *  molNum) const

Get the mole numbers of all species in the multiphase object.

Parameters
[out]molNumVector of doubles of length nSpecies() containing the global mole numbers (kmol).

Definition at line 359 of file MultiPhase.cpp.

◆ setMoles()

void setMoles ( const double *  n)

Sets all of the global species mole numbers.

The state of each phase object is also updated to have the specified composition and the mixture temperature and pressure.

Parameters
nVector of doubles of length nSpecies() containing the global mole numbers (kmol).

Definition at line 374 of file MultiPhase.cpp.

◆ addSpeciesMoles()

void addSpeciesMoles ( const int  indexS,
const double  addedMoles 
)

Adds moles of a certain species to the mixture.

Parameters
indexSIndex of the species in the MultiPhase object
addedMolesValue of the moles that are added to the species.

Definition at line 404 of file MultiPhase.cpp.

◆ getElemAbundances()

void getElemAbundances ( double *  elemAbundances) const

Retrieves a vector of element abundances.

Parameters
elemAbundancesVector of element abundances Length = number of elements in the MultiPhase object. Index is the global element index. Units is in kmol.

Definition at line 430 of file MultiPhase.cpp.

◆ tempOK()

bool tempOK ( size_t  p) const

Return true if the phase p has valid thermo data for the current temperature.

Parameters
pIndex of the phase.

Definition at line 796 of file MultiPhase.cpp.

◆ uploadMoleFractionsFromPhases()

void uploadMoleFractionsFromPhases ( )

Update the locally-stored composition within this object to match the current compositions of the phase objects.

Query the underlying ThermoPhase objects for their mole fractions and fill in the mole fraction vector of this current object. Adjust element compositions within this object to match.

This is an upload operation in the sense that we are taking downstream information (ThermoPhase object info) and applying it to an upstream object (MultiPhase object).

Definition at line 801 of file MultiPhase.cpp.

◆ updatePhases()

void updatePhases ( ) const

Set the states of the phase objects to the locally-stored state within this MultiPhase object.

This method sets each phase to the mixture temperature and pressure, and sets the phase mole fractions based on the mixture mole numbers.

This is an download operation in the sense that we are taking upstream object information (MultiPhase object) and applying it to downstream objects (ThermoPhase object information)

Therefore, the term, "update", is appropriate for a downstream operation.

Definition at line 812 of file MultiPhase.cpp.

◆ calcElemAbundances()

void calcElemAbundances ( ) const
private

Calculate the element abundance vector.

Definition at line 438 of file MultiPhase.cpp.

◆ equilibrate_MultiPhaseEquil()

double equilibrate_MultiPhaseEquil ( int  XY,
double  err,
int  maxsteps,
int  maxiter,
int  loglevel 
)
private

Set the mixture to a state of chemical equilibrium using the MultiPhaseEquil solver.

Parameters
XYInteger flag specifying properties to hold fixed.
errError tolerance for \( \Delta \mu/RT \) for all reactions. Also used as the relative error tolerance for the outer loop.
maxstepsMaximum number of steps to take in solving the fixed TP problem.
maxiterMaximum number of "outer" iterations for problems holding fixed something other than (T,P).
loglevelLevel of diagnostic output

Definition at line 470 of file MultiPhase.cpp.

Member Data Documentation

◆ m_moles

vector<double> m_moles
private

Vector of the number of moles in each phase.

Length = m_np, number of phases.

Definition at line 568 of file MultiPhase.h.

◆ m_phase

vector<ThermoPhase*> m_phase
private

Vector of the ThermoPhase pointers.

Definition at line 571 of file MultiPhase.h.

◆ m_atoms

DenseMatrix m_atoms
private

Global Stoichiometric Coefficient array.

This is a two dimensional array m_atoms(m, k). The first index is the global element index. The second index, k, is the global species index. The value is the number of atoms of type m in species k.

Definition at line 579 of file MultiPhase.h.

◆ m_moleFractions

vector<double> m_moleFractions
private

Locally stored vector of mole fractions of all species comprising the MultiPhase object.

Definition at line 583 of file MultiPhase.h.

◆ m_spphase

vector<size_t> m_spphase
private

Mapping between the global species number and the phase ID.

m_spphase[kGlobal] = iPhase Length = number of global species

Definition at line 590 of file MultiPhase.h.

◆ m_spstart

vector<size_t> m_spstart
private

Vector of ints containing of first species index in the global list of species for each phase.

kfirst = m_spstart[ip], kfirst is the index of the first species in the ip'th phase.

Definition at line 598 of file MultiPhase.h.

◆ m_enames

vector<string> m_enames
private

String names of the global elements.

This has a length equal to the number of global elements.

Definition at line 602 of file MultiPhase.h.

◆ m_atomicNumber

vector<int> m_atomicNumber
private

Atomic number of each global element.

Definition at line 605 of file MultiPhase.h.

◆ m_snames

vector<string> m_snames
private

Vector of species names in the problem.

Vector is over all species defined in the object, the global species index.

Definition at line 609 of file MultiPhase.h.

◆ m_enamemap

map<string, size_t> m_enamemap
private

Returns the global element index, given the element string name.

-> used in the construction. However, wonder if it needs to be global.

Definition at line 615 of file MultiPhase.h.

◆ m_temp

double m_temp = 298.15
private

Current value of the temperature (kelvin)

Definition at line 618 of file MultiPhase.h.

◆ m_press

double m_press = OneBar
private

Current value of the pressure (Pa)

Definition at line 621 of file MultiPhase.h.

◆ m_nel

size_t m_nel = 0
private

Number of distinct elements in all of the phases.

Definition at line 624 of file MultiPhase.h.

◆ m_nsp

size_t m_nsp = 0
private

Number of distinct species in all of the phases.

Definition at line 627 of file MultiPhase.h.

◆ m_init

bool m_init = false
private

True if the init() routine has been called, and the MultiPhase frozen.

Definition at line 630 of file MultiPhase.h.

◆ m_eloc

size_t m_eloc = npos
private

Global ID of the element corresponding to the electronic charge.

If there is none, then this is equal to -1

Definition at line 634 of file MultiPhase.h.

◆ m_temp_OK

vector<bool> m_temp_OK
mutableprivate

Vector of bools indicating whether temperatures are ok for phases.

If the current temperature is outside the range of valid temperatures for the phase thermodynamics, the phase flag is set to false.

Definition at line 641 of file MultiPhase.h.

◆ m_Tmin

double m_Tmin = 1.0
private

Minimum temperature for which thermo parameterizations are valid.

Stoichiometric phases are ignored in this determination. units Kelvin

Definition at line 645 of file MultiPhase.h.

◆ m_Tmax

double m_Tmax = 100000.0
private

Minimum temperature for which thermo parameterizations are valid.

Stoichiometric phases are ignored in this determination. units Kelvin

Definition at line 649 of file MultiPhase.h.

◆ m_elemAbundances

vector<double> m_elemAbundances
mutableprivate

Vector of element abundances.

m_elemAbundances[mGlobal] = kmol of element mGlobal summed over all species in all phases.

Definition at line 656 of file MultiPhase.h.


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