diff --git a/Cantera/src/equil/vcs_VolPhase.cpp b/Cantera/src/equil/vcs_VolPhase.cpp index 9e14c546f..f28bdc41c 100644 --- a/Cantera/src/equil/vcs_VolPhase.cpp +++ b/Cantera/src/equil/vcs_VolPhase.cpp @@ -53,7 +53,7 @@ namespace VCSnonideal { m_VCS_UnitsFormat(VCS_UNITS_MKS), m_useCanteraCalls(false), TP_ptr(0), - TMoles(0.0), + v_totalMoles(0.0), m_totalVol(0.0), m_vcsStateStatus(VCS_STATECALC_OLD), m_phi(0.0), @@ -114,7 +114,7 @@ namespace VCSnonideal { m_VCS_UnitsFormat(b.m_VCS_UnitsFormat), m_useCanteraCalls(b.m_useCanteraCalls), TP_ptr(b.TP_ptr), - TMoles(b.TMoles), + v_totalMoles(b.v_totalMoles), m_phiVarIndex(-1), m_totalVol(b.m_totalVol), m_vcsStateStatus(VCS_STATECALC_OLD), @@ -217,7 +217,7 @@ namespace VCSnonideal { * have to be looked into. */ TP_ptr = b.TP_ptr; - TMoles = b.TMoles; + v_totalMoles = b.v_totalMoles; Xmol = b.Xmol; @@ -535,7 +535,7 @@ namespace VCSnonideal { const double * molesSpeciesVCS) { int kglob; double tmp; - TMoles = TMolesInert; + v_totalMoles = TMolesInert; if (molesSpeciesVCS == 0) { #ifdef DEBUG_MODE @@ -579,12 +579,12 @@ namespace VCSnonideal { kglob = IndSpecies[k]; tmp = MAX(0.0, molesSpeciesVCS[kglob]); Xmol[k] = tmp; - TMoles += tmp; + v_totalMoles += tmp; } } - if (TMoles > 0.0) { + if (v_totalMoles > 0.0) { for (int k = 0; k < NVolSpecies; k++) { - Xmol[k] /= TMoles; + Xmol[k] /= v_totalMoles; } Existence = 1; } else { @@ -646,13 +646,13 @@ namespace VCSnonideal { * Check for consistency with TPhMoles[] */ double Tcheck = TPhMoles[VP_ID]; - if (Tcheck != TMoles) { - if (vcs_doubleEqual(Tcheck, TMoles)) { - Tcheck = TMoles; + if (Tcheck != v_totalMoles) { + if (vcs_doubleEqual(Tcheck, v_totalMoles)) { + Tcheck = v_totalMoles; } else { plogf("vcs_VolPhase::setMolesFromVCSCheck: " "We have a consistency problem: %21.16g %21.16g\n", - Tcheck, TMoles); + Tcheck, v_totalMoles); std::exit(-1); } } @@ -877,7 +877,7 @@ namespace VCSnonideal { for (k = 0; k < NVolSpecies; k++) { m_totalVol += PartialMolarVol[k] * Xmol[k]; } - m_totalVol *= TMoles; + m_totalVol *= v_totalMoles; if (TMolesInert > 0.0) { if (m_gasPhase) { @@ -911,7 +911,7 @@ namespace VCSnonideal { // Make copies of ActCoeff and Xmol for use in taking differences std::vector ActCoeff_Base(ActCoeff); std::vector Xmol_Base(Xmol); - double TMoles_base = TMoles; + double TMoles_base = v_totalMoles; /* * Loop over the columns species to be deltad @@ -922,17 +922,17 @@ namespace VCSnonideal { * -> NOte Xmol[] and Tmoles are always positive or zero * quantities. */ - double moles_j_base = TMoles * Xmol_Base[j]; - deltaMoles_j = 1.0E-7 * moles_j_base + 1.0E-20 * TMoles + 1.0E-150; + double moles_j_base = v_totalMoles * Xmol_Base[j]; + deltaMoles_j = 1.0E-7 * moles_j_base + 1.0E-20 * v_totalMoles + 1.0E-150; /* * Now, update the total moles in the phase and all of the * mole fractions based on this. */ - TMoles = TMoles_base + deltaMoles_j; + v_totalMoles = TMoles_base + deltaMoles_j; for (k = 0; k < NVolSpecies; k++) { - Xmol[k] = Xmol_Base[k] * TMoles_base / TMoles; + Xmol[k] = Xmol_Base[k] * TMoles_base / v_totalMoles; } - Xmol[j] = (moles_j_base + deltaMoles_j) / TMoles; + Xmol[j] = (moles_j_base + deltaMoles_j) / v_totalMoles; /* * Go get new values for the activity coefficients. @@ -949,9 +949,9 @@ namespace VCSnonideal { ((ActCoeff[k] + ActCoeff_Base[k]) * 0.5 * deltaMoles_j); } /* - * Revert to the base case Xmol, TMoles + * Revert to the base case Xmol, v_totalMoles */ - TMoles = TMoles_base; + v_totalMoles = TMoles_base; vcs_vdcopy(Xmol, Xmol_Base, NVolSpecies); } /* @@ -1068,7 +1068,7 @@ namespace VCSnonideal { /************************************************************************************/ double vcs_VolPhase::TotalMoles() const { - return TMoles; + return v_totalMoles; } /************************************************************************************/ @@ -1078,7 +1078,7 @@ namespace VCSnonideal { /************************************************************************************/ void vcs_VolPhase::setTotalMoles(double tmols) { - TMoles = tmols; + v_totalMoles = tmols; } /************************************************************************************/ diff --git a/Cantera/src/equil/vcs_VolPhase.h b/Cantera/src/equil/vcs_VolPhase.h index 7371e3135..b06f5bfed 100644 --- a/Cantera/src/equil/vcs_VolPhase.h +++ b/Cantera/src/equil/vcs_VolPhase.h @@ -677,7 +677,7 @@ namespace VCSnonideal { /*! * units are kmol */ - double TMoles; + double v_totalMoles; //! Vector of the current mole fractions for species //! in the phase diff --git a/Cantera/src/equil/vcs_solve.cpp b/Cantera/src/equil/vcs_solve.cpp index bee5b21b4..0a4f1518a 100644 --- a/Cantera/src/equil/vcs_solve.cpp +++ b/Cantera/src/equil/vcs_solve.cpp @@ -199,7 +199,6 @@ namespace VCSnonideal { m_lnMnaughtSpecies.resize(nspecies0, 0.0); m_actCoeffSpecies_new.resize(nspecies0, 1.0); m_actCoeffSpecies_old.resize(nspecies0, 1.0); - m_phaseACAreCurrent.resize(nphase0, 0); m_wtSpecies.resize(nspecies0, 0.0); m_chargeSpecies.resize(nspecies0, 0.0); m_speciesThermoList.resize(nspecies0, (VCS_SPECIES_THERMO *)0); diff --git a/Cantera/src/equil/vcs_solve.h b/Cantera/src/equil/vcs_solve.h index 84da9fa94..a3936a107 100644 --- a/Cantera/src/equil/vcs_solve.h +++ b/Cantera/src/equil/vcs_solve.h @@ -1803,10 +1803,6 @@ public: */ DoubleStarStar m_dLnActCoeffdMolNum; - //! This boolean indicates whether the activity coefficients for a phase - //! are current. - std::vector m_phaseACAreCurrent; - //! Molecular weight of each species /*! * units = kg/kmol diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index 3f545f748..e2ab6b03e 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -4694,11 +4694,7 @@ namespace VCSnonideal { tlogMoles[iph] = log(tPhMoles_ptr[iph]); } } - /* - * Zero the indicator that that tells us the activity coefficients - * are current - */ - vcs_izero(VCS_DATA_PTR(m_phaseACAreCurrent), m_numPhases); + if (ll != 0) { l1 = lbot; @@ -4713,15 +4709,12 @@ namespace VCSnonideal { * not current */ for (iphase = 0; iphase < m_numPhases; iphase++) { - if (!m_phaseACAreCurrent[iphase]) { - Vphase = m_VolPhaseList[iphase]; - if (!Vphase->SingleSpecies) { - Vphase->setMolesFromVCS(stateCalc, molNum); - Vphase->sendToVCS_ActCoeff(stateCalc, VCS_DATA_PTR(actCoeff_ptr)); - } - m_phasePhi[iphase] = Vphase->electricPotential(); - m_phaseACAreCurrent[iphase] = 1; + Vphase = m_VolPhaseList[iphase]; + if (!Vphase->SingleSpecies) { + // Vphase->setMolesFromVCS(stateCalc, molNum); + Vphase->sendToVCS_ActCoeff(stateCalc, VCS_DATA_PTR(actCoeff_ptr)); } + m_phasePhi[iphase] = Vphase->electricPotential(); } /* ************************************************************** */ /* **** ALL SPECIES, OR COMPONENTS ****************************** */