Fixed a few features with phases consisting solely of electrons.
This commit is contained in:
parent
466d57250b
commit
6b14e20620
3 changed files with 49 additions and 10 deletions
|
|
@ -1036,6 +1036,9 @@ namespace VCSnonideal {
|
|||
* Also decide whether we need a new charge neutrality
|
||||
* element in the phase to enforce a charge neutrality
|
||||
* constraint.
|
||||
* We also decide whether this is a single species phase
|
||||
* with the voltage being the independent variable setting
|
||||
* the chemical potential of the electrons.
|
||||
*/
|
||||
VolPhase->transferElementsFM(tPhase);
|
||||
|
||||
|
|
@ -1338,11 +1341,14 @@ namespace VCSnonideal {
|
|||
vprob->w[kglob] = tPhase->electricPotential();
|
||||
}
|
||||
volPhase->setMolesFromVCS(VCS_STATECALC_OLD, VCS_DATA_PTR(vprob->w));
|
||||
if (volPhase->totalMoles() > 0.0) {
|
||||
volPhase->setExistence(1);
|
||||
if ((nSpPhase == 1) && (volPhase->phiVarIndex() == 0)) {
|
||||
volPhase->setExistence(VCS_PHASE_EXIST_ALWAYS);
|
||||
} else if (volPhase->totalMoles() > 0.0) {
|
||||
volPhase->setExistence(VCS_PHASE_EXIST_YES);
|
||||
} else {
|
||||
volPhase->setExistence(0);
|
||||
volPhase->setExistence(VCS_PHASE_EXIST_NO);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Transfer initial element abundances to the vprob object.
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ namespace VCSnonideal {
|
|||
m_useCanteraCalls(false),
|
||||
TP_ptr(0),
|
||||
v_totalMoles(0.0),
|
||||
m_phiVarIndex(-1),
|
||||
m_totalVol(0.0),
|
||||
m_vcsStateStatus(VCS_STATECALC_OLD),
|
||||
m_phi(0.0),
|
||||
|
|
@ -1189,11 +1190,15 @@ namespace VCSnonideal {
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
if (m_singleSpecies && (m_phiVarIndex == 0)) {
|
||||
m_existence = VCS_PHASE_EXIST_ALWAYS;
|
||||
} else {
|
||||
if (totalMols > 0.0) {
|
||||
m_existence = VCS_PHASE_EXIST_YES;
|
||||
} else {
|
||||
m_existence = VCS_PHASE_EXIST_NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
|
|
@ -1284,6 +1289,12 @@ namespace VCSnonideal {
|
|||
|
||||
void vcs_VolPhase::setPhiVarIndex(int phiVarIndex) {
|
||||
m_phiVarIndex = phiVarIndex;
|
||||
m_speciesUnknownType[m_phiVarIndex] = VCS_SPECIES_TYPE_INTERFACIALVOLTAGE;
|
||||
if (m_singleSpecies) {
|
||||
if (m_phiVarIndex == 0) {
|
||||
m_existence = VCS_PHASE_EXIST_ALWAYS;
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
@ -1320,7 +1331,20 @@ namespace VCSnonideal {
|
|||
else {
|
||||
if (m_totalMolesInert == 0.0) {
|
||||
if (v_totalMoles == 0.0) {
|
||||
plogf("vcs_VolPhase::setExistence setting true existence for phase with no moles");
|
||||
if (!m_singleSpecies || m_phiVarIndex != 0) {
|
||||
plogf("vcs_VolPhase::setExistence setting true existence for phase with no moles");
|
||||
plogendl();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_singleSpecies) {
|
||||
if (m_phiVarIndex == 0) {
|
||||
if (existence == VCS_PHASE_EXIST_NO || existence == VCS_PHASE_EXIST_ZEROEDPHASE) {
|
||||
plogf("vcs_VolPhase::Trying to set existence of an electron phase to false");
|
||||
plogendl();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -1376,6 +1400,8 @@ namespace VCSnonideal {
|
|||
}
|
||||
if (m_totalMolesInert > 0.0) {
|
||||
m_existence = VCS_PHASE_EXIST_ALWAYS;
|
||||
} else if (m_singleSpecies && (m_phiVarIndex == 0)) {
|
||||
m_existence = VCS_PHASE_EXIST_ALWAYS;
|
||||
} else {
|
||||
if (v_totalMoles > 0.0) {
|
||||
m_existence = VCS_PHASE_EXIST_YES;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@ namespace VCSnonideal {
|
|||
* then updates this object with their values. This is essentially
|
||||
* a gather routine.
|
||||
*
|
||||
* @param molesSpeciesVCS array of mole numbers. Note, the indecises for species in
|
||||
* @param molesSpeciesVCS Array of mole numbers. Note, the indecises
|
||||
* for species in
|
||||
* this array may not be contiguous. IndSpecies[] is needed
|
||||
* to gather the species into the local contiguous vector
|
||||
* format.
|
||||
|
|
@ -434,6 +435,8 @@ namespace VCSnonideal {
|
|||
//! Returns whether the object is using cantera calls.
|
||||
bool usingCanteraCalls() const;
|
||||
|
||||
//! Return the index of the species that represents the
|
||||
//! the voltage of the phase
|
||||
int phiVarIndex() const;
|
||||
|
||||
void setPhiVarIndex(int phiVarIndex);
|
||||
|
|
@ -465,7 +468,7 @@ namespace VCSnonideal {
|
|||
* @param spIndex local species index (0 to the number of species
|
||||
* in the phase)
|
||||
*
|
||||
* @return Returns the VCS_SOLVE species index of the that species
|
||||
* @return Returns the VCS_SOLVE species index of the species.
|
||||
* This changes as rearrangements are carried out.
|
||||
*/
|
||||
int spGlobalIndexVCS(const int spIndex) const;
|
||||
|
|
@ -794,15 +797,19 @@ namespace VCSnonideal {
|
|||
|
||||
//! Current state of existence:
|
||||
/*!
|
||||
* VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a higher level.
|
||||
* VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
|
||||
* higher level.
|
||||
* This is used in phase stability boundary calculations
|
||||
* VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
|
||||
* VCS_PHASE_EXIST_MINORCONC = 1: Exists, but the concentration is so low that an alternate
|
||||
* VCS_PHASE_EXIST_MINORCONC = 1: Exists, but the concentration is
|
||||
* so low that an alternate
|
||||
* method is used to calculate the total phase concentrations.
|
||||
* VCS_PHASE_EXIST_YES = 2 : Does exist currently
|
||||
* VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it contains
|
||||
* inerts which can't exist in any other
|
||||
* phase
|
||||
* inerts which can't exist in any other phase. Or,
|
||||
* the phase exists always because it consists of a single
|
||||
* species, which is identified with the voltage, i.e.,
|
||||
* its an electron metal phase.
|
||||
*/
|
||||
int m_existence;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue