Cantera's Interface to the Multiphase chemical equilibrium solver. More...
#include <vcs_MultiPhaseEquil.h>
Public Types | |
typedef Cantera::MultiPhase | mix_t |
Shorthand for the MultiPhase mixture object used by Cantera to store information about multiple phases. | |
typedef size_t | index_t |
Typedef for an index variable. | |
typedef Cantera::DenseMatrix | matrix_t |
Typedef for a dense 2d matrix. | |
Public Member Functions | |
vcs_MultiPhaseEquil () | |
Default empty constructor. | |
vcs_MultiPhaseEquil (mix_t *mix, int printLvl) | |
Constructor for the multiphase equilibrium solver. | |
virtual | ~vcs_MultiPhaseEquil () |
Destructor for the class. | |
int | component (int m) const |
Return the index of the ith component. | |
void | getStoichVector (index_t rxn, Cantera::vector_fp &nu) |
Get the stoichiometric reaction coefficients for a single reaction index. | |
int | iterations () const |
return the number of iterations | |
int | equilibrate (int XY, int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=5000, int loglevel=-99) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object. | |
int | equilibrate_TP (int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=5000, int loglevel=-99) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object using constant T and P. | |
int | equilibrate_HP (doublereal Htarget, int XY, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=5000, int loglevel=-99) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object using either constant H and P or constant U and P. | |
int | equilibrate_SP (doublereal Starget, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=5000, int loglevel=-99) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object using constant S and P. | |
int | equilibrate_TV (int XY, doublereal xtarget, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=5000, int loglevel=-99) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object using constant V and constant T, H, U, or S. | |
void | reportCSV (const std::string &reportFile) |
Report the equilibrium answer in a comma separated table format. | |
int | numComponents () const |
reports the number of components in the equilibration problem | |
int | numElemConstraints () const |
Reports the number of element contraints in the equilibration problem. | |
Protected Attributes | |
Cantera::vector_int | m_order |
Vector that takes into account of the current sorting of the species. | |
VCSnonideal::VCS_PROB * | m_vprob |
Object which contains the problem statement. | |
mix_t * | m_mix |
Pointer to the MultiPhase mixture that will be equilibrated. | |
int | m_printLvl |
Print level from the VCSnonlinear package. | |
matrix_t | m_N |
Stoichiometric matrix. | |
int | m_iter |
Iteration Count. | |
Cantera::vector_int | m_species |
Vector of indices for species that are included in the calculation. | |
VCSnonideal::VCS_SOLVE * | m_vsolvePtr |
Pointer to the object that does all of the equilibration work. | |
Friends | |
int | vcs_Cantera_to_vprob (Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob) |
Translate a MultiPhase object into a VCS_PROB problem definition object. | |
int | vcs_Cantera_update_vprob (Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob) |
Translate a MultiPhase information into a VCS_PROB problem definition object. |
Cantera's Interface to the 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.
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 252 of file vcs_MultiPhaseEquil.h.
typedef size_t index_t |
Typedef for an index variable.
Definition at line 260 of file vcs_MultiPhaseEquil.h.
typedef Cantera::DenseMatrix matrix_t |
Typedef for a dense 2d matrix.
Definition at line 263 of file vcs_MultiPhaseEquil.h.
typedef Cantera::MultiPhase mix_t |
Shorthand for the MultiPhase mixture object used by Cantera to store information about multiple phases.
Definition at line 257 of file vcs_MultiPhaseEquil.h.
Default empty constructor.
Definition at line 47 of file vcs_MultiPhaseEquil.cpp.
vcs_MultiPhaseEquil | ( | mix_t * | 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.
mix | Object containing the MultiPhase object | |
printLvl | Determines the amount of printing to stdout that occurs for each call:
|
Definition at line 55 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_mix, vcs_MultiPhaseEquil::m_printLvl, vcs_MultiPhaseEquil::m_vprob, MultiPhase::nElements(), MultiPhase::nPhases(), MultiPhase::nSpecies(), plogf, and vcs_MultiPhaseEquil::vcs_Cantera_to_vprob.
~vcs_MultiPhaseEquil | ( | ) | [virtual] |
Destructor for the class.
Definition at line 84 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_vprob, and vcs_MultiPhaseEquil::m_vsolvePtr.
int component | ( | int | 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.
m | Index of the component. Must be between 0 and the number of components, which can be obtained from the numComponents() command. |
Definition at line 1459 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_vsolvePtr, and vcs_MultiPhaseEquil::numComponents().
int equilibrate | ( | int | XY, | |
int | estimateEquil = 0 , |
|||
int | printLvl = 0 , |
|||
doublereal | err = 1.0e-6 , |
|||
int | maxsteps = 5000 , |
|||
int | loglevel = -99 | |||
) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object.
Use the vcs algorithm to equilibrate the current multiphase mixture.
XY | Integer representing what two thermo quantities are held constant during the equilibration | |
estimateEquil | integer 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. | |
printLvl | Determines 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). | |
err | Internal error level | |
maxsteps | max steps allowed. | |
loglevel | for |
Definition at line 523 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().
int equilibrate_HP | ( | doublereal | Htarget, | |
int | XY, | |||
double | Tlow, | |||
double | Thigh, | |||
int | estimateEquil = 0 , |
|||
int | printLvl = 0 , |
|||
doublereal | err = 1.0E-6 , |
|||
int | maxsteps = 5000 , |
|||
int | loglevel = -99 | |||
) |
Equilibrate the solution using the current element abundances storred 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 storred with the MultiPhase object.
Htarget | Value 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 | |
XY | Integer flag indicating what is held constant. Must be either HP or UP. | |
Tlow | Lower limit of the temperature. It's an error condition if the temperature falls below Tlow. | |
Thigh | Upper limit of the temperature. It's an error condition if the temperature goes higher than Thigh. | |
estimateEquil | integer 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. | |
printLvl | Determines 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. | |
err | Internal error level | |
maxsteps | max steps allowed. | |
loglevel | Determines the amount of printing to the HTML output file. |
Definition at line 213 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, MAX, 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 = 5000 , |
|||
int | loglevel = -99 | |||
) |
Equilibrate the solution using the current element abundances storred 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 storred with the MultiPhase object.
Starget | Value of the total mixture entropy that will be kept constant. Note, this is and must be an extensive quantity. units = Joules/K | |
Tlow | Lower limit of the temperature. It's an error condition if the temperature falls below Tlow. | |
Thigh | Upper limit of the temperature. It's an error condition if the temperature goes higher than Thigh. | |
estimateEquil | integer 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. | |
printLvl | Determines 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. | |
err | Internal error level | |
maxsteps | max steps allowed. | |
loglevel | Determines the amount of printing to the HTML output file. |
Definition at line 363 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, MAX, 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_TP | ( | int | estimateEquil = 0 , |
|
int | printLvl = 0 , |
|||
doublereal | err = 1.0e-6 , |
|||
int | maxsteps = 5000 , |
|||
int | loglevel = -99 | |||
) |
Equilibrate the solution using the current element abundances storred in the MultiPhase object using constant T and P.
Use the vcs algorithm to equilibrate the current multiphase mixture.
estimateEquil | integer 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. | |
printLvl | Determines 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). | |
err | Internal error level | |
maxsteps | max steps allowed. | |
loglevel | for |
Definition at line 573 of file vcs_MultiPhaseEquil.cpp.
References Cantera::addLogEntry(), Cantera::beginLogGroup(), Cantera::endLogGroup(), vcs_MultiPhaseEquil::m_mix, vcs_MultiPhaseEquil::m_printLvl, vcs_MultiPhaseEquil::m_vprob, vcs_MultiPhaseEquil::m_vsolvePtr, MAX, MultiPhase::nElements(), MultiPhase::nPhases(), Constituents::nSpecies(), MultiPhase::nSpecies(), MultiPhase::phase(), plogf, MultiPhase::pressure(), clockWC::secondsWC(), MultiPhase::setPhaseMoles(), MultiPhase::temperature(), MultiPhase::uploadMoleFractionsFromPhases(), vcs_MultiPhaseEquil::vcs_Cantera_update_vprob, and VCS_SPECIES_TYPE_INTERFACIALVOLTAGE.
Referenced by vcs_MultiPhaseEquil::equilibrate(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), 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 = 5000 , |
|||
int | loglevel = -99 | |||
) |
Equilibrate the solution using the current element abundances storred 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 storred with the MultiPhase object.
XY | Integer flag indicating what is held constant. Must be either TV, HV, UV, or SV. | |
xtarget | Value 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 | |
estimateEquil | integer 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. | |
printLvl | Determines 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. | |
err | Internal error level | |
maxsteps | max steps allowed. | |
loglevel | Determines the amount of printing to the HTML output file. |
Definition at line 93 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, MAX, MultiPhase::maxTemp(), MultiPhase::minTemp(), MultiPhase::pressure(), MultiPhase::setPressure(), MultiPhase::setTemperature(), and MultiPhase::volume().
Referenced by vcs_MultiPhaseEquil::equilibrate().
void getStoichVector | ( | index_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.
rxn | Reaction number. | |
nu | Vector of coefficients for the formation reaction. Length is equal to the number of species in the MultiPhase object. |
Definition at line 1422 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_vsolvePtr, and vcs_MultiPhaseEquil::numComponents().
int iterations | ( | ) | const [inline] |
return the number of iterations
Definition at line 325 of file vcs_MultiPhaseEquil.h.
References vcs_MultiPhaseEquil::m_iter.
int numComponents | ( | ) | const |
reports the number of components in the equilibration problem
Definition at line 1442 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_vsolvePtr.
Referenced by vcs_MultiPhaseEquil::component(), and vcs_MultiPhaseEquil::getStoichVector().
int numElemConstraints | ( | ) | const |
Reports the number of element contraints in the equilibration problem.
Definition at line 1450 of file vcs_MultiPhaseEquil.cpp.
References vcs_MultiPhaseEquil::m_vsolvePtr.
void reportCSV | ( | const std::string & | reportFile | ) |
Report the equilibrium answer in a comma separated table format.
This routine is used for in the test suite.
reportFile | Base name of the file to get the report. File name is incremented by 1 for each report. |
Definition at line 741 of file vcs_MultiPhaseEquil.cpp.
References ThermoPhase::activityConvention(), ThermoPhase::getActivities(), ThermoPhase::getActivityCoefficients(), ThermoPhase::getChemPotentials(), MolalityVPSSTP::getMolalities(), ThermoPhase::getPartialMolarVolumes(), ThermoPhase::getStandardChemPotentials(), vcs_MultiPhaseEquil::m_mix, vcs_MultiPhaseEquil::m_vprob, Phase::name(), Constituents::nSpecies(), MultiPhase::phase(), plogf, MultiPhase::pressure(), MultiPhase::speciesIndex(), Constituents::speciesName(), MultiPhase::temperature(), and VCS_DATA_PTR.
int vcs_Cantera_to_vprob | ( | Cantera::MultiPhase * | mphase, | |
VCSnonideal::VCS_PROB * | vprob | |||
) | [friend] |
Translate a MultiPhase object into a VCS_PROB problem definition object.
mphase | MultiPhase object that is the source for all of the information | |
vprob | VCS_PROB problem definition that gets all of the information |
Note, both objects share the underlying Thermophase objects. So, neither can be const objects.
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.
mphase | MultiPhase object that is the source for all of the information | |
vprob | VCS_PROB problem definition that gets all of the information |
Referenced by vcs_MultiPhaseEquil::equilibrate_TP().
int m_iter [protected] |
Iteration Count.
Definition at line 628 of file vcs_MultiPhaseEquil.h.
Referenced by vcs_MultiPhaseEquil::iterations().
Pointer to the MultiPhase mixture that will be equilibrated.
Equilibrium solutions will be returned via this variable.
Definition at line 601 of file vcs_MultiPhaseEquil.h.
Referenced by vcs_MultiPhaseEquil::equilibrate(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::equilibrate_TV(), vcs_MultiPhaseEquil::reportCSV(), and vcs_MultiPhaseEquil::vcs_MultiPhaseEquil().
Stoichiometric matrix.
Definition at line 625 of file vcs_MultiPhaseEquil.h.
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 583 of file vcs_MultiPhaseEquil.h.
int m_printLvl [protected] |
Print level from the VCSnonlinear package.
(Note, you may have to compile with debug flags to get some printing).
Definition at line 619 of file vcs_MultiPhaseEquil.h.
Referenced by vcs_MultiPhaseEquil::equilibrate_TP(), and vcs_MultiPhaseEquil::vcs_MultiPhaseEquil().
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 636 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 595 of file vcs_MultiPhaseEquil.h.
Referenced by vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::reportCSV(), vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(), and vcs_MultiPhaseEquil::~vcs_MultiPhaseEquil().
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 644 of file vcs_MultiPhaseEquil.h.
Referenced by vcs_MultiPhaseEquil::component(), vcs_MultiPhaseEquil::equilibrate_TP(), vcs_MultiPhaseEquil::getStoichVector(), vcs_MultiPhaseEquil::numComponents(), vcs_MultiPhaseEquil::numElemConstraints(), and vcs_MultiPhaseEquil::~vcs_MultiPhaseEquil().