[Thermo] Make species size local to SurfPhase

This commit is contained in:
Ray Speth 2017-08-23 14:38:59 -04:00
parent 7d0bc71448
commit 1b97c49d8d
10 changed files with 23 additions and 52 deletions

View file

@ -91,11 +91,6 @@ class PDSS_Water;
* standard state Gibbs free energy is obtained from the enthalpy and entropy
* functions.
*
* The vector Phase::m_speciesSize[] is used to hold the base values of species
* sizes. These are defined as the molar volumes of species at infinite dilution
* at 300 K and 1 atm of water. m_speciesSize are calculated during the
* initialization of the DebyeHuckel object and are then not touched.
*
* The current model assumes that an incompressible molar volume for all
* solutes. The molar volume for the water solvent, however, is obtained from a
* pure water equation of state, waterSS. Therefore, the water standard state

View file

@ -118,11 +118,6 @@ class WaterProps;
* pressure. The solute standard state Gibbs free energy is obtained from the
* enthalpy and entropy functions.
*
* The vector Phase::m_speciesSize[] is used to hold the base values of species
* sizes. These are defined as the molar volumes of species at infinite dilution
* at 300 K and 1 atm of water. m_speciesSize are calculated during the
* initialization of the HMWSoln object and are then not touched.
*
* The current model assumes that an incompressible molar volume for all
* solutes. The molar volume for the water solvent, however, is obtained from a
* pure water equation of state, waterSS. Therefore, the water standard state

View file

@ -406,17 +406,13 @@ public:
//! units = kg / kmol
const vector_fp& molecularWeights() const;
//! This routine returns the size of species k
//!
//! The meaning and dimensions are model-dependent. For surface phases, the
//! size is the number of sites occupied by one molecule of the species
//! [nondimensional]. For models which utilize the species partial molar
//! volumes, this is the molar volume of the species in its reference state.
//! For other models, this value may have no meaning.
//! @param k index of the species
//! @return The size of the species
doublereal size(size_t k) const {
return m_speciesSize[k];
//! @deprecated To be removed after Cantera 2.4
//! @see SurfPhase::size
virtual double size(size_t k) const {
warn_deprecated("Phase::size", "Unused except for SurfPhase. "
"To be removed from class Phase after Cantera 2.4. "
"Cast object as SurfPhase to resolve this warning.");
return 1.0;
}
/// @name Composition
@ -796,11 +792,6 @@ protected:
//! The length of this vector is equal to m_kk * m_mm
vector_fp m_speciesComp;
//!Vector of species sizes. length m_kk. Used in some equations of state
//! which employ the constant partial molar volume approximation, and for
//! surface phases.
vector_fp m_speciesSize;
vector_fp m_speciesCharge; //!< Vector of species charges. length m_kk.
std::map<std::string, shared_ptr<Species> > m_species;

View file

@ -313,6 +313,11 @@ public:
return m_n0;
}
//! Returns the number of sites occupied by one molecule of species *k*.
virtual double size(size_t k) const {
return m_speciesSize[k];
}
//! Set the site density of the surface phase (kmol m-2)
/*!
* @param n0 Site density of the surface phase (kmol m-2)
@ -393,6 +398,9 @@ protected:
//! Surface site density (kmol m-2)
doublereal m_n0;
//! Vector of species sizes (number of sites occupied). length m_kk.
vector_fp m_speciesSize;
//! log of the surface site density
doublereal m_logn0;

View file

@ -663,7 +663,6 @@ SurfaceArrhenius InterfaceKinetics::buildSurfaceArrhenius(
for (const auto& sp : r.reactants) {
size_t iPhase = speciesPhaseIndex(kineticsSpeciesIndex(sp.first));
const ThermoPhase& p = thermo(iPhase);
const ThermoPhase& surf = thermo(surfacePhaseIndex());
size_t k = p.speciesIndex(sp.first);
if (sp.first == sticking_species) {
multiplier *= sqrt(GasConstant/(2*Pi*p.molecularWeight(k)));
@ -675,8 +674,8 @@ SurfaceArrhenius InterfaceKinetics::buildSurfaceArrhenius(
// rate constant is evaluated, since we don't assume that the
// site density is known at this time.
double order = getValue(r.orders, sp.first, sp.second);
if (&p == &surf) {
multiplier *= pow(p.size(k), order);
if (&p == m_surf) {
multiplier *= pow(m_surf->size(k), order);
surface_order += order;
} else {
multiplier *= pow(p.standardConcentration(k), -order);
@ -891,8 +890,7 @@ void InterfaceKinetics::applyStickingCorrection(double T, double* kf)
CachedArray cached = m_cache.getArray(cacheId);
vector_fp& factors = cached.value;
SurfPhase& surf = dynamic_cast<SurfPhase&>(thermo(reactionPhaseIndex()));
double n0 = surf.siteDensity();
double n0 = m_surf->siteDensity();
if (!cached.validate(n0)) {
factors.resize(m_stickingData.size());
for (size_t n = 0; n < m_stickingData.size(); n++) {

View file

@ -146,7 +146,7 @@ void DebyeHuckel::getActivityConcentrations(doublereal* c) const
doublereal DebyeHuckel::standardConcentration(size_t k) const
{
double mvSolvent = m_speciesSize[0];
double mvSolvent = providePDSS(0)->molarVolume();
return 1.0 / mvSolvent;
}
@ -560,29 +560,19 @@ void DebyeHuckel::initThermo()
// Solvent
m_waterSS = dynamic_cast<PDSS_Water*>(providePDSS(0));
if (m_waterSS) {
m_waterSS->setState_TP(300., OneAtm);
double dens = m_waterSS->density();
double mw = m_waterSS->molecularWeight();
m_speciesSize[0] = mw / dens;
// Initialize the water property calculator. It will share the internal
// eos water calculator.
if (m_form_A_Debye == A_DEBYE_WATER) {
m_waterProps.reset(new WaterProps(m_waterSS));
}
} else if (dynamic_cast<PDSS_ConstVol*>(providePDSS(0))) {
m_speciesSize[0] = providePDSS(0)->molarVolume();
} else {
} else if (dynamic_cast<PDSS_ConstVol*>(providePDSS(0)) == 0) {
throw CanteraError("DebyeHuckel::initThermo", "Solvent standard state"
" model must be WaterIAPWS or constant_incompressible.");
}
// Solutes
for (size_t k = 1; k < nSpecies(); k++) {
PDSS_ConstVol* ss = dynamic_cast<PDSS_ConstVol*>(providePDSS(k));
if (ss) {
m_speciesSize[k] = ss->molarVolume();
} else {
if (dynamic_cast<PDSS_ConstVol*>(providePDSS(k)) == 0) {
throw CanteraError("DebyeHuckel::initThermo", "Solute standard"
" state model must be constant_incompressible.");
}
@ -700,7 +690,6 @@ bool DebyeHuckel::addSpecies(shared_ptr<Species> spec)
{
bool added = MolalityVPSSTP::addSpecies(spec);
if (added) {
m_speciesSize.push_back(0.0);
m_lnActCoeffMolal.push_back(0.0);
m_dlnActCoeffMolaldT.push_back(0.0);
m_d2lnActCoeffMolaldT2.push_back(0.0);

View file

@ -666,9 +666,6 @@ void HMWSoln::initThermo()
elambda[i] = 0.0;
elambda1[i] = 0.0;
}
for (size_t k = 0; k < nSpecies(); k++) {
m_speciesSize[k] = providePDSS(k)->molarVolume();
}
// Store a local pointer to the water standard state model.
m_waterSS = providePDSS(0);
@ -997,7 +994,6 @@ double HMWSoln::d2A_DebyedT2_TP(double tempArg, double presArg) const
void HMWSoln::initLengths()
{
m_speciesSize.resize(m_kk);
m_tmpV.resize(m_kk, 0.0);
m_molalitiesCropped.resize(m_kk, 0.0);

View file

@ -159,7 +159,6 @@ void MineralEQ3::initThermoXML(XML_Node& phaseNode, const std::string& id_)
volVal = getFloat(*aStandardState, "V0_Pr_Tr");
m_V0_pr_tr= volVal;
volVal *= Afactor;
m_speciesSize[0] = volVal;
} else {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");

View file

@ -728,7 +728,6 @@ bool Phase::addSpecies(shared_ptr<Species> spec) {
m_species[ba::to_lower_copy(spec->name)] = spec;
m_speciesIndices[ba::to_lower_copy(spec->name)] = m_kk;
m_speciesCharge.push_back(spec->charge);
m_speciesSize.push_back(spec->size);
size_t ne = nElements();
double wt = 0.0;

View file

@ -213,7 +213,8 @@ bool SurfPhase::addSpecies(shared_ptr<Species> spec)
m_cp0.push_back(0.0);
m_mu0.push_back(0.0);
m_work.push_back(0.0);
m_logsize.push_back(log(size(m_kk-1)));
m_speciesSize.push_back(spec->size);
m_logsize.push_back(log(spec->size));
if (m_kk == 1) {
vector_fp cov{1.0};
setCoverages(cov.data());