Fixed a bug in the equilibrium solver

Potentials of electron phases were being altered when they shouldn't have been.
This commit is contained in:
Harry Moffat 2013-03-23 01:06:36 +00:00
parent b82df1b1ea
commit 3c08cba848
2 changed files with 24 additions and 16 deletions

View file

@ -181,11 +181,10 @@ namespace VCSnonideal
*/
#define VCS_SPECIES_DELETED -4
//! Species refers to an electron in the metal
//! Species refers to an electron in the metal.
/*!
* The unknown is equal to the interfacial voltage
* drop across the interface on the SHE (standard
* hydrogen electrode) scale (volts).
* The unknown is equal to the electric potential of the phase
* in which it exists.
*/
#define VCS_SPECIES_INTERFACIALVOLTAGE -5
@ -363,7 +362,8 @@ namespace VCSnonideal
/*!
* Typically, these species are electrons in metals. There is an
* infinite supply of them. However, their electrical potential
* is defined by the interface voltage.
* is sometimes allowed to vary, for example if the open circuit voltage
* is sought after.
*/
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE -5
//@}

View file

@ -1099,24 +1099,32 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
*/
string stmp = mphase->speciesName(kT);
vprob->SpName[kT] = stmp;
/*
* Set the initial estimate of the number of kmoles of the species
* and the mole fraction vector. translate from
* kmol to gmol.
* Transfer the type of unknown
*/
vprob->w[kT] = mphase->speciesMoles(kT);
tMoles += vprob->w[kT];
vprob->mf[kT] = mphase->moleFraction(kT);
vprob->SpeciesUnknownType[kT] = VolPhase->speciesUnknownType(k);
if (vprob->SpeciesUnknownType[kT] == VCS_SPECIES_TYPE_MOLNUM) {
/*
* Set the initial number of kmoles of the species
* and the mole fraction vector
*/
vprob->w[kT] = mphase->speciesMoles(kT);
tMoles += vprob->w[kT];
vprob->mf[kT] = mphase->moleFraction(kT);
} else if (vprob->SpeciesUnknownType[kT] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
vprob->w[kT] = tPhase->electricPotential();
vprob->mf[kT] = mphase->moleFraction(kT);
} else {
throw CanteraError(" vcs_Cantera_to_vprob() ERROR",
"Unknown species type: " + int2str(vprob->SpeciesUnknownType[kT]));
}
/*
* transfer chemical potential vector
*/
vprob->m_gibbsSpecies[kT] = muPhase[k];
/*
* Transfer the type of unknown
*/
vprob->SpeciesUnknownType[kT] = VolPhase->speciesUnknownType(k);
/*
* Transfer the species information from the
* volPhase structure to the VPROB structure