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,
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...
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.
std::vector< std::unique_ptr< vcs_VolPhase > > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
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.
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.
void writelogendl()
Write an end of line character to the screen and flush output.
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.
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.
size_t m_nsp
Total number of species in the problems.
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_nelem
Number of element constraints in the problem.
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)