Cantera  2.1.2
Public Member Functions | Protected Attributes | Friends | List of all members
vcs_MultiPhaseEquil Class Reference

Cantera's Interface to the Multiphase chemical equilibrium solver. More...

#include <vcs_MultiPhaseEquil.h>

Collaboration diagram for vcs_MultiPhaseEquil:
[legend]

Public Member Functions

 vcs_MultiPhaseEquil (Cantera::MultiPhase *mix, int printLvl)
 Constructor for the multiphase equilibrium solver. More...
 
size_t component (size_t m) const
 Return the index of the ith component. More...
 
void getStoichVector (size_t rxn, Cantera::vector_fp &nu)
 Get the stoichiometric reaction coefficients for a single reaction index. More...
 
int iterations () const
 return the number of iterations More...
 
int equilibrate (int XY, int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
 Equilibrate the solution using the current element abundances stored in the MultiPhase object. More...
 
int equilibrate_TP (int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
 Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant T and P. More...
 
int equilibrate_HP (doublereal Htarget, int XY, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
 Equilibrate the solution using the current element abundances stored in the MultiPhase object using either constant H and P or constant U and P. More...
 
int equilibrate_SP (doublereal Starget, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
 Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant S and P. More...
 
int equilibrate_TV (int XY, doublereal xtarget, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int logLevel=-99)
 Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant V and constant T, H, U or S. More...
 
int determine_PhaseStability (int iph, double &funcStab, int printLvl=0, int logLevel=-99)
 Determine the phase stability of a phase at the current conditions. More...
 
void reportCSV (const std::string &reportFile)
 Report the equilibrium answer in a comma separated table format. More...
 
size_t numComponents () const
 reports the number of components in the equilibration problem More...
 
size_t numElemConstraints () const
 Reports the number of element constraints in the equilibration problem. More...
 

Protected Attributes

Cantera::vector_int m_order
 Vector that takes into account of the current sorting of the species. More...
 
VCSnonideal::VCS_PROBm_vprob
 Object which contains the problem statement. More...
 
Cantera::MultiPhasem_mix
 Pointer to the MultiPhase mixture that will be equilibrated. More...
 
int m_printLvl
 Print level from the VCSnonlinear package. More...
 
Cantera::DenseMatrix m_N
 Stoichiometric matrix. More...
 
int m_iter
 Iteration Count. More...
 
Cantera::vector_int m_species
 Vector of indices for species that are included in the calculation. More...
 
VCSnonideal::VCS_SOLVEm_vsolvePtr
 Pointer to the object that does all of the equilibration work. More...
 

Friends

int vcs_Cantera_to_vprob (Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
 Translate a MultiPhase object into a VCS_PROB problem definition object. More...
 
int vcs_Cantera_update_vprob (Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
 Translate a MultiPhase information into a VCS_PROB problem definition object. More...
 

Detailed Description

Cantera's Interface to the Multiphase chemical equilibrium solver.

Class vcs_MultiPhaseEquil is designed to be used to set a mixture containing one or more phases to a state of chemical equilibrium.

Note, as currently constructed, the underlying ThermoPhase objects are shared between the MultiPhase object and this object. Therefore, mix is not a const argument, and the return parameters are contained in underlying ThermoPhase objects.

Definition at line 210 of file vcs_MultiPhaseEquil.h.

Constructor & Destructor Documentation

vcs_MultiPhaseEquil ( Cantera::MultiPhase mix,
int  printLvl 
)

Constructor for the multiphase equilibrium solver.

This constructor will initialize the object with a MultiPhase object, setting up the internal equilibration problem. Note, as currently constructed, the underlying ThermoPhase objects are shared between the MultiPhase object and this object. Therefore, mix is not a const argument, and the return parameters are contained in underlying ThermoPhase objects.

Parameters
mixObject containing the MultiPhase object
printLvlDetermines the amount of printing to stdout that occurs for each call:
  • 0: No printing
  • 1: Only printing to the .csv file
  • 2: print the soln only
  • 3: Print the setup and then the soln only
  • 4: Print a table for each iteration
  • 5: Print more than a table for each iteration

Definition at line 43 of file vcs_MultiPhaseEquil.cpp.

References vcs_MultiPhaseEquil::m_mix, VCS_PROB::m_printLvl, vcs_MultiPhaseEquil::m_printLvl, vcs_MultiPhaseEquil::m_vprob, MultiPhase::nElements(), MultiPhase::nPhases(), MultiPhase::nSpecies(), plogf, and vcs_MultiPhaseEquil::vcs_Cantera_to_vprob.

Member Function Documentation

size_t component ( size_t  m) const

Return the index of the ith component.

Returns the index of the ith component in the equilibrium calculation. The index refers to the ordering of the species in the MultiPhase object.

Parameters
mIndex of the component. Must be between 0 and the number of components, which can be obtained from the numComponents() command.

Definition at line 1478 of file vcs_MultiPhaseEquil.cpp.

References VCS_SOLVE::m_speciesMapIndex, vcs_MultiPhaseEquil::m_vsolvePtr, Cantera::npos, and vcs_MultiPhaseEquil::numComponents().

void getStoichVector ( size_t  rxn,
Cantera::vector_fp nu 
)

Get the stoichiometric reaction coefficients for a single reaction index.

This returns a stoichiometric reaction vector for a single formation reaction for a noncomponent species. There are (nSpecies() - nComponents) formation reactions. Each formation reaction will have a value of 1.0 for the species that is being formed, and the other non-zero coefficients will all involve the components of the mixture.

Parameters
rxnReaction number.
nuVector of coefficients for the formation reaction. Length is equal to the number of species in the MultiPhase object.

Definition at line 1437 of file vcs_MultiPhaseEquil.cpp.

References VCS_SOLVE::m_numSpeciesTot, VCS_SOLVE::m_speciesMapIndex, VCS_SOLVE::m_stoichCoeffRxnMatrix, vcs_MultiPhaseEquil::m_vsolvePtr, and vcs_MultiPhaseEquil::numComponents().

int iterations ( ) const
inline

return the number of iterations

Definition at line 267 of file vcs_MultiPhaseEquil.h.

References vcs_MultiPhaseEquil::m_iter.

int equilibrate ( int  XY,
int  estimateEquil = 0,
int  printLvl = 0,
doublereal  err = 1.0e-6,
int  maxsteps = VCS_MAXSTEPS,
int  loglevel = -99 
)

Equilibrate the solution using the current element abundances stored in the MultiPhase object.

Use the vcs algorithm to equilibrate the current multiphase mixture.

Parameters
XYInteger representing what two thermo quantities are held constant during the equilibration
estimateEquilinteger indicating whether the solver should estimate its own initial condition.
  • If 0, the initial mole fraction vector in the ThermoPhase object is used as the initial condition.
  • If 1, the initial mole fraction vector is used if the element abundances are satisfied.
  • if -1, the initial mole fraction vector is thrown out, and an estimate is formulated.
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing).
errInternal error level
maxstepsmax steps allowed.
loglevelDetermines the amount of printing to the HTML output file.

Definition at line 514 of file vcs_MultiPhaseEquil.cpp.

References MultiPhase::enthalpy(), MultiPhase::entropy(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::equilibrate_TV(), MultiPhase::IntEnergy(), vcs_MultiPhaseEquil::m_mix, MultiPhase::maxTemp(), MultiPhase::minTemp(), and MultiPhase::temperature().

Referenced by Cantera::vcs_equilibrate_1().

int equilibrate_TP ( int  estimateEquil = 0,
int  printLvl = 0,
doublereal  err = 1.0e-6,
int  maxsteps = VCS_MAXSTEPS,
int  loglevel = -99 
)

Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant T and P.

Use the vcs algorithm to equilibrate the current multiphase mixture.

Parameters
estimateEquilinteger indicating whether the solver should estimate its own initial condition.
  • If 0, the initial mole fraction vector in the ThermoPhase object is used as the initial condition.
  • If 1, the initial mole fraction vector is used if the element abundances are satisfied.
  • if -1, the initial mole fraction vector is thrown out, and an estimate is formulated.
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing).
errInternal error level
maxstepsmax steps allowed.
loglevelDetermines the amount of printing to the HTML output file.

Definition at line 562 of file vcs_MultiPhaseEquil.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), Cantera::endLogGroup(), VCS_PROB::iest, VCS_PROB::m_gibbsSpecies, vcs_MultiPhaseEquil::m_mix, VCS_PROB::m_printLvl, vcs_MultiPhaseEquil::m_printLvl, VCS_SOLVE::m_timing_print_lvl, VCS_PROB::m_VCS_UnitsFormat, vcs_MultiPhaseEquil::m_vprob, vcs_MultiPhaseEquil::m_vsolvePtr, VCS_PROB::mf, MultiPhase::nElements(), VCS_PROB::NPhase, MultiPhase::nPhases(), VCS_PROB::nspecies, MultiPhase::nSpecies(), Phase::nSpecies(), vcs_VolPhase::nSpecies(), MultiPhase::phase(), VCS_PROB::PhaseID, plogf, VCS_PROB::PresPA, MultiPhase::pressure(), VCS_PROB::prob_report(), clockWC::secondsWC(), MultiPhase::setPhaseMoles(), VCS_PROB::SpeciesUnknownType, VCS_PROB::SpName, VCS_PROB::T, MultiPhase::temperature(), MultiPhase::uploadMoleFractionsFromPhases(), VCS_SOLVE::vcs(), vcs_MultiPhaseEquil::vcs_Cantera_update_vprob, VCS_SPECIES_TYPE_INTERFACIALVOLTAGE, VCS_PROB::VPhaseList, and VCS_PROB::w.

Referenced by vcs_MultiPhaseEquil::equilibrate(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), and vcs_MultiPhaseEquil::equilibrate_TV().

int equilibrate_HP ( doublereal  Htarget,
int  XY,
double  Tlow,
double  Thigh,
int  estimateEquil = 0,
int  printLvl = 0,
doublereal  err = 1.0E-6,
int  maxsteps = VCS_MAXSTEPS,
int  loglevel = -99 
)

Equilibrate the solution using the current element abundances stored in the MultiPhase object using either constant H and P or constant U and P.

Use the vcs algorithm to equilibrate the current multiphase mixture. The pressure of the calculation is taken from the current pressure stored with the MultiPhase object.

Parameters
HtargetValue of the total mixture enthalpy or total internal energy that will be kept constant. Note, this is and must be an extensive quantity. units = Joules
XYInteger flag indicating what is held constant. Must be either HP or UP.
TlowLower limit of the temperature. It's an error condition if the temperature falls below Tlow.
ThighUpper limit of the temperature. It's an error condition if the temperature goes higher than Thigh.
estimateEquilinteger indicating whether the solver should estimate its own initial condition.
  • If 0, the initial mole fraction vector in the ThermoPhase object is used as the initial condition.
  • If 1, the initial mole fraction vector is used if the element abundances are satisfied.
  • if -1, the initial mole fraction vector is thrown out, and an estimate is formulated.
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing). See main constructor call for meaning of the levels.
errInternal error level
maxstepsmax steps allowed.
loglevelDetermines the amount of printing to the HTML output file.

Definition at line 198 of file vcs_MultiPhaseEquil.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), Cantera::endLogGroup(), MultiPhase::enthalpy(), vcs_MultiPhaseEquil::equilibrate_TP(), Cantera::fp2str(), Cantera::int2str(), MultiPhase::IntEnergy(), vcs_MultiPhaseEquil::m_mix, MultiPhase::maxTemp(), MultiPhase::minTemp(), MultiPhase::phaseMoles(), plogendl, plogf, MultiPhase::setTemperature(), MultiPhase::temperature(), and Cantera::Undef.

Referenced by vcs_MultiPhaseEquil::equilibrate(), and vcs_MultiPhaseEquil::equilibrate_TV().

int equilibrate_SP ( doublereal  Starget,
double  Tlow,
double  Thigh,
int  estimateEquil = 0,
int  printLvl = 0,
doublereal  err = 1.0E-6,
int  maxsteps = VCS_MAXSTEPS,
int  loglevel = -99 
)

Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant S and P.

Use the vcs algorithm to equilibrate the current multiphase mixture. The pressure of the calculation is taken from the current pressure stored with the MultiPhase object.

Parameters
StargetValue of the total mixture entropy that will be kept constant. Note, this is and must be an extensive quantity. units = Joules/K
TlowLower limit of the temperature. It's an error condition if the temperature falls below Tlow.
ThighUpper limit of the temperature. It's an error condition if the temperature goes higher than Thigh.
estimateEquilinteger indicating whether the solver should estimate its own initial condition.
  • If 0, the initial mole fraction vector in the ThermoPhase object is used as the initial condition.
  • If 1, the initial mole fraction vector is used if the element abundances are satisfied.
  • If -1, the initial mole fraction vector is thrown out, and an estimate is formulated.
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing). See main constructor call for meaning of the levels.
errInternal error level
maxstepsmax steps allowed.
loglevelDetermines the amount of printing to the HTML output file.

Definition at line 357 of file vcs_MultiPhaseEquil.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), Cantera::endLogGroup(), MultiPhase::entropy(), vcs_MultiPhaseEquil::equilibrate_TP(), Cantera::fp2str(), Cantera::int2str(), vcs_MultiPhaseEquil::m_mix, MultiPhase::maxTemp(), MultiPhase::minTemp(), MultiPhase::phaseMoles(), plogf, MultiPhase::setTemperature(), MultiPhase::temperature(), and Cantera::Undef.

Referenced by vcs_MultiPhaseEquil::equilibrate(), and vcs_MultiPhaseEquil::equilibrate_TV().

int equilibrate_TV ( int  XY,
doublereal  xtarget,
int  estimateEquil = 0,
int  printLvl = 0,
doublereal  err = 1.0E-6,
int  maxsteps = VCS_MAXSTEPS,
int  logLevel = -99 
)

Equilibrate the solution using the current element abundances stored in the MultiPhase object using constant V and constant T, H, U or S.

Use the vcs algorithm to equilibrate the current multiphase mixture. The pressure of the calculation is taken from the current pressure stored with the MultiPhase object.

Parameters
XYInteger flag indicating what is held constant. Must be either TV, HV, UV, or SV.
xtargetValue of the total thermodynamic parameter to be held constant in addition to V. Note, except for T, this must be an extensive quantity. units = Joules/K or Joules
estimateEquilinteger indicating whether the solver should estimate its own initial condition.
  • If 0, the initial mole fraction vector in the ThermoPhase object is used as the initial condition.
  • If 1, the initial mole fraction vector is used if the element abundances are satisfied.
  • if -1, the initial mole fraction vector is thrown out, and an estimate is formulated.
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing). See main constructor call for meaning of the levels.
errInternal error level
maxstepsmax steps allowed.
logLevelDetermines the amount of printing to the HTML output file.

Definition at line 78 of file vcs_MultiPhaseEquil.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), Cantera::endLogGroup(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), vcs_MultiPhaseEquil::equilibrate_TP(), Cantera::fp2str(), Cantera::int2str(), vcs_MultiPhaseEquil::m_mix, MultiPhase::maxTemp(), MultiPhase::minTemp(), MultiPhase::pressure(), MultiPhase::setPressure(), MultiPhase::setTemperature(), and MultiPhase::volume().

Referenced by vcs_MultiPhaseEquil::equilibrate().

int determine_PhaseStability ( int  iph,
double &  funcStab,
int  printLvl = 0,
int  logLevel = -99 
)

Determine the phase stability of a phase at the current conditions.

Equilibration of the solution is not done before the determination is made.

Parameters
iphPhase number to determine the equilibrium. If the phase has a non-zero mole number....
funcStabValue of the phase pop function
printLvlDetermines the amount of printing that gets sent to stdout from the vcs package (Note, you may have to compile with debug flags to get some printing).
logLevelDetermines the amount of printing to the HTML output file.

Definition at line 1488 of file vcs_MultiPhaseEquil.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), DATA_PTR, Cantera::endLogGroup(), MultiPhase::getChemPotentials(), VCS_PROB::m_gibbsSpecies, vcs_MultiPhaseEquil::m_mix, VCS_PROB::m_printLvl, vcs_MultiPhaseEquil::m_printLvl, VCS_SOLVE::m_timing_print_lvl, VCS_PROB::m_VCS_UnitsFormat, vcs_MultiPhaseEquil::m_vprob, vcs_MultiPhaseEquil::m_vsolvePtr, VCS_PROB::mf, MultiPhase::nElements(), MultiPhase::nPhases(), VCS_PROB::nspecies, MultiPhase::nSpecies(), MultiPhase::phaseName(), plogf, VCS_PROB::PresPA, MultiPhase::pressure(), VCS_PROB::prob_report(), clockWC::secondsWC(), VCS_PROB::SpeciesUnknownType, VCS_PROB::SpName, VCS_PROB::T, MultiPhase::temperature(), MultiPhase::uploadMoleFractionsFromPhases(), vcs_MultiPhaseEquil::vcs_Cantera_update_vprob, VCS_SPECIES_TYPE_INTERFACIALVOLTAGE, and VCS_PROB::w.

Referenced by Cantera::vcs_determine_PhaseStability().

void reportCSV ( const std::string &  reportFile)
size_t numComponents ( ) const

reports the number of components in the equilibration problem

Returns
returns the number of components. If an equilibrium problem hasn't been solved yet, it returns -1.

Definition at line 1460 of file vcs_MultiPhaseEquil.cpp.

References VCS_SOLVE::m_numComponents, vcs_MultiPhaseEquil::m_vsolvePtr, and Cantera::npos.

Referenced by vcs_MultiPhaseEquil::component(), and vcs_MultiPhaseEquil::getStoichVector().

size_t numElemConstraints ( ) const

Reports the number of element constraints in the equilibration problem.

Returns
returns the number of element constraints. If an equilibrium problem hasn't been solved yet, it returns -1.

Definition at line 1469 of file vcs_MultiPhaseEquil.cpp.

References VCS_SOLVE::m_numElemConstraints, vcs_MultiPhaseEquil::m_vsolvePtr, and Cantera::npos.

Friends And Related Function Documentation

int vcs_Cantera_to_vprob ( Cantera::MultiPhase mphase,
VCSnonideal::VCS_PROB vprob 
)
friend

Translate a MultiPhase object into a VCS_PROB problem definition object.

Parameters
mphaseMultiPhase object that is the source for all of the information
vprobVCS_PROB problem definition that gets all of the information

Note, both objects share the underlying Thermophase objects. So, neither can be const objects.

Definition at line 895 of file vcs_MultiPhaseEquil.cpp.

Referenced by vcs_MultiPhaseEquil::vcs_MultiPhaseEquil().

int vcs_Cantera_update_vprob ( Cantera::MultiPhase mphase,
VCSnonideal::VCS_PROB vprob 
)
friend

Translate a MultiPhase information into a VCS_PROB problem definition object.

This version updates the problem statement information only. All species and phase definitions remain the same.

Parameters
mphaseMultiPhase object that is the source for all of the information
vprobVCS_PROB problem definition that gets all of the information

Definition at line 1304 of file vcs_MultiPhaseEquil.cpp.

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability(), and vcs_MultiPhaseEquil::equilibrate_TP().

Member Data Documentation

Cantera::vector_int m_order
protected

Vector that takes into account of the current sorting of the species.

The index of m_order is the original k value of the species in the multiphase. The value of m_order, k_sorted, is the current value of the species index.

m_order[korig] = k_sorted

Definition at line 487 of file vcs_MultiPhaseEquil.h.

VCSnonideal::VCS_PROB* m_vprob
protected

Object which contains the problem statement.

The problem statement may contain some subtleties. For example, the element constraints may be different than just an element conservation contraint equations. There may be kinetically frozen degrees of freedom. There may be multiple electrolyte phases with zero charge constraints. All of these make the problem statement different than the simple element conservation statement.

Definition at line 498 of file vcs_MultiPhaseEquil.h.

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability(), vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::reportCSV(), and vcs_MultiPhaseEquil::vcs_MultiPhaseEquil().

Cantera::MultiPhase* m_mix
protected
int m_printLvl
protected

Print level from the VCSnonlinear package.

(Note, you may have to compile with debug flags to get some printing).

  • 0: No IO from the routine whatsoever
  • 1: file IO from reportCSV() carried out. One line print statements from equilibrate_XY() functions
  • 2: Problem statement information from vcs_Cantera_update_vprob(); Final state of the system from vcs_solve_TP()
  • 3: Several more setup tables; Problem initialization routine
  • 4: One table for each iteration within vcs_solve_Tp()
  • 5: Multiple tables for each iteration within vcs_solve_TP()

Definition at line 519 of file vcs_MultiPhaseEquil.h.

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability(), vcs_MultiPhaseEquil::equilibrate_TP(), and vcs_MultiPhaseEquil::vcs_MultiPhaseEquil().

Cantera::DenseMatrix m_N
protected

Stoichiometric matrix.

Definition at line 522 of file vcs_MultiPhaseEquil.h.

int m_iter
protected

Iteration Count.

Definition at line 525 of file vcs_MultiPhaseEquil.h.

Referenced by vcs_MultiPhaseEquil::iterations().

Cantera::vector_int m_species
protected

Vector of indices for species that are included in the calculation.

This is used to exclude pure-phase species with invalid thermo data

Definition at line 531 of file vcs_MultiPhaseEquil.h.

VCSnonideal::VCS_SOLVE* m_vsolvePtr
protected

Pointer to the object that does all of the equilibration work.

VCS_SOLVE will have different ordering for species and element constraints than this object or the VCS_PROB object. This object owns the pointer.

Definition at line 538 of file vcs_MultiPhaseEquil.h.

Referenced by vcs_MultiPhaseEquil::component(), vcs_MultiPhaseEquil::determine_PhaseStability(), vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::getStoichVector(), vcs_MultiPhaseEquil::numComponents(), and vcs_MultiPhaseEquil::numElemConstraints().


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