17 static char pprefix[20] =
" --- vcs_inest: ";
20 double*
const ss,
double test)
29 plogf(
"%s Mole Numbers returned from linear programming (vcs_inest initial guess):\n",
31 plogf(
"%s SPECIES MOLE_NUMBER -SS_ChemPotential\n", pprefix);
32 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
33 plogf(
"%s ", pprefix);
37 plogf(
"%s Element Abundance Agreement returned from linear "
38 "programming (vcs_inest initial guess):\n", pprefix);
39 plogf(
"%s Element Goal Actual\n", pprefix);
40 for (
size_t j = 0; j <
m_nelem; j++) {
43 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
46 plogf(
"%s ", pprefix);
57 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
73 vcs_basopt(
false, aw, sa, sm, ss, test, &conv);
89 double TMolesMultiphase = 0.0;
115 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
116 plogf(
"%s", pprefix);
122 plogf(
"fe* = %15.5g ff = %15.5g dg* = %15.5g\n",
136 for (
size_t irxn = 0; irxn < nrxn; ++irxn) {
170 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
172 plogf(
"%sdirection (", pprefix);
179 plogf(
" (ssPhase doesn't exist -> stability not checked)");
196 if (par <= 1.0 && par > 0.0) {
232 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
238 if (s < 0.0 && ikl == 0) {
251 double xl = (1.0 - s / (s1 - s)) * 0.5;
261 par = par * 2.0 * xl;
268 plogf(
"%s Final Mole Numbers produced by inest:\n",
270 plogf(
"%s SPECIES MOLE_NUMBER\n", pprefix);
271 for (
size_t kspec = 0; kspec <
m_nsp; ++kspec) {
272 plogf(
"%s %-12.12s %g\n",
287 plogf(
"%s Initial guess passed element abundances on input\n", pprefix);
288 plogf(
"%s m_doEstimateEquil = 1 so will use the input mole "
289 "numbers as estimates\n", pprefix);
293 plogf(
"%s Initial guess failed element abundances on input\n", pprefix);
294 plogf(
"%s m_doEstimateEquil = 1 so will discard input "
295 "mole numbers and find our own estimate\n", pprefix);
307 plogf(
"%sGo find an initial estimate for the equilibrium problem\n",
310 double test = -1.0E20;
311 vcs_inest(&aw[0], &sa[0], &sm[0], &ss[0], test);
326 plogf(
"%sInitial guess failed element abundances\n", pprefix);
327 plogf(
"%sCall vcs_elcorr to attempt fix\n", pprefix);
332 plogf(
"%sInitial guess still fails element abundance equations\n",
334 plogf(
"%s - Inability to ever satisfy element abundance "
335 "constraints is probable\n", pprefix);
340 plogf(
"%sInitial guess now satisfies element abundances\n", pprefix);
342 plogf(
"%sElement Abundances RANGE ERROR\n", pprefix);
343 plogf(
"%s - Initial guess satisfies NC=%d element abundances, "
344 "BUT not NE=%d element abundances\n", pprefix,
352 plogf(
"%sInitial guess satisfies element abundances\n", pprefix);
354 plogf(
"%sElement Abundances RANGE ERROR\n", pprefix);
355 plogf(
"%s - Initial guess satisfies NC=%d element abundances, "
356 "BUT not NE=%d element abundances\n", pprefix,
363 plogf(
"%sTotal Dimensionless Gibbs Free Energy = %15.7E\n", pprefix,
int T_Calls_Inest
Current number of times the initial thermo equilibrium estimator has been called.
double T_Time_inest
Time spent in initial estimator.
size_t m_numPhases
Number of Phases in the problem.
int m_doEstimateEquil
Setting for whether to do an initial estimate.
int vcs_inest_TP()
Create an initial estimate of the solution to the thermodynamic equilibrium problem.
void vcs_deltag(const int L, const bool doDeleted, const int vcsState, const bool alterZeroedPhases=true)
This subroutine calculates reaction free energy changes for all noncomponent formation reactions.
std::vector< std::string > m_speciesName
Species string name for the kth species.
vector_fp m_TmpPhase2
Temporary vector of length NPhase.
size_t m_nelem
Number of element constraints in the problem.
int vcs_basopt(const bool doJustComponents, double aw[], double sa[], double sm[], double ss[], double test, bool *const usedZeroedSpecies)
Choose the optimum species basis for the calculations.
int vcs_elcorr(double aa[], double x[])
vector_fp m_molNumSpecies_old
Total moles of the species.
vector_fp m_molNumSpecies_new
Tentative value of the mole number vector.
void vcs_inest(double *const aw, double *const sa, double *const sm, double *const ss, double test)
Estimate equilibrium compositions.
vector_int m_speciesUnknownType
Specifies the species unknown type.
void vcs_elab()
Computes the current elemental abundances vector.
int vcs_setMolesLinProg()
Estimate the initial mole numbers by constrained linear programming.
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
vector_fp m_tPhaseMoles_new
total kmols of species in each phase in the tentative soln vector
vector_fp m_feSpecies_new
Dimensionless new free energy for all the species in the mechanism at the new tentative T,...
vector_fp m_tPhaseMoles_old
Total kmols of species in each phase.
int m_debug_print_lvl
Debug printing lvl.
vector_fp m_elemAbundancesGoal
Element abundances vector Goals.
vector_fp TPhInertMoles
Total kmoles of inert to add to each phase.
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
std::vector< size_t > m_indexRxnToSpecies
Mapping between the species index for noncomponent species and the full species index.
Array2D m_formulaMatrix
Formula matrix for the problem.
vector_fp m_deltaPhaseMoles
Change in the total moles in each phase.
Array2D m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form.
VCS_COUNTERS * m_VCount
Timing and iteration counters for the vcs object.
size_t m_numComponents
Number of components calculated for the problem.
vector_fp m_feSpecies_old
Free energy vector from the start of the current iteration.
vector_int m_elementActive
Specifies whether an element constraint is active.
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
size_t m_nsp
Total number of species in the problems.
std::vector< std::unique_ptr< vcs_VolPhase > > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
bool vcs_elabcheck(int ibound)
vector_fp m_deltaMolNumSpecies
Reaction Adjustments for each species during the current step.
vector_fp m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
Array2D m_deltaMolNumPhase
Change in the number of moles of phase, iphase, due to the noncomponent formation reaction,...
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
vector_fp m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
void vcs_dfe(const int stateCalc, const int ll, const size_t lbot, const size_t ltop)
Calculate the dimensionless chemical potentials of all species or of certain groups of species,...
size_t m_numRxnTot
Total number of non-component species in the problem.
vector_fp m_TmpPhase
Temporary vector of length NPhase.
std::vector< std::string > m_elementName
Vector of strings containing the element names.
The class provides the wall clock timer in seconds.
double secondsWC()
Returns the wall clock time in seconds since the last reset.
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.
Header for the object representing each phase within vcs.
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
#define VCS_STATECALC_NEW
State Calculation based on the new or tentative mole numbers.
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
#define plogf
define this Cantera function to replace printf
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...