27 m_nsp(mphase->nSpecies()),
31 m_numSpeciesRdc(mphase->nSpecies()),
33 m_numRxnMinorZeroed(0),
34 m_numPhases(mphase->nPhases()),
35 m_doEstimateEquil(-1),
37 m_temperature(mphase->temperature()),
38 m_pressurePA(mphase->pressure()),
44 m_totalVol(mphase->volume()),
45 m_Faraday_dim(Faraday / (m_temperature *
GasConstant)),
51 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
55 string ser =
"VCS_SOLVE: ERROR:\n\t";
57 plogf(
"%s Number of species is nonpositive\n", ser);
59 " Number of species is nonpositive\n");
62 plogf(
"%s Number of phases is nonpositive\n", ser);
64 " Number of species is nonpositive\n");
145 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
151 std::string eos = tPhase->
type();
152 bool gasPhase = (eos ==
"IdealGas");
155 size_t nSpPhase = tPhase->
nSpecies();
157 string phaseName = tPhase->
name();
167 VolPhase->
resize(iphase, nSpPhase, nelem, phaseName.c_str(), 0.0);
183 if (eos ==
"IdealGas") {
185 }
else if (eos ==
"ConstDensity") {
187 }
else if (eos ==
"StoichSubstance") {
189 }
else if (eos ==
"IdealSolidSoln") {
191 }
else if (eos ==
"Surf" || eos ==
"Edge") {
193 "Surface/edge phase not handled yet.");
196 writelog(
"Unknown Cantera EOS to VCSnonideal: '{}'\n", eos);
215 for (
size_t k = 0; k < nSpPhase; k++) {
255 for (
size_t e = 0; e <
m_nelem; e++) {
276 double minTemp, maxTemp, refPressure;
277 sp.
reportParams(k, spType, c, minTemp, maxTemp, refPressure);
292 plogf(
"vcs_Cantera_convert: Species Type %d not known \n",
317 for (
size_t k = 0; k < nSpPhase; k++) {
326 for (
size_t j = 0; j <
m_nelem; j++) {
327 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
339 writeline(
'=', 80,
true,
true);
340 writeline(
'=', 16,
false);
341 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
344 plogf(
" Phase IDs of species\n");
345 plogf(
" species phaseID phaseName ");
346 plogf(
" Initial_Estimated_kMols\n");
347 for (
size_t i = 0; i <
m_nsp; i++) {
361 writeline(
'-', 80,
true,
true);
362 plogf(
" Information about phases\n");
363 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
364 plogf(
" TMolesInert Tmoles(kmol)\n");
366 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
368 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
375 writeline(
'=', 80,
true,
true);
376 writeline(
'=', 16,
false);
377 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
391 for (
size_t i = 0; i <
m_nsp; i++) {
396 for (
size_t i = 0; i <
m_nelem; i++) {
403 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
407 "Species to Phase Mapping, PhaseID, has a bad value\n" 408 "\tm_phaseID[{}] = {}\n" 409 "Allowed values: 0 to {}", kspec, iph,
m_numPhases - 1);
417 if (numPhSp[iph] != Vphase->
nSpecies()) {
419 "Number of species in phase {}, {}, doesn't match ({} != {}) [vphase = {}]",
424 for (
size_t i = 0; i <
m_nelem; i++) {
429 "Charge neutrality condition {} is signicantly " 430 "nonzero, {}. Giving up",
434 plogf(
"Charge neutrality condition %s not zero, %g. Setting it zero\n",
444 for (
size_t i = 0; i <
m_nsp; i++) {
461 for (
size_t k = 1; k < Vphase->
nSpecies(); k++) {
471 VCS_SOLVE::~VCS_SOLVE()
502 plogf(
"vcs_prep_oneTime returned a bad status, %d: bailing!\n",
526 if (ipr > 0 || ip1 > 0) {
533 }
else if (iconv == 1) {
534 plogf(
"WARNING: RANGE SPACE ERROR encountered\n");
548 vector<size_t> invSpecies(
m_nsp);
549 for (
size_t k = 0; k <
m_nsp; k++) {
553 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
560 size_t nSpPhase = tPhase->
nSpecies();
561 if ((nSpPhase == 1) && (volPhase->
phiVarIndex() == 0)) {
572 writeline(
'=', 80,
true,
true);
573 writeline(
'=', 20,
false);
574 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
578 plogf(
" Phase IDs of species\n");
579 plogf(
" species phaseID phaseName ");
580 plogf(
" Initial_Estimated_kMols\n");
581 for (
size_t i = 0; i <
m_nsp; i++) {
594 writeline(
'-', 80,
true,
true);
595 plogf(
" Information about phases\n");
596 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
597 plogf(
" TMolesInert Tmoles(kmol)\n");
599 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
601 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
608 writeline(
'=', 80,
true,
true);
609 writeline(
'=', 20,
false);
610 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
660 const double w[],
double volPM[])
663 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
void vcs_prob_specifyFully()
Fully specify the problem to be solved.
vector_fp m_phasePhi
electric potential of the iph phase
void addPhaseElements(vcs_VolPhase *volPhase)
Add elements to the local element list.
#define VCS_PHASE_EXIST_NO
Phase doesn't currently exist in the mixture.
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
vector_fp FormulaMatrixCol
Column of the formula matrix, comprising the element composition of the species.
size_t nElements() const
Number of elements.
int Its
Current number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
int vcs_prep(int printLvl)
This routine is mostly concerned with changing the private data to be consistent with what's needed f...
int T_Calls_Inest
Current number of times the initial thermo equilibrium estimator has been called. ...
double Time_vcs_TP
Current time spent in vcs_TP.
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
vector_int m_speciesUnknownType
Specifies the species unknown type.
bool m_singleSpecies
If true, this phase consists of a single species.
VCS_SPECIES_THERMO * SpeciesThermo
Pointer to the thermo structure for this species.
int Basis_Opts
number of optimizations of the components basis set done
int vcs(int ipr, int ip1, int maxit)
Solve an equilibrium problem.
double totalMolesInert() const
Returns the value of the total kmol of inert in the phase.
vector_fp m_TmpPhase
Temporary vector of length NPhase.
double T_Time_basopt
Total Time spent in basopt.
vcs_VolPhase * OwningPhase
Pointer to the owning phase object.
double m_Faraday_dim
dimensionless value of Faraday's constant, F / RT (1/volt)
VCS_COUNTERS * m_VCount
Timing and iteration counters for the vcs object.
vector_fp m_PMVolumeSpecies
Partial molar volumes of the species.
vector_fp m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
vector_fp m_molNumSpecies_old
Total moles of the species.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
vector_fp m_wtSpecies
Molecular weight of each species.
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
vector_fp m_scSize
Absolute size of the stoichiometric coefficients.
doublereal speciesMoles(size_t kGlob) const
Returns the moles of global species k. units = kmol.
void vcs_prob_update()
Transfer the results of the equilibrium calculation back from VCS_SOLVE.
void setPhaseMoles(const size_t n, const doublereal moles)
Set the number of moles of phase with index n.
size_t addOnePhaseSpecies(vcs_VolPhase *volPhase, size_t k, size_t kT)
This routines adds entries for the formula matrix for one species.
doublereal temperature() const
Temperature [K].
double SS0_Cp0
Base heat capacity used in the VCS_SS0_CONSTANT_CP model.
int m_useActCoeffJac
Choice of Hessians.
#define VCS_PHASE_EXIST_ALWAYS
Always exists because it contains inerts which can't exist in any other phase.
int vcs_TP(int ipr, int ip1, int maxit, double T, double pres)
Solve an equilibrium problem at a particular fixed temperature and pressure.
int p_activityConvention
Convention for the activity formulation.
vector_fp m_lnMnaughtSpecies
specifies the ln(Mnaught) used to calculate the chemical potentials
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
size_t IndexSpeciesPhase
Index of this species in the current phase.
#define VCS_SSVOL_IDEALGAS
Models for the standard state volume of each species.
vector_fp m_deltaGRxn_Deficient
Last deltag[irxn] from the previous step with additions for possible births of zeroed phases...
std::vector< size_t > m_elementMapIndex
Index vector that keeps track of the rearrangement of the elements.
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
size_t nSpecies() const
Returns the number of species in the phase.
doublereal volume() const
The total mixture volume [m^3].
int vcs_timing_print_lvl
Global hook for turning on and off time printing.
The class provides the wall clock timer in seconds.
vector_fp m_feSpecies_new
Dimensionless new free energy for all the species in the mechanism at the new tentative T...
size_t transferElementsFM(const ThermoPhase *const tPhase)
Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object...
doublereal pressure() const
Pressure [Pa].
vector_fp m_deltaMolNumSpecies
Reaction Adjustments for each species during the current step.
std::string PhaseName
String name for the phase.
#define VCS_PHASE_EXIST_YES
Phase is a normal phase that currently exists.
std::vector< std::unique_ptr< vcs_VolPhase > > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
double WtSpecies
Molecular Weight of the species (gm/mol)
vector_fp m_spSize
total size of the species
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
size_t m_numRxnRdc
Current number of non-component species in the problem.
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
Headers for the MultiPhase object that is used to set up multiphase equilibrium problems (see Equilfu...
void setExistence(const int existence)
Set the existence flag in the object.
vector_fp m_tPhaseMoles_new
total kmols of species in each phase in the tentative soln vector
int T_Basis_Opts
Total number of optimizations of the components basis set done.
void setPtrThermoPhase(ThermoPhase *tp_ptr)
Set the pointer for Cantera's ThermoPhase parameter.
Base class for a phase with thermodynamic properties.
size_t VP_ID_
Original ID of the phase in the problem.
vector_fp m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
void setMolesFromVCS(const int stateCalc, const double *molesSpeciesVCS=0)
Set the moles within the phase.
std::vector< std::string > m_elementName
Vector of strings containing the element names.
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
Header for the object representing each phase within vcs.
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
int vcs_report(int iconv)
Print out a report on the state of the equilibrium problem to standard output.
double SSStar_Vol0
parameter that is used in the VCS_SSVOL_CONSTANT model.
void uploadMoleFractionsFromPhases()
Update the locally-stored composition within this object to match the current compositions of the pha...
A class for multiphase mixtures.
int SSStar_Vol_Model
Models for the standard state volume of each species.
std::string SpName
Name of the species.
double SS0_S0
Base entropy used in the VCS_SS0_CONSTANT_CP model.
vector_fp m_deltaGRxn_tmp
Temporary vector of Rxn DeltaG's.
std::vector< size_t > m_speciesMapIndex
Index vector that keeps track of the species vector rearrangement.
double vcs_VolTotal(const double tkelvin, const double pres, const double w[], double volPM[])
Calculation of the total volume and the partial molar volumes.
double secondsWC()
Returns the wall clock time in seconds since the last reset.
size_t IndexPhase
Index of the phase that this species belongs to.
std::string eos_name() const
Return the name corresponding to the equation of state.
Properties of a single species.
double T_Time_vcs_TP
Current time spent in vcs_TP.
void vcs_TCounters_report(int timing_print_lvl=1)
Create a report on the plog file containing timing and its information.
int m_eqnState
Type of the equation of state.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
vector_fp m_deltaPhaseMoles
Change in the total moles in each phase.
double SS0_H0
Base enthalpy used in the VCS_SS0_CONSTANT_CP model.
#define VCS_ELEM_TYPE_CHARGENEUTRALITY
This refers to a charge neutrality of a single phase.
int T_Its
Total number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
void setElectricPotential(const double phi)
set the electric potential of the phase
double T_Time_inest
Time spent in initial estimator.
std::vector< std::unique_ptr< VCS_SPECIES_THERMO > > m_speciesThermoList
Vector of pointers to thermo structures which identify the model and parameters for evaluating the th...
size_t nSpecies() const
Return the number of species in the phase.
Base class for exceptions thrown by Cantera classes.
vector_fp m_deltaGRxn_old
Last deltag[irxn] from the previous step.
vector_fp m_feSpecies_old
Free energy vector from the start of the current iteration.
#define SIMPLE
Constant Cp thermo.
vector_fp TPhInertMoles
Total kmoles of inert to add to each phase.
void resize(const size_t phaseNum, const size_t numSpecies, const size_t numElem, const char *const phaseName, const double molesInert=0.0)
The resize() function fills in all of the initial information if it is not given in the constructor...
double Time_basopt
Current Time spent in basopt.
int m_debug_print_lvl
Debug printing lvl.
int m_timing_print_lvl
printing level of timing information
#define VCS_SPECIES_MAJOR
Species is a major species.
size_t m_numComponents
Number of components calculated for the problem.
vector_int m_actConventionSpecies
specifies the activity convention of the phase containing the species
bool m_gasPhase
If true, this phase is a gas-phase like phase.
vector_fp m_elemAbundancesGoal
Element abundances vector Goals.
int m_printLvl
Print level for print routines.
double totalMoles() const
Return the total moles in the phase.
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
double m_totalVol
Total volume of all phases. Units are m^3.
double m_temperature
Temperature (Kelvin)
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
Phase information and Phase calculations for vcs.
vector_int m_phaseActConvention
specifies the activity convention of the phase.
vector_fp m_tPhaseMoles_old
Total kmols of species in each phase.
virtual std::string type() const
String indicating the thermodynamic model implemented.
std::vector< std::string > m_speciesName
Species string name for the kth species.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
Array2D m_deltaMolNumPhase
Change in the number of moles of phase, iphase, due to the noncomponent formation reaction...
Array2D m_formulaMatrix
Formula matrix for the problem.
double m_pressurePA
Pressure.
vector_fp m_actCoeffSpecies_new
Molar-based Activity Coefficients for Species.
double SS0_T0
Base temperature used in the VCS_SS0_CONSTANT_CP model.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
int SSStar_Model
Integer value representing the star state model.
int SS0_Model
Integer representing the models for the species standard state Naught temperature dependence...
double VolPM
Partial molar volume of the species.
size_t m_nsp
Total number of species in the problems.
vcs_SpeciesProperties * speciesProperty(const size_t kindex)
Retrieve the kth Species structure for the species belonging to this phase.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
int SurfaceSpecies
True if this species belongs to a surface phase.
std::string name() const
Return the name of the phase.
vector_int m_speciesStatus
Major -Minor status vector for the species in the problem.
Contains declarations for string manipulation functions within Cantera.
double sendToVCS_VolPM(double *const VolPM) const
Fill in the partial molar volume vector for VCS.
double Charge
Charge state of the species -> This may be duplication of what's in the FormulaMatrixCol entries...
#define plogf
define this Cantera function to replace printf
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
Class to keep track of time and iterations.
double T_Time_vcs
Time spent in the vcs suite of programs.
void vcs_delete_memory()
Delete memory that isn't just resizable STL containers.
#define VCS_ELEM_TYPE_LATTICERATIO
Constraint associated with maintaining a fixed lattice stoichiometry in the solids.
thermo_t & phase(size_t n)
Return a reference to phase n.
Array2D m_phaseParticipation
This is 1 if the phase, iphase, participates in the formation reaction irxn, and zero otherwise...
A species thermodynamic property manager for a phase.
vector_fp m_TmpPhase2
Temporary vector of length NPhase.
vector_int m_elType
Type of the element constraint.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Namespace for the Cantera kernel.
std::vector< size_t > m_indexRxnToSpecies
Mapping between the species index for noncomponent species and the full species index.
size_t m_nelem
Number of element constraints in the problem.
size_t m_numPhases
Number of Phases in the problem.
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
size_t m_numRxnTot
Total number of non-component species in the problem.
vector_fp m_molNumSpecies_new
Tentative value of the mole number vector.
static void disableTiming()
Disable printing of timing information.
Array2D m_np_dLnActCoeffdMolNum
Change in the log of the activity coefficient with respect to the mole number multiplied by the phase...
vector_fp m_actCoeffSpecies_old
Molar-based Activity Coefficients for Species based on old mole numbers.
void vcs_counters_init(int ifunc)
Initialize the internal counters.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
void prob_report(int print_lvl)
Print out the problem specification in all generality as it currently exists in the VCS_SOLVE object...
vector_fp m_chargeSpecies
Charge of each species. Length = number of species.
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
double SS0_TSave
Internal storage of the last temperature used in the calculation of the reference naught Gibbs free e...
std::vector< size_t > m_speciesLocalPhaseIndex
Index that keeps track of the index of the species within the local phase.
double SS0_feSave
Internal storage of the last calculation of the reference naught Gibbs free energy at SS0_TSave...
double G0_calc_one(size_t kspec) const
Gibbs free energy calculation at a temperature for the reference state of a species, return a value for one species.
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
int T_Calls_vcs_TP
Current number of calls to vcs_TP.
std::string speciesName(const size_t kGlob) const
Name of species with global index kGlob.