14 bool inertYes =
false;
17 std::vector<std::pair<double, size_t>> x_order;
18 for (
size_t i = 0; i <
m_nsp; i++) {
31 plogf(
"\t\t VCS_TP REPORT\n");
35 plogf(
" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
36 }
else if (iconv == 1) {
37 plogf(
" RANGE SPACE ERROR: Equilibrium Found but not all Element Abundances are Satisfied\n");
52 plogf(
" Species Equilibrium kmoles ");
53 plogf(
"Mole Fraction ChemPot/RT SpecUnkType\n");
57 writeline(
' ', 13,
false);
64 size_t j = x_order[i].second;
66 writeline(
' ', 13,
false);
76 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
84 plogf(
" Inert Gas Species ");
86 plogf(
" Inert Species in phase %16s ",
94 plogf(
"\n SPECIES WITH LESS THAN 1.0E-32 KMOLES:\n\n");
98 plogf(
" %14.7E %14.7E %12.4E",
116 plogf(
" |ComponentID|");
121 plogf(
" | Components|");
126 plogf(
" NonComponent | Moles |");
130 plogf(
" | DG/RT Rxn |\n");
132 for (
size_t irxn = 0; irxn <
m_numRxnTot; irxn++) {
134 plogf(
" %3d ", kspec);
149 double totalMoles = 0.0;
150 double gibbsPhase = 0.0;
151 double gibbsTotal = 0.0;
154 writeline(
'-',
m_nelem*10 + 58);
155 plogf(
" | ElementID |");
156 for (
size_t j = 0; j <
m_nelem; j++) {
160 plogf(
" | Element |");
161 for (
size_t j = 0; j <
m_nelem; j++) {
165 plogf(
" PhaseName |KMolTarget |");
166 for (
size_t j = 0; j <
m_nelem; j++) {
169 plogf(
" | Gibbs Total |\n");
170 writeline(
'-',
m_nelem*10 + 58);
171 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
172 plogf(
" %3d ", iphase);
179 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
182 for (
size_t j = 0; j <
m_nelem; j++) {
183 plogf(
" %10.3g", gaPhase[j]);
184 gaTPhase[j] += gaPhase[j];
188 gibbsTotal += gibbsPhase;
189 plogf(
" | %18.11E |\n", gibbsPhase);
191 writeline(
'-',
m_nelem*10 + 58);
192 plogf(
" TOTAL |%10.3e |", totalMoles);
193 for (
size_t j = 0; j <
m_nelem; j++) {
194 plogf(
" %10.3g", gaTPhase[j]);
196 plogf(
" | %18.11E |\n", gibbsTotal);
198 writeline(
'-',
m_nelem*10 + 58);
207 plogf(
"\n\tTotal Dimensionless Gibbs Free Energy = G/RT = %15.7E\n", g);
209 plogf(
"\t\t(Inert species have standard free energy of zero)\n");
212 plogf(
"\nElemental Abundances (kmol): ");
213 plogf(
" Actual Target Type ElActive\n");
214 for (
size_t i = 0; i <
m_nelem; ++i) {
215 writeline(
' ', 26,
false);
223 writeline(
'-', 93,
true,
true);
224 plogf(
"Chemical Potentials of the Species: (dimensionless)\n");
227 plogf(
" Name TKMoles StandStateChemPot "
228 " ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
229 plogf(
"| (MolNum ChemPot)|");
230 writeline(
'-', 147,
true,
true);
231 for (
size_t i = 0; i <
m_nsp; ++i) {
232 size_t j = x_order[i].second;
247 lx = log(tmp) - log(tpmoles);
253 plogf(
"%14.7E |", lx);
254 plogf(
"%14.7E | ", eContrib);
259 "we have a problem - doesn't add up");
271 for (
size_t i = 0; i < 125; i++) {
274 plogf(
" %20.9E\n", g);
279 plogf(
"\nCounters: Iterations Time (seconds)\n");
281 plogf(
" vcs_basopt: %5d %11.5E\n",
283 plogf(
" vcs_TP: %5d %11.5E\n",
286 plogf(
" vcs_basopt: %5d %11s\n",
288 plogf(
" vcs_TP: %5d %11s\n",
300 plogf(
"\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
301 if (timing_print_lvl > 0) {
302 plogf(
" vcs_basopt: %5d %5d %11.5E\n",
305 plogf(
" vcs_TP: %5d %5d %11.5E\n",
308 plogf(
" vcs_inest: %5d %11.5E\n",
310 plogf(
" vcs_TotalTime: %11.5E\n",
313 plogf(
" vcs_basopt: %5d %5d %11s\n",
315 plogf(
" vcs_TP: %5d %5d %11s\n",
317 plogf(
" vcs_inest: %5d %11s\n",
319 plogf(
" vcs_TotalTime: %11s\n",
Base class for exceptions thrown by Cantera classes.
int Its
Current number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
int T_Calls_Inest
Current number of times the initial thermo equilibrium estimator has been called.
double T_Time_basopt
Total Time spent in basopt.
double T_Time_inest
Time spent in initial estimator.
int T_Basis_Opts
Total number of optimizations of the components basis set done.
double T_Time_vcs_TP
Current time spent in vcs_TP.
int Basis_Opts
number of optimizations of the components basis set done
double T_Time_vcs
Time spent in the vcs suite of programs.
int T_Its
Total number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
int T_Calls_vcs_TP
Current number of calls to vcs_TP.
double Time_basopt
Current Time spent in basopt.
double Time_vcs_TP
Current time spent in vcs_TP.
size_t m_numPhases
Number of Phases in the problem.
vector_fp m_phasePhi
electric potential of the iph phase
double vcs_VolTotal(const double tkelvin, const double pres, const double w[], double volPM[])
Calculation of the total volume and the partial molar volumes.
std::vector< std::string > m_speciesName
Species string name for the kth species.
vector_int m_elType
Type of the element constraint.
size_t m_nelem
Number of element constraints in the problem.
double m_totalVol
Total volume of all phases. Units are m^3.
vector_fp m_molNumSpecies_old
Total moles of the species.
void vcs_TCounters_report(int timing_print_lvl=1)
Create a report on the plog file containing timing and its information.
vector_fp m_molNumSpecies_new
Tentative value of the mole number vector.
vector_fp m_elemAbundances
Element abundances vector.
vector_int m_speciesUnknownType
Specifies the species unknown type.
int m_timing_print_lvl
printing level of timing information
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
vector_fp m_tPhaseMoles_old
Total kmols of species in each phase.
size_t m_numSpeciesRdc
Current number of species in the problems.
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_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.
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.
size_t m_numComponents
Number of components calculated for the problem.
double m_pressurePA
Pressure.
vector_fp m_chargeSpecies
Charge of each species. Length = number of species.
vector_fp m_feSpecies_old
Free energy vector from the start of the current iteration.
int vcs_report(int iconv)
Print out a report on the state of the equilibrium problem to standard output.
vector_int m_elementActive
Specifies whether an element constraint is active.
double m_Faraday_dim
dimensionless value of Faraday's constant, F / RT (1/volt)
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.
vector_fp m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
vector_fp m_actCoeffSpecies_old
Molar-based Activity Coefficients for Species based on old mole numbers.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
vector_fp m_PMVolumeSpecies
Partial molar volumes of the species.
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,...
vector_fp m_lnMnaughtSpecies
specifies the ln(Mnaught) used to calculate the chemical potentials
size_t m_numRxnTot
Total number of non-component species in the problem.
double m_temperature
Temperature (Kelvin)
std::vector< std::string > m_elementName
Vector of strings containing the element names.
Phase information and Phase calculations for vcs.
std::string PhaseName
String name for the phase.
double totalMoles() const
Return the total moles in the phase.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
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_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem.
#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...