14 bool printActualMoles =
true, inertYes =
false;
17 std::vector<size_t> sortindex(nspecies,0);
21 for (
size_t i = 0; i < nspecies; ++i) {
31 std::swap(xy[k], xy[i]);
32 std::swap(sortindex[k], sortindex[i]);
42 double molScale = 1.0;
43 if (printActualMoles) {
54 plogf(
"\t\t VCS_TP REPORT\n");
58 plogf(
" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
59 }
else if (iconv == 1) {
60 plogf(
" RANGE SPACE ERROR: Equilibrium Found but not all Element Abundances are Satisfied\n");
71 if (!printActualMoles) {
72 plogf(
"\t\tMole Scale = %15.5g kmol (all mole numbers and volumes are scaled by this value)\n",
79 plogf(
" Species Equilibrium kmoles ");
80 plogf(
"Mole Fraction ChemPot/RT SpecUnkType\n");
84 writeline(
' ', 13,
false);
91 size_t j = sortindex[i];
93 writeline(
' ', 13,
false);
103 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
111 plogf(
" Inert Gas Species ");
113 plogf(
" Inert Species in phase %16s ",
121 plogf(
"\n SPECIES WITH LESS THAN 1.0E-32 KMOLES:\n\n");
125 plogf(
" %14.7E %14.7E %12.4E",
143 plogf(
" |ComponentID|");
148 plogf(
" | Components|");
153 plogf(
" NonComponent | Moles |");
157 plogf(
" | DG/RT Rxn |\n");
159 for (
size_t irxn = 0; irxn <
m_numRxnTot; irxn++) {
161 plogf(
" %3d ", kspec);
176 double totalMoles = 0.0;
177 double gibbsPhase = 0.0;
178 double gibbsTotal = 0.0;
182 plogf(
" | ElementID |");
187 plogf(
" | Element |");
192 plogf(
" PhaseName |KMolTarget |");
196 plogf(
" | Gibbs Total |\n");
198 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
199 plogf(
" %3d ", iphase);
206 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
210 plogf(
" %10.3g", gaPhase[j]);
211 gaTPhase[j] += gaPhase[j];
215 gibbsTotal += gibbsPhase;
216 plogf(
" | %18.11E |\n", gibbsPhase);
219 plogf(
" TOTAL |%10.3e |", totalMoles);
221 plogf(
" %10.3g", gaTPhase[j]);
223 plogf(
" | %18.11E |\n", gibbsTotal);
234 plogf(
"\n\tTotal Dimensionless Gibbs Free Energy = G/RT = %15.7E\n", g);
236 plogf(
"\t\t(Inert species have standard free energy of zero)\n");
239 plogf(
"\nElemental Abundances (kmol): ");
240 plogf(
" Actual Target Type ElActive\n");
242 writeline(
' ', 26,
false);
250 writeline(
'-', 93,
true,
true);
251 plogf(
"Chemical Potentials of the Species: (dimensionless)\n");
254 plogf(
" Name TKMoles StandStateChemPot " 255 " ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
256 plogf(
"| (MolNum ChemPot)|");
257 writeline(
'-', 147,
true,
true);
258 for (
size_t i = 0; i < nspecies; ++i) {
259 size_t j = sortindex[i];
274 lx = log(tmp) - log(tpmoles);
280 plogf(
"%14.7E |", lx);
281 plogf(
"%14.7E | ", eContrib);
286 "we have a problem - doesn't add up");
298 for (
size_t i = 0; i < 125; i++) {
301 plogf(
" %20.9E\n", g);
306 plogf(
"\nCounters: Iterations Time (seconds)\n");
308 plogf(
" vcs_basopt: %5d %11.5E\n",
310 plogf(
" vcs_TP: %5d %11.5E\n",
313 plogf(
" vcs_basopt: %5d %11s\n",
315 plogf(
" vcs_TP: %5d %11s\n",
337 plogf(
"\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
338 if (timing_print_lvl > 0) {
339 plogf(
" vcs_basopt: %5d %5d %11.5E\n",
342 plogf(
" vcs_TP: %5d %5d %11.5E\n",
345 plogf(
" vcs_inest: %5d %11.5E\n",
347 plogf(
" vcs_TotalTime: %11.5E\n",
350 plogf(
" vcs_basopt: %5d %5d %11s\n",
352 plogf(
" vcs_TP: %5d %5d %11s\n",
354 plogf(
" vcs_inest: %5d %11s\n",
356 plogf(
" vcs_TotalTime: %11s\n",
vector_fp m_phasePhi
electric potential of the iph phase
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
int Its
Current number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
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. ...
double Time_vcs_TP
Current time spent in vcs_TP.
vector_int m_speciesUnknownType
Specifies the species unknown type.
int Basis_Opts
number of optimizations of the components basis set done
vector_fp m_elemAbundances
Element abundances vector.
double T_Time_basopt
Total Time spent in basopt.
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.
Array2D m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
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...
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
vector_fp m_lnMnaughtSpecies
specifies the ln(Mnaught) used to calculate the chemical potentials
void vcs_nondim_TP()
Nondimensionalize the problem data.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
std::string PhaseName
String name for the phase.
void vcs_redim_TP()
Redimensionalize the problem data.
size_t m_numSpeciesRdc
Current number of species in the problems.
int T_Basis_Opts
Total number of optimizations of the components basis set done.
vector_fp m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
double vcs_GibbsPhase(size_t iphase, const double *const w, const double *const fe)
Calculate the total dimensionless Gibbs free energy of a single phase.
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 vcs_report(int iconv)
Print out a report on the state of the equilibrium problem to standard output.
#define VCS_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem...
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 T_Time_vcs_TP
Current time spent in vcs_TP.
size_t m_numElemConstraints
Number of element constraints in the problem.
void vcs_TCounters_report(int timing_print_lvl=1)
Create a report on the plog file containing timing and its information.
size_t m_numSpeciesTot
Total number of species in the problems.
int T_Its
Total number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
double T_Time_inest
Time spent in initial estimator.
Base class for exceptions thrown by Cantera classes.
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.
double Time_basopt
Current Time spent in basopt.
int m_timing_print_lvl
printing level of timing information
size_t m_numComponents
Number of components calculated for the problem.
vector_fp m_elemAbundancesGoal
Element abundances vector Goals.
double totalMoles() const
Return the total moles in the phase.
double m_totalVol
Total volume of all phases. Units are m^3.
double m_temperature
Temperature (Kelvin)
Phase information and Phase calculations for vcs.
#define VCS_DIMENSIONAL_G
dimensioned
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.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
double m_pressurePA
Pressure.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
size_t vcs_optMax(const double *x, const double *xSize, size_t j, size_t n)
Finds the location of the maximum component in a double vector.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
#define plogf
define this Cantera function to replace printf
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
double T_Time_vcs
Time spent in the vcs suite of programs.
vector_int m_elType
Type of the element constraint.
Namespace for the Cantera kernel.
char m_unitsState
This specifies the current state of units for the Gibbs free energy properties in the program...
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.
double m_totalMoleScale
Multiplier for the mole numbers within the nondimensional formulation.
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.
vector_fp m_actCoeffSpecies_old
Molar-based Activity Coefficients for Species based on old mole numbers.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
vector_fp m_chargeSpecies
Charge of each species. Length = number of species.
int T_Calls_vcs_TP
Current number of calls to vcs_TP.