14 static void print_space(
int num)
16 for (
int j = 0; j < num; j++) {
21 static void print_line(
const std::string& schar,
size_t num)
23 for (
size_t j = 0; j < num; j++) {
24 plogf(
"%s", schar.c_str());
31 bool printActualMoles =
true, inertYes =
false;
32 size_t i, j, l, k, kspec;
39 std::vector<size_t> sortindex(nspecies,0);
40 std::vector<double> xy(nspecies,0.0);
46 for (i = 0; i < nspecies; ++i) {
58 std::swap(xy[k], xy[l]);
59 std::swap(sortindex[k], sortindex[l]);
71 double molScale = 1.0;
72 if (printActualMoles) {
85 plogf(
"\t\t VCS_TP REPORT\n");
89 plogf(
" ERROR: CONVERGENCE CRITERION NOT SATISFIED.\n");
90 }
else if (iconv == 1) {
91 plogf(
" RANGE SPACE ERROR: Equilibrium Found but not all Element Abundances are Satisfied\n");
103 if (!printActualMoles) {
104 plogf(
"\t\tMole Scale = %15.5g kmol (all mole numbers and volumes are scaled by this value)\n",
113 plogf(
" Species Equilibrium kmoles ");
114 plogf(
"Mole Fraction ChemPot/RT SpecUnkType\n");
137 plogf(
"we have a problem\n");
146 plogf(
" Inert Gas Species ");
148 plogf(
" Inert Species in phase %16s ",
155 if (m_numSpeciesRdc != nspecies) {
156 plogf(
"\n SPECIES WITH LESS THAN 1.0E-32 KMOLES:\n\n");
157 for (kspec = m_numSpeciesRdc; kspec < nspecies; ++kspec) {
160 plogf(
" %14.7E %14.7E %12.4E",
181 print_line(
"-", m_numComponents*10 + 45);
182 plogf(
" |ComponentID|");
187 plogf(
" | Components|");
192 plogf(
" NonComponent | Moles |");
196 plogf(
" | DG/RT Rxn |\n");
197 print_line(
"-", m_numComponents*10 + 45);
198 for (
size_t irxn = 0; irxn <
m_numRxnTot; irxn++) {
200 plogf(
" %3d ", kspec);
209 print_line(
"-", m_numComponents*10 + 45);
217 double totalMoles = 0.0;
218 double gibbsPhase = 0.0;
219 double gibbsTotal = 0.0;
223 plogf(
" | ElementID |");
228 plogf(
" | Element |");
233 plogf(
" PhaseName |KMolTarget |");
237 plogf(
" | Gibbs Total |\n");
238 print_line(
"-", m_numElemConstraints*10 + 58);
239 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {
240 plogf(
" %3d ", iphase);
247 plogf(
"We have a problem\n");
253 plogf(
" %10.3g", gaPhase[j]);
254 gaTPhase[j] += gaPhase[j];
258 gibbsTotal += gibbsPhase;
259 plogf(
" | %18.11E |\n", gibbsPhase);
261 print_line(
"-", m_numElemConstraints*10 + 58);
262 plogf(
" TOTAL |%10.3e |", totalMoles);
264 plogf(
" %10.3g", gaTPhase[j]);
266 plogf(
" | %18.11E |\n", gibbsTotal);
268 print_line(
"-", m_numElemConstraints*10 + 58);
283 plogf(
"\n\tTotal Dimensionless Gibbs Free Energy = G/RT = %15.7E\n", g);
285 plogf(
"\t\t(Inert species have standard free energy of zero)\n");
288 plogf(
"\nElemental Abundances (kmol): ");
289 plogf(
" Actual Target Type ElActive\n");
303 plogf(
"Chemical Potentials of the Species: (dimensionless)\n");
306 plogf(
"\t\t(RT = %g ", rt);
309 plogf(
" Name TKMoles StandStateChemPot "
310 " ln(AC) ln(X_i) | F z_i phi | ChemPot | (-lnMnaught)");
311 plogf(
"| (MolNum ChemPot)|");
313 print_line(
"-", 147);
314 for (i = 0; i < nspecies; ++i) {
330 lx = log(tmp) - log(tpmoles);
336 plogf(
"%14.7E |", lx);
337 plogf(
"%14.7E | ", eContrib);
341 plogf(
"\n\t\twe have a problem - doesn't add up\n");
354 for (i = 0; i < 125; i++) {
357 plogf(
" %20.9E\n", g);
358 print_line(
"-", 147);
364 plogf(
"\nCounters: Iterations Time (seconds)\n");
366 plogf(
" vcs_basopt: %5d %11.5E\n",
368 plogf(
" vcs_TP: %5d %11.5E\n",
371 plogf(
" vcs_basopt: %5d %11s\n",
373 plogf(
" vcs_TP: %5d %11s\n",
398 plogf(
"\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
399 if (timing_print_lvl > 0) {
400 plogf(
" vcs_basopt: %5d %5d %11.5E\n",
403 plogf(
" vcs_TP: %5d %5d %11.5E\n",
406 plogf(
" vcs_inest: %5d %11.5E\n",
408 plogf(
" vcs_TotalTime: %11.5E\n",
411 plogf(
" vcs_basopt: %5d %5d %11s\n",
413 plogf(
" vcs_TP: %5d %5d %11s\n",
415 plogf(
" vcs_inest: %5d %11s\n",
417 plogf(
" vcs_TotalTime: %11s\n",
std::vector< double > m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
char m_unitsState
This specifies the current state of units for the Gibbs free energy properties in the program...
size_t m_numRxnTot
Total number of non-component species in the problem.
size_t m_numComponents
Number of components calculated for the problem.
std::vector< double > m_phasePhi
electric potential of the iph phase
std::vector< double > m_actCoeffSpecies_old
Molar-based Activity Coefficients for Species based on old mole numbers.
int T_Calls_vcs_TP
Current number of calls to vcs_TP.
int vcs_report(int iconv)
Print out a report on the state of the equilibrium problem to standard output.
std::string PhaseName
String name for the phase.
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
std::vector< size_t > m_indexRxnToSpecies
Mapping between the species index for noncomponent species and the full species index.
double m_temperature
Temperature (Kelvin)
std::vector< double > m_lnMnaughtSpecies
specifies the ln(Mnaught) used to calculate the chemical potentials
int m_timing_print_lvl
printing level of timing information
int Basis_Opts
number of optimizations of the components basis set done
std::vector< double > m_feSpecies_old
Free energy vector from the start of the current iteration.
int m_VCS_UnitsFormat
Units for the chemical potential data.
double Time_vcs_TP
Current time spent in vcs_TP.
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< double > m_deltaGRxn_new
Delta G(irxn) for the noncomponent species in the mechanism.
int T_Basis_Opts
Total number of optimizations of the components basis set done.
std::vector< double > m_elemAbundancesGoal
Element abundances vector Goals.
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.
std::vector< double > m_elemAbundances
Element abundances vector.
Phase information and Phase calculations for vcs.
double T_Time_vcs
Time spent in the vcs suite of programs.
#define VCS_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem...
std::vector< double > m_molNumSpecies_new
Tentative value of the mole number vector.
void vcs_printChemPotUnits(int unitsFormat) const
Print the string representing the Chemical potential units.
Internal declarations for the VCSnonideal package.
std::vector< double > m_molNumSpecies_old
Total moles of the species.
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 m_Faraday_dim
dimensionless value of Faraday's constant, F / RT (1/volt)
std::vector< std::string > m_elementName
Vector of strings containing the element names.
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< int > m_elementActive
Specifies whether an element constraint is active.
int Its
Current number of iterations in the main loop of vcs_TP() to solve for thermo equilibrium.
void vcs_TCounters_report(int timing_print_lvl=1)
Create a report on the plog file containing timing and its information.
double T_Time_inest
Time spent in initial estimator.
size_t m_numElemConstraints
Number of element constraints in the problem.
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
double m_totalMoleScale
Multiplier for the mole numbers within the nondimensionless formulation.
double T_Time_vcs_TP
Current time spent in vcs_TP.
size_t m_numPhases
Number of Phases in the problem.
double Time_basopt
Current Time spent in basopt.
#define VCS_DIMENSIONAL_G
dimensioned
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
void vcs_nondim_TP()
Nondimensionalize the problem data.
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
double vcs_VolTotal(const double tkelvin, const double pres, const double w[], double volPM[])
Calculation of the total volume and the partial molar volumes.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
std::vector< double > m_tPhaseMoles_old
Total kmols of species in each phase.
double vcs_nondimMult_TP(int mu_units, double TKelvin) const
Returns the multiplier for the nondimensionalization of the equations.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
DoubleStarStar m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
void vcs_redim_TP()
Redimensionalize the problem data.
std::vector< double > TPhInertMoles
Total kmoles of inert to add to each phase.
std::vector< double > m_PMVolumeSpecies
Partial molar volumes of the species.
int T_Calls_Inest
Current number of times the initial thermo equilibrium estimator has been called. ...
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.
double totalMoles() const
Return the total moles in the phase.
#define plogf
define this Cantera function to replace printf
std::vector< int > m_elType
Type of the element constraint.
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
std::vector< double > m_chargeSpecies
Charge of each species. Length = number of species.
VCS_COUNTERS * m_VCount
Timing and iteration counters for the vcs object.
double m_totalVol
Total volume of all phases. Units are m^3.
double T_Time_basopt
Total Time spent in basopt.
std::vector< std::string > m_speciesName
Species string name for the kth species.
size_t m_numSpeciesRdc
Current number of species in the problems.