vcs_Volphase update: eliminating more members and simplifying.

This commit is contained in:
Harry Moffat 2008-07-03 23:24:04 +00:00
parent 2fe5039614
commit f494e6ee78
11 changed files with 27 additions and 148 deletions

View file

@ -1441,7 +1441,7 @@ namespace VCSnonideal {
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
std::string sEOS = string16_EOSType(VolPhase->m_eqnState);
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->SingleSpecies,
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->NVolSpecies, VolPhase->TMolesInert );
plogf("%16e\n", VolPhase->TotalMoles());
@ -1560,7 +1560,7 @@ namespace VCSnonideal {
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
std::string sEOS = string16_EOSType(VolPhase->m_eqnState);
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->SingleSpecies,
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->NVolSpecies, VolPhase->TMolesInert );
plogf("%16e\n", VolPhase->TotalMoles() );

View file

@ -33,7 +33,7 @@ namespace VCSnonideal {
m_owningSolverObject(0),
VP_ID(-1),
Domain_ID(-1),
SingleSpecies(true),
m_singleSpecies(true),
m_gasPhase(false),
m_eqnState(VCS_EOS_CONSTANT),
nElemConstraints(0),
@ -46,7 +46,6 @@ namespace VCSnonideal {
m_isIdealSoln(false),
m_existence(0),
m_MFStartIndex(0),
Activity_Coeff_Model(VCS_AC_CONSTANT),
IndSpecies(0),
//IndSpeciesContig(true),
m_VCS_UnitsFormat(VCS_UNITS_MKS),
@ -97,7 +96,7 @@ namespace VCSnonideal {
m_owningSolverObject(b.m_owningSolverObject),
VP_ID(b.VP_ID),
Domain_ID(b.Domain_ID),
SingleSpecies(b.SingleSpecies),
m_singleSpecies(b.m_singleSpecies),
m_gasPhase(b.m_gasPhase),
m_eqnState(b.m_eqnState),
nElemConstraints(b.nElemConstraints),
@ -108,8 +107,6 @@ namespace VCSnonideal {
m_isIdealSoln(b.m_isIdealSoln),
m_existence(b.m_existence),
m_MFStartIndex(b.m_MFStartIndex),
Activity_Coeff_Model(b.Activity_Coeff_Model),
//IndSpeciesContig(b.IndSpeciesContig),
m_VCS_UnitsFormat(b.m_VCS_UnitsFormat),
m_useCanteraCalls(b.m_useCanteraCalls),
TP_ptr(b.TP_ptr),
@ -152,7 +149,7 @@ namespace VCSnonideal {
VP_ID = b.VP_ID;
Domain_ID = b.Domain_ID;
SingleSpecies = b.SingleSpecies;
m_singleSpecies = b.m_singleSpecies;
m_gasPhase = b.m_gasPhase;
m_eqnState = b.m_eqnState;
@ -185,7 +182,6 @@ namespace VCSnonideal {
m_isIdealSoln = b.m_isIdealSoln;
m_existence = b.m_existence;
m_MFStartIndex = b.m_MFStartIndex;
Activity_Coeff_Model = b.Activity_Coeff_Model;
/*
* Do a shallow copy because we haven' figured this out.
@ -283,9 +279,9 @@ namespace VCSnonideal {
}
}
if (nspecies > 1) {
SingleSpecies = false;
m_singleSpecies = false;
} else {
SingleSpecies = true;
m_singleSpecies = true;
}
if (NVolSpecies == nspecies) {
@ -294,7 +290,7 @@ namespace VCSnonideal {
NVolSpecies = nspecies;
if (nspecies > 1) {
SingleSpecies = false;
m_singleSpecies = false;
}
IndSpecies.resize(nspecies,-1);
@ -350,18 +346,6 @@ namespace VCSnonideal {
}
if (m_useCanteraCalls) {
TP_ptr->getActivityCoefficients(VCS_DATA_PTR(ActCoeff));
} else {
switch (Activity_Coeff_Model) {
case VCS_AC_CONSTANT:
/*
* Don't need to do anything since ActCoeff[] is initialized to
* the value of one, and never changed for this model.
*/
break;
default:
plogf("%sERROR: unknown model\n");
std::exit(-1);
}
}
m_UpToDate_AC = true;
}

View file

@ -551,7 +551,7 @@ namespace VCSnonideal {
int Domain_ID;
//! If true, this phase consists of a single species
int SingleSpecies;
bool m_singleSpecies;
//! If true, this phase is a gas-phase like phase
/*!
@ -677,14 +677,6 @@ namespace VCSnonideal {
*/
int m_MFStartIndex;
public:
//! Integer representing the activity coefficient model
/*!
* The known models are listed at the top of this page
*/
int Activity_Coeff_Model;
private:
//! Index into the species vectors
/*!
* Maps the phase species number into the global species number.

View file

@ -177,7 +177,7 @@ namespace VCSnonideal {
}
TMolesMultiphase = 0.0;
for (iph = 0; iph < m_numPhases; iph++) {
if (! m_VolPhaseList[iph]->SingleSpecies) {
if (! m_VolPhaseList[iph]->m_singleSpecies) {
TMolesMultiphase += m_tPhaseMoles_new[iph];
}
}

View file

@ -49,13 +49,13 @@ namespace VCSnonideal {
*/
for (iph = 0; iph < m_numPhases; iph++) {
Vphase = m_VolPhaseList[iph];
Vphase->SingleSpecies = false;
Vphase->m_singleSpecies = false;
if (TPhInertMoles[iph] > 0.0) {
Vphase->setExistence(2);
}
if (numPhSpecies[iph] <= 1) {
if (TPhInertMoles[iph] == 0.0) {
Vphase->SingleSpecies = true;
Vphase->m_singleSpecies = true;
}
}
Vphase->NVolSpecies = numPhSpecies[iph];
@ -70,7 +70,7 @@ namespace VCSnonideal {
for (kspec = 0; kspec < m_numSpeciesTot; kspec++) {
iph = m_phaseID[kspec];
Vphase = m_VolPhaseList[iph];
if (Vphase->SingleSpecies) m_SSPhase[kspec] = TRUE;
if (Vphase->m_singleSpecies) m_SSPhase[kspec] = TRUE;
else m_SSPhase[kspec] = FALSE;
}
}

View file

@ -283,7 +283,7 @@ namespace VCSnonideal {
Vphase = VPhaseList[iphase];
std::string EOS_cstr = string16_EOSType(Vphase->m_eqnState);
plogf("%16s %5d %5d %8d ", Vphase->PhaseName.c_str(),
Vphase->VP_ID, Vphase->SingleSpecies, Vphase->m_gasPhase);
Vphase->VP_ID, Vphase->m_singleSpecies, Vphase->m_gasPhase);
plogf("%16s %8d %16e ", EOS_cstr.c_str(),
Vphase->NVolSpecies, Vphase->TMolesInert);
if (iest >= 0) plogf("%16e\n", Vphase->TotalMoles());

View file

@ -139,7 +139,7 @@ namespace VCSnonideal {
}
}
for (j = 0; j < m_numPhases; j++) {
if (! (m_VolPhaseList[j])->SingleSpecies) {
if (! (m_VolPhaseList[j])->m_singleSpecies) {
if (m_tPhaseMoles_old[j] > 0.0)
s -= SQUARE(dnPhase_irxn[j]) / m_tPhaseMoles_old[j];
}
@ -323,7 +323,7 @@ namespace VCSnonideal {
/*
* We don't need to call single species phases;
*/
if (!Vphase->SingleSpecies && !Vphase->isIdealSoln()) {
if (!Vphase->m_singleSpecies && !Vphase->isIdealSoln()) {
/*
* update the mole numbers
*/

View file

@ -852,10 +852,10 @@ namespace VCSnonideal {
retn = VCS_PUB_BAD;
}
if (vPhase->SingleSpecies != pub_phase_ptr->SingleSpecies) {
if (vPhase->m_singleSpecies != pub_phase_ptr->m_singleSpecies) {
plogf("%sSingleSpecies value have changed:%d %d\n", yo.c_str(),
vPhase->SingleSpecies,
pub_phase_ptr->SingleSpecies);
vPhase->m_singleSpecies,
pub_phase_ptr->m_singleSpecies);
retn = VCS_PUB_BAD;
}
@ -892,7 +892,7 @@ namespace VCSnonideal {
vPhase->TMolesInert = pub_phase_ptr->TMolesInert;
if (TPhInertMoles[iph] > 0.0) {
vPhase->setExistence(2);
vPhase->SingleSpecies = FALSE;
vPhase->m_singleSpecies = FALSE;
}
/*

View file

@ -982,9 +982,6 @@ public:
double vcs_GibbsPhase(int iphase, const double * const w,
const double * const fe);
double vcs_Gxs_phase_calc(vcs_VolPhase *Vphase, double *mf_PO);
double vcs_Gxs_calc(int iphase);
//! Transfer the results of the equilibrium calculation back to VCS_PROB
/*!
* The VCS_PUB structure is returned to the user.

View file

@ -1137,7 +1137,7 @@ namespace VCSnonideal {
l2normdg(VCS_DATA_PTR(m_deltaGRxn_old)),
l2normdg(VCS_DATA_PTR(m_deltaGRxn_new)));
plogf(" Total kmoles of gas = %15.7E\n", m_tPhaseMoles_old[0]);
if ((m_numPhases > 1) && (! (m_VolPhaseList[1])->SingleSpecies)) {
if ((m_numPhases > 1) && (! (m_VolPhaseList[1])->m_singleSpecies)) {
plogf(" Total kmoles of liquid = %15.7E\n", m_tPhaseMoles_old[1]);
} else {
plogf(" Total kmoles of liquid = %15.7E\n", 0.0);
@ -1261,7 +1261,7 @@ namespace VCSnonideal {
justDeletedMultiPhase = FALSE;
for (iph = 0; iph < m_numPhases; iph++) {
Vphase = m_VolPhaseList[iph];
if (!(Vphase->SingleSpecies)) {
if (!(Vphase->m_singleSpecies)) {
if (m_tPhaseMoles_old[iph] != 0.0 &&
m_tPhaseMoles_old[iph]/m_totalMolNum <= VCS_DELETE_PHASE_CUTOFF) {
soldel = 1;
@ -2657,7 +2657,7 @@ namespace VCSnonideal {
return false;
}
int irxn, kspec;
if (Vphase->SingleSpecies) {
if (Vphase->m_singleSpecies) {
kspec = Vphase->spGlobalIndexVCS(0);
irxn = kspec + m_numComponents;
if(m_deltaGRxn_old[irxn] < 0.0) {
@ -3106,7 +3106,7 @@ namespace VCSnonideal {
}
for (j = 0; j < m_numPhases; j++) {
Vphase = m_VolPhaseList[j];
if (! Vphase->SingleSpecies) {
if (! Vphase->m_singleSpecies) {
if (m_tPhaseMoles_old[j] > 0.0)
s -= SQUARE(dnPhase_irxn[j]) / m_tPhaseMoles_old[j];
}
@ -3454,7 +3454,7 @@ namespace VCSnonideal {
for (iph = 0; iph < m_numPhases; iph++) {
lneed = FALSE;
vcs_VolPhase *Vphase = m_VolPhaseList[iph];
if (! Vphase->SingleSpecies) {
if (! Vphase->m_singleSpecies) {
double sum = 0.0;
for (k = 0; k < Vphase->NVolSpecies; k++) {
kspec = Vphase->spGlobalIndexVCS(k);
@ -4675,7 +4675,7 @@ namespace VCSnonideal {
for (iphase = 0; iphase < m_numPhases; iphase++) {
Vphase = m_VolPhaseList[iphase];
Vphase->updateFromVCS_MoleNumbers(stateCalc);
if (!Vphase->SingleSpecies) {
if (!Vphase->m_singleSpecies) {
Vphase->sendToVCS_ActCoeff(stateCalc, VCS_DATA_PTR(actCoeff_ptr));
}
m_phasePhi[iphase] = Vphase->electricPotential();
@ -5157,7 +5157,7 @@ namespace VCSnonideal {
/*
* Single species Phase
*/
if (vPhase->SingleSpecies) {
if (vPhase->m_singleSpecies) {
kspec = vPhase->spGlobalIndexVCS(0);
#ifdef DEBUG_MODE
if (iphase != m_phaseID[kspec]) {

View file

@ -354,100 +354,6 @@ double VCS_SPECIES_THERMO::eval_ac(int kglob)
}
return ac;
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
double VCS_SOLVE::vcs_Gxs_phase_calc(vcs_VolPhase *Vphase, double *mf_PO)
/**************************************************************************
*
* vcs_Gxs_calc:
*
* This function evaluates the Gibbs Excess free energy function for
* the phase pointed to by Vphase.
*
* There are two ways. They may be evaluated from the
* activity coefficients themselves
*
* Gxs/RT = sum_i_inphase( X_i * ln (ActCoeff_i))
*
* Or, the actual formulas for the excess Gibbs free energy may
* be used (which the activity coefficients probably came from anyway.
*
* Input
* phase_ptr => Pointer to the phase that we want to calculate
* the
* mf_PO => Vector of mole fractions in the phase
* in "Phase Order" order. This must sum to one. However
* this condition is not checked.
*
* Output
* return value = activity coefficient for species kspec
***************************************************************************/
{
int kspec, kglob;
double Gxs = 0.0, ac;
VCS_SPECIES_THERMO *ts_ptr;
if (Vphase->Activity_Coeff_Model != VCS_AC_CONSTANT) {
for (kspec = 0; kspec < Vphase->NVolSpecies; kspec++) {
kglob = Vphase->spGlobalIndexVCS(kspec);
ts_ptr = m_speciesThermoList[kglob];
ac = ts_ptr->eval_ac(kspec);
Gxs += mf_PO[kspec] * log(ac);
}
}
return Gxs;
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
double VCS_SOLVE::vcs_Gxs_calc(int iphase)
/**************************************************************************
*
* vcs_Gxs_calc:
*
* This function evaluates the Gibbs Excess free energy function.
*
* There are two ways. They may be evaluated from the
* activity coefficients themselves
*
* Gxs/RT = sum_i_inphase( X_i * ln (ActCoeff_i))
*
* Or, the actual formulas for the excess Gibbs free energy may
* be used (which the activity coefficients probably came from anyway.
*
* Input
*
*
* Output
* return value = activity coefficient for species kspec
***************************************************************************/
{
int kspec;
double Gxs = 0.0, ac;
double totmol = m_tPhaseMoles_old[iphase];
vcs_VolPhase *Vphase = m_VolPhaseList[iphase];
VCS_SPECIES_THERMO *ts_ptr;
if (totmol != 0.0 && Vphase->Activity_Coeff_Model != VCS_AC_CONSTANT) {
for (kspec = 0; kspec < m_numSpeciesRdc; kspec++) {
if (m_phaseID[kspec] == iphase) {
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
ts_ptr = m_speciesThermoList[kspec];
ac = ts_ptr->eval_ac(kspec);
Gxs += m_molNumSpecies_old[kspec]/totmol * log(ac);
} else {
plogf("FILL IN\n");
exit(-1);
}
}
}
}
return Gxs;
}
/*****************************************************************************/
}