18 #include "vcs_SpeciesProperties.h"
19 #include "vcs_species_thermo.h"
32 int vcs_timing_print_lvl = 1;
34 VCS_SOLVE::VCS_SOLVE() :
38 m_numElemConstraints(0),
43 m_numRxnMinorZeroed(0),
54 m_totalMoleScale(1.0),
57 m_Faraday_dim(Cantera::ElectronCharge * Cantera::
Avogadro),
60 m_timing_print_lvl(1),
61 m_VCS_UnitsFormat(VCS_UNITS_UNITLESS)
100 string ser =
"VCS_SOLVE: ERROR:\n\t";
101 if (nspecies0 <= 0) {
102 plogf(
"%s Number of species is nonpositive\n", ser.c_str());
103 throw vcsError(
"VCS_SOLVE()",
104 ser +
" Number of species is nonpositive\n",
107 if (nelements <= 0) {
108 plogf(
"%s Number of elements is nonpositive\n", ser.c_str());
109 throw vcsError(
"VCS_SOLVE()",
110 ser +
" Number of species is nonpositive\n",
114 plogf(
"%s Number of phases is nonpositive\n", ser.c_str());
115 throw vcsError(
"VCS_SOLVE()",
116 ser +
" Number of species is nonpositive\n",
215 for (
size_t iph = 0; iph < nphase0; iph++) {
236 if (vcs_timing_print_lvl == 0) {
266 for (j = 0; j < nspecies; j++) {
319 int retn = 0, iconv = 0;
320 size_t nspecies0, nelements0, nphase0;
323 int iprintTime =
std::max(ipr, ip1);
329 plogf(
"vcs: Unrecognized value of ifunc, %d: bailing!\n",
340 nelements0 = vprob->
ne;
346 plogf(
"vcs_priv_alloc returned a bad status, %d: bailing!\n",
357 plogf(
"vcs_pub_to_priv returned a bad status, %d: bailing!\n",
368 plogf(
"vcs_prep_oneTime returned a bad status, %d: bailing!\n",
380 plogf(
"vcs_prob_specify returned a bad status, %d: bailing!\n",
392 plogf(
"vcs_prep returned a bad status, %d: bailing!\n", retn);
400 plogf(
"vcs has determined the problem is not well posed: Bailing\n");
434 if (iprintTime > 0) {
445 }
else if (iconv == 1) {
446 plogf(
"WARNING: RANGE SPACE ERROR encountered\n");
464 "vcs_pub_to_priv ERROR :ill defined interface -> bailout:\n\t";
472 plogf(
"%sPrivate Data is dimensioned too small\n", ser);
477 plogf(
"%sPrivate Data is dimensioned too small\n", ser);
480 size_t nelements = pub->
ne;
482 plogf(
"%sPrivate Data is dimensioned too small\n", ser);
504 if (nelements > nspecies) {
528 for (
size_t i = 0; i < nspecies; i++) {
529 bool nonzero =
false;
530 for (
size_t j = 0; j < nelements; j++) {
537 plogf(
"vcs_prob_specifyFully:: species %d %s has a zero formula matrix!\n", i,
557 for (
size_t kspec = 0; kspec < nspecies; kspec++) {
564 plogf(
" duplMyselfAsVCS_SPECIES_THERMO returned an error!\n");
583 if (pub->
w.size() != 0) {
593 if (pub->
gai.size() != 0) {
594 for (
size_t i = 0; i < nelements; i++) {
605 for (
size_t j = 0; j < nelements; j++) {
607 for (
size_t kspec = 0; kspec < nspecies; kspec++) {
620 plogf(
"%sElement Abundances, m_elemAbundancesGoal[], not specified\n", ser);
649 for (
size_t iph = 0; iph < nph; iph++) {
671 for (
size_t i = 0; i < nspecies; i++) {
679 for (
size_t i = 0; i < nelements; i++) {
686 for (
size_t i = 0; i < nspecies; i++) {
694 if (pub->
PhaseID.size() != 0) {
695 std::vector<size_t> numPhSp(nph, 0);
696 for (
size_t kspec = 0; kspec < nspecies; kspec++) {
697 size_t iph = pub->
PhaseID[kspec];
699 plogf(
"%sSpecies to Phase Mapping, PhaseID, has a bad value\n",
701 plogf(
"\tPhaseID[%d] = %d\n", kspec, iph);
702 plogf(
"\tAllowed values: 0 to %d\n", nph - 1);
709 for (
size_t iph = 0; iph < nph; iph++) {
711 if (numPhSp[iph] != Vphase->
nSpecies()) {
712 plogf(
"%sNumber of species in phase %d, %s, doesn't match\n",
719 for (
size_t kspec = 0; kspec < nspecies; kspec++) {
724 plogf(
"%sSpecies to Phase Mapping, PhaseID, is not defined\n", ser);
738 for (
size_t i = 0; i < nelements; i++) {
745 plogf(
"we have an inconsistency!\n");
751 for (
size_t i = 0; i < nelements; i++) {
755 plogf(
"Charge neutrality condition %s is signicantly nonzero, %g. Giving up\n",
760 plogf(
"Charge neutrality condition %s not zero, %g. Setting it zero\n",
773 for (
size_t i = 0; i < nspecies; i++) {
780 for (
size_t iph = 0; iph < nph; iph++) {
788 for (
size_t k = 0; k < Vphase->
nSpecies(); k++) {
798 for (
size_t iph = 0; iph < nph; iph++) {
813 for (
size_t k = 1; k < Vphase->
nSpecies(); k++) {
824 if (pub->Title.size() == 0) {
825 m_title =
"Unspecified Problem Title";
857 size_t kspec, k, i, j, iph;
858 string yo(
"vcs_prob_specify ERROR: ");
860 bool status_change =
false;
892 if (pub->Title.size() == 0) {
894 m_title =
"Unspecified Problem Title";
913 plogf(
"%sPhase numbers have changed:%d %d\n", yo.c_str(),
919 plogf(
"%sSingleSpecies value have changed:%d %d\n", yo.c_str(),
926 plogf(
"%sGasPhase value have changed:%d %d\n", yo.c_str(),
935 plogf(
"%sNVolSpecies value have changed:%d %d\n", yo.c_str(),
942 plogf(
"%sPhaseName value have changed:%s %s\n", yo.c_str(),
949 status_change =
true;
1025 for (
size_t iph = 0; iph < pub->
NPhase; iph++) {
1035 const std::vector<double> & mfVector = pubPhase->
moleFractions();
1036 for (
size_t k = 0; k < pubPhase->
nSpecies(); k++) {
1038 pub->
mf[kT] = mfVector[k];
1043 plogf(
"We have an inconsistency in voltage, %g, %g\n",
1050 plogf(
"We have an inconsistency in mole fraction, %g, %g\n",
1055 sumMoles += pub->
w[kT];
1058 if (! vcs_doubleEqual(sumMoles, vPhase->
totalMoles())) {
1059 plogf(
"We have an inconsistency in total moles, %g %g\n",
1124 const double w[],
double volPM[])
1126 double VolTot = 0.0;
1127 for (
size_t iphase = 0; iphase <
m_numPhases; iphase++) {