16 bool printActualMoles =
true, inertYes =
false;
21 std::vector<size_t> sortindex(nspecies,0);
22 std::vector<double> xy(nspecies,0.0);
28 for (
size_t i = 0; i < nspecies; ++i) {
40 std::swap(xy[k], xy[l]);
41 std::swap(sortindex[k], sortindex[l]);
53 double molScale = 1.0;
54 if (printActualMoles) {
67 plogf(
"\t\t VCS_TP REPORT\n");
71 plogf(
" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
72 }
else if (iconv == 1) {
73 plogf(
" RANGE SPACE ERROR: Equilibrium Found but not all Element Abundances are Satisfied\n");
85 if (!printActualMoles) {
86 plogf(
"\t\tMole Scale = %15.5g kmol (all mole numbers and volumes are scaled by this value)\n",
95 plogf(
" Species Equilibrium kmoles ");
96 plogf(
"Mole Fraction ChemPot/RT SpecUnkType\n");
100 writeline(
' ', 13,
false);
107 size_t l = sortindex[i];
109 writeline(
' ', 13,
false);
119 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
127 plogf(
" Inert Gas Species ");
129 plogf(
" Inert Species in phase %16s ",
136 if (m_numSpeciesRdc != nspecies) {
137 plogf(
"\n SPECIES WITH LESS THAN 1.0E-32 KMOLES:\n\n");
138 for (
size_t kspec = m_numSpeciesRdc; kspec < nspecies; ++kspec) {
141 plogf(
" %14.7E %14.7E %12.4E",
161 writeline(
'-', m_numComponents*10 + 45,
true,
true);
162 plogf(
" |ComponentID|");
167 plogf(
" | Components|");
172 plogf(
" NonComponent | Moles |");
176 plogf(
" | DG/RT Rxn |\n");
177 writeline(
'-', m_numComponents*10 + 45);
178 for (
size_t irxn = 0; irxn <
m_numRxnTot; irxn++) {
180 plogf(
" %3d ", kspec);
189 writeline(
'-', m_numComponents*10 + 45);
197 double totalMoles = 0.0;
198 double gibbsPhase = 0.0;
199 double gibbsTotal = 0.0;
203 plogf(
" | ElementID |");
208 plogf(
" | Element |");
213 plogf(
" PhaseName |KMolTarget |");
217 plogf(
" | Gibbs Total |\n");
218 writeline(
'-', m_numElemConstraints*10 + 58);
219 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
220 plogf(
" %3d ", iphase);
227 throw CanteraError(
"VCS_SOLVE::vcs_report",
"we have a problem");
232 plogf(
" %10.3g", gaPhase[j]);
233 gaTPhase[j] += gaPhase[j];
237 gibbsTotal += gibbsPhase;
238 plogf(
" | %18.11E |\n", gibbsPhase);
240 writeline(
'-', m_numElemConstraints*10 + 58);
241 plogf(
" TOTAL |%10.3e |", totalMoles);
243 plogf(
" %10.3g", gaTPhase[j]);
245 plogf(
" | %18.11E |\n", gibbsTotal);
247 writeline(
'-', m_numElemConstraints*10 + 58);
262 plogf(
"\n\tTotal Dimensionless Gibbs Free Energy = G/RT = %15.7E\n", g);
264 plogf(
"\t\t(Inert species have standard free energy of zero)\n");
267 plogf(
"\nElemental Abundances (kmol): ");
268 plogf(
" Actual Target Type ElActive\n");
270 writeline(
' ', 26,
false);
280 writeline(
'-', 93,
true,
true);
281 plogf(
"Chemical Potentials of the Species: (dimensionless)\n");
284 plogf(
"\t\t(RT = %g ", rt);
287 plogf(
" Name TKMoles StandStateChemPot "
288 " ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
289 plogf(
"| (MolNum ChemPot)|");
290 writeline(
'-', 147,
true,
true);
291 for (
size_t i = 0; i < nspecies; ++i) {
292 size_t l = sortindex[i];
307 lx = log(tmp) - log(tpmoles);
313 plogf(
"%14.7E |", lx);
314 plogf(
"%14.7E | ", eContrib);
319 "we have a problem - doesn't add up");
331 for (
size_t i = 0; i < 125; i++) {
334 plogf(
" %20.9E\n", g);
341 plogf(
"\nCounters: Iterations Time (seconds)\n");
343 plogf(
" vcs_basopt: %5d %11.5E\n",
345 plogf(
" vcs_TP: %5d %11.5E\n",
348 plogf(
" vcs_basopt: %5d %11s\n",
350 plogf(
" vcs_TP: %5d %11s\n",
375 plogf(
"\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
376 if (timing_print_lvl > 0) {
377 plogf(
" vcs_basopt: %5d %5d %11.5E\n",
380 plogf(
" vcs_TP: %5d %5d %11.5E\n",
383 plogf(
" vcs_inest: %5d %11.5E\n",
385 plogf(
" vcs_TotalTime: %11.5E\n",
388 plogf(
" vcs_basopt: %5d %5d %11s\n",
390 plogf(
" vcs_TP: %5d %5d %11s\n",
392 plogf(
" vcs_inest: %5d %11s\n",
394 plogf(
" vcs_TotalTime: %11s\n",
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.
double vcs_nondimMult_TP(int mu_units, double TKelvin) const
Returns the multiplier for the nondimensionalization of the equations.
int Its
Current number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
std::vector< int > m_elType
Type of the element constraint.
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.
int Basis_Opts
number of optimizations of the components basis set done
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.
Array2D m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
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.
std::vector< double > m_phasePhi
electric potential of the iph phase
void vcs_nondim_TP()
Nondimensionalize the problem data.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
std::vector< double > m_lnMnaughtSpecies
specifies the ln(Mnaught) used to calculate the chemical potentials
std::string PhaseName
String name for the phase.
void vcs_redim_TP()
Redimensionalize the problem data.
void vcs_printChemPotUnits(int unitsFormat) const
Print the string representing the Chemical potential units.
int m_VCS_UnitsFormat
Units for the chemical potential data.
double totalMoles() const
Return the total moles in the phase.
std::vector< double > m_chargeSpecies
Charge of each species. Length = number of species.
size_t m_numSpeciesRdc
Current number of species in the problems.
std::vector< double > m_molNumSpecies_old
Total moles of the species.
int T_Basis_Opts
Total number of optimizations of the components basis set done.
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.
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.
std::vector< double > m_elemAbundances
Element abundances vector.
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.
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
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.
std::vector< double > m_tPhaseMoles_old
Total kmols of species in 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.
std::vector< double > m_molNumSpecies_new
Tentative value of the mole number vector.
std::vector< double > m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
std::vector< double > m_actCoeffSpecies_old
Molar-based Activity Coefficients for Species based on old mole numbers.
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
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.
std::vector< int > m_elementActive
Specifies whether an element constraint is active.
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
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.
std::vector< double > m_PMVolumeSpecies
Partial molar volumes of the species.
#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.
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 nondimensionless formulation.
size_t m_numRxnTot
Total number of non-component species in the problem.
std::vector< double > TPhInertMoles
Total kmoles of inert to add to each phase.
std::vector< double > m_elemAbundancesGoal
Element abundances vector Goals.
std::vector< double > m_feSpecies_old
Free energy vector from the start of the current iteration.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< double > m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
int T_Calls_vcs_TP
Current number of calls to vcs_TP.