vcs_VolPhase update: Made more members private

This commit is contained in:
Harry Moffat 2008-08-07 23:40:52 +00:00
parent 0b6ccbcbef
commit 6f985cdc78
8 changed files with 79 additions and 78 deletions

View file

@ -701,7 +701,7 @@ namespace VCSnonideal {
if (m_vprob->w[i] <= 0.0) {
int iph = m_vprob->PhaseID[i];
vcs_VolPhase *VPhase = m_vprob->VPhaseList[iph];
if (VPhase->NVolSpecies > 1) {
if (VPhase->nSpecies() > 1) {
plogf(" -1.000e+300\n");
} else {
plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]);
@ -1269,7 +1269,7 @@ namespace VCSnonideal {
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->NVolSpecies, VolPhase->totalMolesInert() );
VolPhase->nSpecies(), VolPhase->totalMolesInert() );
plogf("%16e\n", VolPhase->TotalMoles());
}
@ -1388,7 +1388,7 @@ namespace VCSnonideal {
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->NVolSpecies, VolPhase->totalMolesInert() );
VolPhase->nSpecies(), VolPhase->totalMolesInert() );
plogf("%16e\n", VolPhase->TotalMoles() );
}

View file

@ -42,7 +42,7 @@ namespace VCSnonideal {
p_activityConvention(0),
m_numElemConstraints(0),
m_elemGlobalIndex(0),
NVolSpecies(0),
m_numSpecies(0),
m_totalMolesInert(0.0),
m_isIdealSoln(false),
m_existence(0),
@ -75,7 +75,7 @@ namespace VCSnonideal {
* Destructor for the VolPhase object.
*/
vcs_VolPhase::~vcs_VolPhase() {
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
vcs_SpeciesProperties *sp = ListSpeciesPtr[k];
delete sp;
sp = 0;
@ -102,7 +102,7 @@ namespace VCSnonideal {
p_VCS_UnitsFormat(b.p_VCS_UnitsFormat),
p_activityConvention(b.p_activityConvention),
m_numElemConstraints(b.m_numElemConstraints),
NVolSpecies(b.NVolSpecies),
m_numSpecies(b.m_numSpecies),
m_totalMolesInert(b.m_totalMolesInert),
m_isIdealSoln(b.m_isIdealSoln),
m_existence(b.m_existence),
@ -139,7 +139,7 @@ namespace VCSnonideal {
vcs_VolPhase& vcs_VolPhase::operator=(const vcs_VolPhase& b) {
int k;
if (&b != this) {
int old_num = NVolSpecies;
int old_num = m_numSpecies;
// Note: we comment this out for the assignment operator
// specifically, because it isn't true for the assignment
@ -152,7 +152,7 @@ namespace VCSnonideal {
m_gasPhase = b.m_gasPhase;
m_eqnState = b.m_eqnState;
NVolSpecies = b.NVolSpecies;
m_numSpecies = b.m_numSpecies;
m_numElemConstraints = b.m_numElemConstraints;
ChargeNeutralityElement = b.ChargeNeutralityElement;
@ -165,16 +165,16 @@ namespace VCSnonideal {
m_elementActive = b.m_elementActive;
m_elementType = b.m_elementType;
m_formulaMatrix.resize(m_numElemConstraints, NVolSpecies, 0.0);
m_formulaMatrix.resize(m_numElemConstraints, m_numSpecies, 0.0);
for (int e = 0; e < m_numElemConstraints; e++) {
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
m_formulaMatrix[e][k] = b.m_formulaMatrix[e][k];
}
}
m_speciesUnknownType = b.m_speciesUnknownType;
m_elemGlobalIndex = b.m_elemGlobalIndex;
NVolSpecies = b.NVolSpecies;
m_numSpecies = b.m_numSpecies;
PhaseName = b.PhaseName;
m_totalMolesInert = b.m_totalMolesInert;
p_activityConvention= b.p_activityConvention;
@ -194,8 +194,8 @@ namespace VCSnonideal {
ListSpeciesPtr[k] = 0;
}
}
ListSpeciesPtr.resize(NVolSpecies, 0);
for (k = 0; k < NVolSpecies; k++) {
ListSpeciesPtr.resize(m_numSpecies, 0);
for (k = 0; k < m_numSpecies; k++) {
ListSpeciesPtr[k] =
new vcs_SpeciesProperties(*(b.ListSpeciesPtr[k]));
}
@ -281,11 +281,11 @@ namespace VCSnonideal {
m_singleSpecies = true;
}
if (NVolSpecies == nspecies && numElem == m_numElemConstraints) {
if (m_numSpecies == nspecies && numElem == m_numElemConstraints) {
return;
}
NVolSpecies = nspecies;
m_numSpecies = nspecies;
if (nspecies > 1) {
m_singleSpecies = false;
}
@ -293,8 +293,8 @@ namespace VCSnonideal {
IndSpecies.resize(nspecies, -1);
if ((int) ListSpeciesPtr.size() >= NVolSpecies) {
for (int i = 0; i < NVolSpecies; i++) {
if ((int) ListSpeciesPtr.size() >= m_numSpecies) {
for (int i = 0; i < m_numSpecies; i++) {
if (ListSpeciesPtr[i]) {
delete ListSpeciesPtr[i];
ListSpeciesPtr[i] = 0;
@ -340,7 +340,7 @@ namespace VCSnonideal {
m_elementActive.resize(numElemConstraints+1, 1);
m_elementType.resize(numElemConstraints, VCS_ELEM_TYPE_ABSPOS);
m_formulaMatrix.resize(numElemConstraints, NVolSpecies, 0.0);
m_formulaMatrix.resize(numElemConstraints, m_numSpecies, 0.0);
m_elementNames.resize(numElemConstraints, "");
m_elemGlobalIndex.resize(numElemConstraints, -1);
@ -392,7 +392,7 @@ namespace VCSnonideal {
TP_ptr->getGibbs_ref(VCS_DATA_PTR(SS0ChemicalPotential));
} else {
double R = vcsUtil_gasConstant(p_VCS_UnitsFormat);
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
int kglob = IndSpecies[k];
vcs_SpeciesProperties *sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO *sTherm = sProp->SpeciesThermo;
@ -433,7 +433,7 @@ namespace VCSnonideal {
TP_ptr->getStandardChemPotentials(VCS_DATA_PTR(StarChemicalPotential));
} else {
double R = vcsUtil_gasConstant(p_VCS_UnitsFormat);
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
int kglob = IndSpecies[k];
vcs_SpeciesProperties *sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO *sTherm = sProp->SpeciesThermo;
@ -473,12 +473,12 @@ namespace VCSnonideal {
*/
void vcs_VolPhase::setMoleFractions(const double * const xmol) {
double sum = -1.0;
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
Xmol[k] = xmol[k];
sum+= xmol[k];
}
if (std::fabs(sum) > 1.0E-13) {
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
Xmol[k] /= sum;
}
}
@ -568,14 +568,14 @@ namespace VCSnonideal {
}
#endif
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
if (m_speciesUnknownType[k] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
kglob = IndSpecies[k];
v_totalMoles += MAX(0.0, molesSpeciesVCS[kglob]);
}
}
if (v_totalMoles > 0.0) {
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
if (m_speciesUnknownType[k] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
kglob = IndSpecies[k];
tmp = MAX(0.0, molesSpeciesVCS[kglob]);
@ -587,8 +587,8 @@ namespace VCSnonideal {
// This is where we will start to store a better approximation
// for the mole fractions, when the phase doesn't exist.
// This is currently unimplemented.
for (int k = 0; k < NVolSpecies; k++) {
Xmol[k] = 1.0 / NVolSpecies;
for (int k = 0; k < m_numSpecies; k++) {
Xmol[k] = 1.0 / m_numSpecies;
}
m_existence = 0;
}
@ -598,14 +598,14 @@ namespace VCSnonideal {
*/
if (m_phiVarIndex >= 0) {
kglob = IndSpecies[m_phiVarIndex];
if (NVolSpecies == 1) {
if (m_numSpecies == 1) {
Xmol[m_phiVarIndex] = 1.0;
} else {
Xmol[m_phiVarIndex] = 0.0;
}
double phi = molesSpeciesVCS[kglob];
setElectricPotential(phi);
if (NVolSpecies == 1) {
if (m_numSpecies == 1) {
m_existence = 1;
}
}
@ -696,7 +696,7 @@ namespace VCSnonideal {
_updateActCoeff();
}
int kglob;
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
kglob = IndSpecies[k];
AC[kglob] = ActCoeff[k];
}
@ -718,7 +718,7 @@ namespace VCSnonideal {
(void) _updateVolPM();
}
int kglob;
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
kglob = IndSpecies[k];
VolPM[kglob] = PartialMolarVol[k];
}
@ -741,7 +741,7 @@ namespace VCSnonideal {
_updateGStar();
}
int kglob;
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
kglob = IndSpecies[k];
gstar[kglob] = StarChemicalPotential[k];
}
@ -826,7 +826,7 @@ namespace VCSnonideal {
if (m_useCanteraCalls) {
TP_ptr->getStandardVolumes(VCS_DATA_PTR(StarMolarVol));
} else {
for (int k = 0; k < NVolSpecies; k++) {
for (int k = 0; k < m_numSpecies; k++) {
int kglob = IndSpecies[k];
vcs_SpeciesProperties *sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO *sTherm = sProp->SpeciesThermo;
@ -871,19 +871,19 @@ namespace VCSnonideal {
if (m_useCanteraCalls) {
TP_ptr->getPartialMolarVolumes(VCS_DATA_PTR(PartialMolarVol));
} else {
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
kglob = IndSpecies[k];
vcs_SpeciesProperties *sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO *sTherm = sProp->SpeciesThermo;
StarMolarVol[k] = (sTherm->VolStar_calc(kglob, Temp, Pres));
}
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
PartialMolarVol[k] = StarMolarVol[k];
}
}
m_totalVol = 0.0;
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
m_totalVol += PartialMolarVol[k] * Xmol[k];
}
m_totalVol *= v_totalMoles;
@ -925,7 +925,7 @@ namespace VCSnonideal {
/*
* Loop over the columns species to be deltad
*/
for (j = 0; j < NVolSpecies; j++) {
for (j = 0; j < m_numSpecies; j++) {
/*
* Calculate a value for the delta moles of species j
* -> NOte Xmol[] and Tmoles are always positive or zero
@ -938,7 +938,7 @@ namespace VCSnonideal {
* mole fractions based on this.
*/
v_totalMoles = TMoles_base + deltaMoles_j;
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
Xmol[k] = Xmol_Base[k] * TMoles_base / v_totalMoles;
}
Xmol[j] = (moles_j_base + deltaMoles_j) / v_totalMoles;
@ -953,7 +953,7 @@ namespace VCSnonideal {
* Calculate the column of the matrix
*/
double * const lnActCoeffCol = dLnActCoeffdMolNumber[j];
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
lnActCoeffCol[k] = (ActCoeff[k] - ActCoeff_Base[k]) /
((ActCoeff[k] + ActCoeff_Base[k]) * 0.5 * deltaMoles_j);
}
@ -961,7 +961,7 @@ namespace VCSnonideal {
* Revert to the base case Xmol, v_totalMoles
*/
v_totalMoles = TMoles_base;
vcs_vdcopy(Xmol, Xmol_Base, NVolSpecies);
vcs_vdcopy(Xmol, Xmol_Base, m_numSpecies);
}
/*
* Go get base values for the activity coefficients.
@ -1000,11 +1000,11 @@ namespace VCSnonideal {
* Now copy over the values
*/
int j, k, jglob, kglob;
for (j = 0; j < NVolSpecies; j++) {
for (j = 0; j < m_numSpecies; j++) {
jglob = IndSpecies[j];
double * const lnACJacVCS_col = LnACJac_VCS[jglob];
const double * const lnACJac_col = dLnActCoeffdMolNumber[j];
for (k = 0; k < NVolSpecies; k++) {
for (k = 0; k < m_numSpecies; k++) {
kglob = IndSpecies[k];
lnACJacVCS_col[kglob] = lnACJac_col[k];
}
@ -1031,9 +1031,9 @@ namespace VCSnonideal {
m_phi = TP_ptr->electricPotential();
int nsp = TP_ptr->nSpecies();
int nelem = TP_ptr->nElements();
if (nsp != NVolSpecies) {
if (NVolSpecies != 0) {
plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, NVolSpecies);
if (nsp != m_numSpecies) {
if (m_numSpecies != 0) {
plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, m_numSpecies);
}
resize(VP_ID, nsp, nelem, PhaseName.c_str());
}
@ -1528,5 +1528,11 @@ namespace VCSnonideal {
int vcs_VolPhase::elementActive(const int e) const {
return m_elementActive[e];
}
//! Return the number of species in the phase
int vcs_VolPhase::nSpecies() const {
return m_numSpecies;
}
}

View file

@ -534,6 +534,10 @@ namespace VCSnonideal {
int elementActive(const int e) const;
//! Return the number of species in the phase
int nSpecies() const;
private:
//! Evaluate the activity coefficients at the current conditions
@ -603,7 +607,6 @@ namespace VCSnonideal {
*/
void _updateMoleFractionDependencies();
/*************************************************************************
* MEMBER DATA *
@ -747,10 +750,10 @@ namespace VCSnonideal {
//! storred in VCS_PROB or VCS_SOLVE
std::vector<int> m_elemGlobalIndex;
public:
//! Number of species in the phase
int NVolSpecies;
int m_numSpecies;
public:
//! String name for the phase
std::string PhaseName;

View file

@ -24,16 +24,9 @@
namespace VCSnonideal {
void VCS_SOLVE::vcs_SSPhase(void)
/**************************************************************************
*
* vcs_SSPhase:
*
* Calculate the status of single species phases.
*
*************************************************************************/
{
// Calculate the status of single species phases.
void VCS_SOLVE::vcs_SSPhase() {
int kspec, iph;
vcs_VolPhase *Vphase;
@ -57,8 +50,7 @@ namespace VCSnonideal {
if (TPhInertMoles[iph] == 0.0) {
Vphase->m_singleSpecies = true;
}
}
Vphase->NVolSpecies = numPhSpecies[iph];
}
}
/*

View file

@ -285,7 +285,7 @@ namespace VCSnonideal {
plogf("%16s %5d %5d %8d ", Vphase->PhaseName.c_str(),
Vphase->VP_ID, Vphase->m_singleSpecies, Vphase->m_gasPhase);
plogf("%16s %8d %16e ", EOS_cstr.c_str(),
Vphase->NVolSpecies, Vphase->totalMolesInert());
Vphase->nSpecies(), Vphase->totalMolesInert());
if (iest >= 0) plogf("%16e\n", Vphase->TotalMoles());
else plogf(" N/A\n");
}
@ -321,7 +321,7 @@ namespace VCSnonideal {
for (iphase = 0; iphase < NPhase; iphase++) {
Vphase = VPhaseList[iphase];
Vphase->setState_TP(T, PresPA);
for (int kindex = 0; kindex < Vphase->NVolSpecies; kindex++) {
for (int kindex = 0; kindex < Vphase->nSpecies(); kindex++) {
int kglob = Vphase->spGlobalIndexVCS(kindex);
plogf("%16s ", SpName[kglob].c_str());
if (kindex == 0) {
@ -489,7 +489,7 @@ namespace VCSnonideal {
istart = iK;
vcs_VolPhase *volP = VPhaseList[iphase];
//const Cantera::ThermoPhase *tptr = volP->ptrThermoPhase();
int nSpeciesPhase = volP->NVolSpecies;
int nSpeciesPhase = volP->nSpecies();
volPM.resize(nSpeciesPhase, 0.0);
volP->sendToVCS_VolPM(VCS_DATA_PTR(volPM));
@ -518,7 +518,7 @@ namespace VCSnonideal {
vcs_VolPhase *volP = VPhaseList[iphase];
const Cantera::ThermoPhase *tp = volP->ptrThermoPhase();
string phaseName = volP->PhaseName;
int nSpeciesPhase = volP->NVolSpecies;
int nSpeciesPhase = volP->nSpecies();
volP->sendToVCS_VolPM(VCS_DATA_PTR(volPM));
double TMolesPhase = volP->TotalMoles();
//AssertTrace(TMolesPhase == m_mix->phaseMoles(iphase));

View file

@ -666,7 +666,7 @@ namespace VCSnonideal {
}
for (iph = 0; iph < nph; iph++) {
Vphase = pub->VPhaseList[iph];
if (numPhSp[iph] != Vphase->NVolSpecies) {
if (numPhSp[iph] != Vphase->nSpecies()) {
plogf("%sNumber of species in phase %d, %s, doesn't match\n",
ser, iph, Vphase->PhaseName.c_str());
return VCS_PUB_BAD;
@ -724,7 +724,7 @@ namespace VCSnonideal {
* data space.
*/
Vphase = m_VolPhaseList[iph];
for (int k = 0; k < Vphase->NVolSpecies; k++) {
for (int k = 0; k < Vphase->nSpecies(); k++) {
vcs_SpeciesProperties *sProp = Vphase->speciesProperty(k);
int kT = Vphase->spGlobalIndexVCS(k);
sProp->SpeciesThermo = m_speciesThermoList[kT];
@ -749,7 +749,7 @@ namespace VCSnonideal {
*/
int iSolvent = Vphase->spGlobalIndexVCS(0);
double mnaught = m_wtSpecies[iSolvent] / 1000.;
for (int k = 1; k < Vphase->NVolSpecies; k++) {
for (int k = 1; k < Vphase->nSpecies(); k++) {
int kspec = Vphase->spGlobalIndexVCS(k);
m_actConventionSpecies[kspec] = Vphase->p_activityConvention;
m_lnMnaughtSpecies[kspec] = log(mnaught);
@ -869,10 +869,10 @@ namespace VCSnonideal {
vPhase->m_eqnState = pub_phase_ptr->m_eqnState;
if (vPhase->NVolSpecies != pub_phase_ptr->NVolSpecies) {
if (vPhase->nSpecies() != pub_phase_ptr->nSpecies()) {
plogf("%sNVolSpecies value have changed:%d %d\n", yo.c_str(),
vPhase->NVolSpecies,
pub_phase_ptr->NVolSpecies);
vPhase->nSpecies(),
pub_phase_ptr->nSpecies());
retn = VCS_PUB_BAD;
}
@ -965,7 +965,7 @@ namespace VCSnonideal {
pubPhase->setElectricPotential(vPhase->electricPotential());
double sumMoles = pubPhase->totalMolesInert();
pubPhase->setMoleFractions(VCS_DATA_PTR(vPhase->moleFractions()));
for (int k = 0; k < pubPhase->NVolSpecies; k++) {
for (int k = 0; k < pubPhase->nSpecies(); k++) {
kT = pubPhase->spGlobalIndexVCS(k);
if (pubPhase->phiVarIndex() == k) {

View file

@ -1271,7 +1271,7 @@ private:
double * const ss, double test);
//! Calculate the status of single species phases.
void vcs_SSPhase(void);
//! This function recalculates the deltaG for reaction, irxn

View file

@ -181,7 +181,7 @@ namespace VCSnonideal {
plogf(" PRESSURE%22.8g %3s\n", m_pressurePA, "Pa ");
plogf(" TEMPERATURE%19.3f K\n", m_temperature);
Vphase = m_VolPhaseList[0];
if (Vphase->NVolSpecies > 0) {
if (Vphase->nSpecies() > 0) {
plogf(" PHASE1 INERTS%17.3f\n", TPhInertMoles[0]);
}
if (m_numPhases > 0) {
@ -2720,7 +2720,7 @@ namespace VCSnonideal {
}
double phaseDG = 1.0;
for (int kk = 0; kk < Vphase->NVolSpecies; kk++) {
for (int kk = 0; kk < Vphase->nSpecies(); kk++) {
kspec = Vphase->spGlobalIndexVCS(kk);
irxn = kspec + m_numComponents;
if (m_deltaGRxn_old[irxn] > 50.0) m_deltaGRxn_old[irxn] = 50.0;
@ -3091,7 +3091,7 @@ namespace VCSnonideal {
m_deltaGRxn_new[irxn]);
#endif
Vphase = m_VolPhaseList[iph];
int numSpPhase = Vphase->NVolSpecies;
int numSpPhase = Vphase->nSpecies();
m_deltaMolNumSpecies[kspec] =
m_totalMolNum * 10.0 * VCS_DELETE_PHASE_CUTOFF / numSpPhase;
}
@ -3509,7 +3509,7 @@ namespace VCSnonideal {
vcs_VolPhase *Vphase = m_VolPhaseList[iph];
if (! Vphase->m_singleSpecies) {
double sum = 0.0;
for (k = 0; k < Vphase->NVolSpecies; k++) {
for (k = 0; k < Vphase->nSpecies(); k++) {
kspec = Vphase->spGlobalIndexVCS(k);
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
sum += molNumSpecies[kspec];
@ -3523,7 +3523,7 @@ namespace VCSnonideal {
if (lneed) {
double poly = 0.0;
for (k = 0; k < Vphase->NVolSpecies; k++) {
for (k = 0; k < Vphase->nSpecies(); k++) {
kspec = Vphase->spGlobalIndexVCS(k);
irxn = kspec - m_numComponents;
// We may need to look at deltaGRxn for components!
@ -3538,7 +3538,7 @@ namespace VCSnonideal {
* All of the m_deltaGRxn_new[]'s will be equal. If deltaGRxn[] is negative, then
* the phase will come back into existence.
*/
for (k = 0; k < Vphase->NVolSpecies; k++) {
for (k = 0; k < Vphase->nSpecies(); k++) {
kspec = Vphase->spGlobalIndexVCS(k);
irxn = kspec - m_numComponents;
if (irxn >= 0) {
@ -4432,7 +4432,7 @@ namespace VCSnonideal {
const bool do_deleted) {
vcs_VolPhase *Vphase = m_VolPhaseList[iph];
int nkk = Vphase->NVolSpecies;
int nkk = Vphase->nSpecies();
int k, kspec;
#ifdef DEBUG_MODE