diff --git a/include/cantera/thermo/SurfPhase.h b/include/cantera/thermo/SurfPhase.h index de6663503..7239a8fde 100644 --- a/include/cantera/thermo/SurfPhase.h +++ b/include/cantera/thermo/SurfPhase.h @@ -551,6 +551,9 @@ public: */ void setCoveragesByName(const std::string& cov); + //! Set the coverages from a map of name:value pairs + void setCoveragesByName(const compositionMap& cov); + //! Return a vector of surface coverages /*! * Get the coverages. diff --git a/src/thermo/SurfPhase.cpp b/src/thermo/SurfPhase.cpp index 26b404c78..6332e7358 100644 --- a/src/thermo/SurfPhase.cpp +++ b/src/thermo/SurfPhase.cpp @@ -327,11 +327,15 @@ void SurfPhase::getCoverages(doublereal* theta) const void SurfPhase::setCoveragesByName(const std::string& cov) { - compositionMap cc = parseCompString(cov, speciesNames()); + setCoveragesByName(parseCompString(cov, speciesNames())); +} + +void SurfPhase::setCoveragesByName(const compositionMap& cov) +{ vector_fp cv(m_kk, 0.0); bool ifound = false; for (size_t k = 0; k < m_kk; k++) { - double c = cc[speciesName(k)]; + double c = getValue(cov, speciesName(k), 0.0); if (c > 0.0) { ifound = true; cv[k] = c;