diff --git a/include/cantera/equil/vcs_defs.h b/include/cantera/equil/vcs_defs.h index 74c00e148..433b30867 100644 --- a/include/cantera/equil/vcs_defs.h +++ b/include/cantera/equil/vcs_defs.h @@ -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 //@} diff --git a/src/equil/vcs_MultiPhaseEquil.cpp b/src/equil/vcs_MultiPhaseEquil.cpp index 7cbe3018d..9ade0aece 100644 --- a/src/equil/vcs_MultiPhaseEquil.cpp +++ b/src/equil/vcs_MultiPhaseEquil.cpp @@ -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