17 static char pprefix[20] =
" --- vcs_inest: ";
20 double*
const ss,
double test)
30 plogf(
"%s Mole Numbers returned from linear programming (vcs_inest initial guess):\n",
32 plogf(
"%s SPECIES MOLE_NUMBER -SS_ChemPotential\n", pprefix);
33 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
34 plogf(
"%s ", pprefix);
38 plogf(
"%s Element Abundance Agreement returned from linear " 39 "programming (vcs_inest initial guess):",
42 plogf(
"%s Element Goal Actual\n", pprefix);
46 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
49 plogf(
"%s ", pprefix);
60 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
76 vcs_basopt(
false, aw, sa, sm, ss, test, &conv);
92 double TMolesMultiphase = 0.0;
118 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
119 plogf(
"%s", pprefix);
125 plogf(
"fe* = %15.5g ff = %15.5g dg* = %15.5g\n",
139 for (
size_t irxn = 0; irxn < nrxn; ++irxn) {
173 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
175 plogf(
"%sdirection (", pprefix);
182 plogf(
" (ssPhase doesn't exist -> stability not checked)");
199 if (par <= 1.0 && par > 0.0) {
235 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
241 if (s < 0.0 && ikl == 0) {
254 double xl = (1.0 - s / (s1 - s)) * 0.5;
264 par = par * 2.0 * xl;
271 plogf(
"%s Final Mole Numbers produced by inest:\n",
273 plogf(
"%s SPECIES MOLE_NUMBER\n", pprefix);
274 for (
size_t kspec = 0; kspec < nspecies; ++kspec) {
275 plogf(
"%s ", pprefix);
292 plogf(
"%s Initial guess passed element abundances on input\n", pprefix);
293 plogf(
"%s m_doEstimateEquil = 1 so will use the input mole " 294 "numbers as estimates", pprefix);
299 plogf(
"%s Initial guess failed element abundances on input\n", pprefix);
300 plogf(
"%s m_doEstimateEquil = 1 so will discard input " 301 "mole numbers and find our own estimate", pprefix);
314 plogf(
"%sGo find an initial estimate for the equilibrium problem",
318 double test = -1.0E20;
319 vcs_inest(&aw[0], &sa[0], &sm[0], &ss[0], test);
334 plogf(
"%sInitial guess failed element abundances\n", pprefix);
335 plogf(
"%sCall vcs_elcorr to attempt fix", pprefix);
341 plogf(
"%sInitial guess still fails element abundance equations\n",
343 plogf(
"%s - Inability to ever satisfy element abundance " 344 "constraints is probable", pprefix);
350 plogf(
"%sInitial guess now satisfies element abundances", pprefix);
353 plogf(
"%sElement Abundances RANGE ERROR\n", pprefix);
354 plogf(
"%s - Initial guess satisfies NC=%d element abundances, " 355 "BUT not NE=%d element abundances", pprefix,
364 plogf(
"%sInitial guess satisfies element abundances", pprefix);
367 plogf(
"%sElement Abundances RANGE ERROR\n", pprefix);
368 plogf(
"%s - Initial guess satisfies NC=%d element abundances, " 369 "BUT not NE=%d element abundances", pprefix,
377 plogf(
"%sTotal Dimensionless Gibbs Free Energy = %15.7E", pprefix,
void vcs_inest(double *const aw, double *const sa, double *const sm, double *const ss, double test)
Estimate equilibrium compositions.
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
int T_Calls_Inest
Current number of times the initial thermo equilibrium estimator has been called. ...
vector_int m_speciesUnknownType
Specifies the species unknown type.
vector_fp m_TmpPhase
Temporary vector of length NPhase.
VCS_COUNTERS * m_VCount
Timing and iteration counters for the vcs object.
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.
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
Array2D m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
int vcs_elcorr(double aa[], double x[])
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...
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
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...
vector_fp m_deltaMolNumSpecies
Reaction Adjustments for each species during the current step.
vector_fp m_tPhaseMoles_new
total kmols of species in each phase in the tentative soln vector
vector_fp m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
vector_int m_elementActive
Specifies whether an element constraint is active.
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.
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
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.
double secondsWC()
Returns the wall clock time in seconds since the last reset.
size_t m_numElemConstraints
Number of element constraints in the problem.
size_t m_numSpeciesTot
Total number of species in the problems.
vector_fp m_deltaPhaseMoles
Change in the total moles in each phase.
#define VCS_STATECALC_NEW
State Calculation based on the new or tentative mole numbers.
double T_Time_inest
Time spent in initial estimator.
vector_fp m_feSpecies_old
Free energy vector from the start of the current iteration.
vector_fp TPhInertMoles
Total kmoles of inert to add to each phase.
int m_debug_print_lvl
Debug printing lvl.
size_t m_numComponents
Number of components calculated for the problem.
vector_fp m_elemAbundancesGoal
Element abundances vector Goals.
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
vector_fp m_tPhaseMoles_old
Total kmols of species in each phase.
std::vector< std::string > m_speciesName
Species string name for the kth species.
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...
#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.
#define plogendl()
define this Cantera function to replace cout << endl;
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
void vcs_elab()
Computes the current elemental abundances vector.
int vcs_setMolesLinProg()
Estimate the initial mole numbers by constrained linear programming.
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.
#define plogf
define this Cantera function to replace printf
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
vector_fp m_TmpPhase2
Temporary vector of length NPhase.
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_numPhases
Number of Phases in the problem.
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.
bool vcs_elabcheck(int ibound)