MultiPhase.cpp Source File#
MultiPhase.cpp
Go to the documentation of this file.
Chemical equilibrium.
Headers for the MultiPhase object that is used to set up multiphase equilibrium problems (see Chemica...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Base class for exceptions thrown by Cantera classes.
Definition ctexceptions.h:66
void resize(size_t n, size_t m, double v=0.0) override
Resize the matrix.
Definition DenseMatrix.cpp:60
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 MultiPhase.cpp:160
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 phas...
Definition MultiPhase.h:226
bool solutionSpecies(size_t kGlob) const
Return true is species kGlob is a species in a multicomponent solution phase.
Definition MultiPhase.cpp:260
double nAtoms(const size_t kGlob, const size_t mGlob) const
Returns the Number of atoms of global element mGlob in global species kGlob.
Definition MultiPhase.cpp:751
void setMolesByName(const Composition &xMap)
Set the number of moles of species in the mixture.
Definition MultiPhase.cpp:342
void setMoles(const double *n)
Sets all of the global species mole numbers.
Definition MultiPhase.cpp:374
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
Definition MultiPhase.cpp:732
double speciesMoles(size_t kGlob) const
Returns the moles of global species k. units = kmol.
Definition MultiPhase.cpp:174
void getValidChemPotentials(double not_mu, double *mu, bool standard=false) const
Returns a vector of Valid chemical potentials.
Definition MultiPhase.cpp:241
vector< size_t > m_spstart
Vector of ints containing of first species index in the global list of species for each phase.
Definition MultiPhase.h:598
vector< size_t > m_spphase
Mapping between the global species number and the phase ID.
Definition MultiPhase.h:590
void getMoles(double *molNum) const
Get the mole numbers of all species in the multiphase object.
Definition MultiPhase.cpp:359
double minTemp() const
Minimum temperature for which all solution phases have valid thermo data.
Definition MultiPhase.h:246
vector< double > m_moleFractions
Locally stored vector of mole fractions of all species comprising the MultiPhase object.
Definition MultiPhase.h:583
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.
Definition MultiPhase.cpp:470
void checkPhaseArraySize(size_t mm) const
Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases().
Definition MultiPhase.cpp:167
vector< bool > m_temp_OK
Vector of bools indicating whether temperatures are ok for phases.
Definition MultiPhase.h:641
double phaseCharge(size_t p) const
Charge (Coulombs) of phase with index p.
Definition MultiPhase.cpp:220
int phaseIndex(const string &pName) const
Returns the index, given the phase name.
Definition MultiPhase.cpp:766
size_t m_eloc
Global ID of the element corresponding to the electronic charge.
Definition MultiPhase.h:634
void getChemPotentials(double *mu) const
Returns a vector of Chemical potentials.
Definition MultiPhase.cpp:231
double moleFraction(const size_t kGlob) const
Returns the mole fraction of global species k.
Definition MultiPhase.cpp:791
bool tempOK(size_t p) const
Return true if the phase p has valid thermo data for the current temperature.
Definition MultiPhase.cpp:796
void addPhases(vector< ThermoPhase * > &phases, const vector< double > &phaseMoles)
Add a vector of phases to the mixture.
Definition MultiPhase.cpp:30
map< string, size_t > m_enamemap
Returns the global element index, given the element string name.
Definition MultiPhase.h:615
void addSpeciesMoles(const int indexS, const double addedMoles)
Adds moles of a certain species to the mixture.
Definition MultiPhase.cpp:404
size_t elementIndex(const string &name) const
Returns the index of the element with name name.
Definition MultiPhase.cpp:722
void checkElementArraySize(size_t mm) const
Check that an array size is at least nElements().
Definition MultiPhase.cpp:710
size_t speciesPhaseIndex(const size_t kGlob) const
Returns the phase index of the Kth "global" species.
Definition MultiPhase.cpp:786
void setState_TPMoles(const double T, const double Pres, const double *Moles)
Set the state of the underlying ThermoPhase objects in one call.
Definition MultiPhase.cpp:423
string speciesName(const size_t kGlob) const
Name of species with global index kGlob.
Definition MultiPhase.cpp:746
double phaseMoles(const size_t n) const
Return the number of moles in phase n.
Definition MultiPhase.cpp:776
void getMoleFractions(double *const x) const
Returns the global Species mole fractions.
Definition MultiPhase.cpp:756
void setPhaseMoleFractions(const size_t n, const double *const x)
Set the Mole fractions of the nth phase.
Definition MultiPhase.cpp:329
void uploadMoleFractionsFromPhases()
Update the locally-stored composition within this object to match the current compositions of the pha...
Definition MultiPhase.cpp:801
bool m_init
True if the init() routine has been called, and the MultiPhase frozen.
Definition MultiPhase.h:630
double m_Tmin
Minimum temperature for which thermo parameterizations are valid.
Definition MultiPhase.h:645
void updatePhases() const
Set the states of the phase objects to the locally-stored state within this MultiPhase object.
Definition MultiPhase.cpp:812
void getElemAbundances(double *elemAbundances) const
Retrieves a vector of element abundances.
Definition MultiPhase.cpp:430
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
Definition MultiPhase.cpp:739
string phaseName(const size_t iph) const
Returns the name of the n'th phase.
Definition MultiPhase.cpp:761
void setState_TP(const double T, const double Pres)
Set the state of the underlying ThermoPhase objects in one call.
Definition MultiPhase.cpp:413
void checkElementIndex(size_t m) const
Check that the specified element index is in range.
Definition MultiPhase.cpp:703
string elementName(size_t m) const
Returns the name of the global element m.
Definition MultiPhase.cpp:717
void setPhaseMoles(const size_t n, const double moles)
Set the number of moles of phase with index n.
Definition MultiPhase.cpp:781
double elementMoles(size_t m) const
Total moles of global element m, summed over all phases.
Definition MultiPhase.cpp:180
double m_Tmax
Minimum temperature for which thermo parameterizations are valid.
Definition MultiPhase.h:649
size_t elementIndex(const string &name) const
Return the index of element named 'name'.
Definition Phase.cpp:55
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition Phase.cpp:434
double nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition Phase.cpp:103
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
Definition ThermoPhase.h:451
virtual void setState_TPX(double t, double p, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
Definition ThermoPhase.cpp:85
virtual string report(bool show_thermo=true, double threshold=-1e-14) const
returns a summary of the state of the phase as a string
Definition ThermoPhase.cpp:1277
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Definition ThermoPhase.h:504
Cantera's Interface to the Multiphase chemical equilibrium solver.
Definition vcs_MultiPhaseEquil.h:31
int equilibrate(int XY, int estimateEquil=0, int printLvl=0, double err=1.0e-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object.
Definition vcs_MultiPhaseEquil.cpp:362
Composition parseCompString(const string &ss, const vector< string > &names)
Parse a composition string into a map consisting of individual key:composition pairs.
Definition stringUtils.cpp:58
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.
Definition MultiPhase.cpp:630
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition ThermoPhase.h:1661
void debuglog(const string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
Definition global.h:158
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition ct_defs.h:164
std::ostream & operator<<(std::ostream &s, const Array2D &m)
Output the current contents of the Array2D object.
Definition Array.cpp:100
const U & getValue(const map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a map.
Definition utilities.h:190
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...
Interface class for the vcsnonlinear solver.
Generated by