Skip to content

Commit

Permalink
Make minor changes in InterfaceRate.cpp and .h
Browse files Browse the repository at this point in the history
  • Loading branch information
jongyoonbae authored and speth committed Jun 15, 2023
1 parent deb9bf8 commit 47cdc22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions include/cantera/kinetics/InterfaceRate.h
Expand Up @@ -88,7 +88,7 @@ struct InterfaceData : public BlowersMaselData
* dependence on the activation energy modifier \f$ E_k \f$, polynomial coverage
* dependence is also available. When the dependence parameter \f$ E_k \f$ is given as
* a scalar value, the linear dependency is applied whereas if a list of four values
* are given as \f$ [E^{(1)}_k-E^{(4)}_k] \f$, a polynomial dependency is applied as
* are given as \f$ [E^{(1)}_k, ..., E^{(4)}_k] \f$, a polynomial dependency is applied as
* \f[
* k_f = A T^b \exp \left( - \frac{E_a}{RT} \right)
* \prod_k 10^{a_k \theta_k} \theta_k^{m_k}
Expand Down Expand Up @@ -127,7 +127,7 @@ class InterfaceRateBase
//! Add a coverage dependency for species *sp*, with exponential dependence
//! *a*, power-law exponent *m*, and activation energy dependence *e*,
//! where *e* is in Kelvin, that is, energy divided by the molar gas constant.
virtual void addCoverageDependence(const string& sp, double a, double m, vector_fp e);
virtual void addCoverageDependence(const string& sp, double a, double m, const vector_fp& e);

//! Boolean indicating whether rate uses exchange current density formulation
bool exchangeCurrentDensityFormulation() {
Expand Down Expand Up @@ -449,7 +449,7 @@ class InterfaceRate : public RateType, public InterfaceRateBase
return RateType::activationEnergy() + m_ecov * GasConstant;
}

void addCoverageDependence(const string& sp, double a, double m, vector_fp e) override {
void addCoverageDependence(const string& sp, double a, double m, const vector_fp& e) override {
InterfaceRateBase::addCoverageDependence(sp, a, m, e);
RateType::setCompositionDependence(true);
}
Expand Down
13 changes: 9 additions & 4 deletions src/kinetics/InterfaceRate.cpp
Expand Up @@ -154,7 +154,7 @@ void InterfaceRateBase::setCoverageDependencies(const AnyMap& dependencies,
E[1] = units.convertActivationEnergy(cov_map["E"], "K");
} else {
m_lindep.push_back(false);
auto& E_temp = cov_map["E"].asVector<AnyValue>(4);
auto& E_temp = cov_map["E"].asVector<AnyValue>(1, 4);
for (size_t i = 0; i < E_temp.size(); i++) {
E[i+1] = units.convertActivationEnergy(E_temp[i], "K");
}
Expand All @@ -168,7 +168,7 @@ void InterfaceRateBase::setCoverageDependencies(const AnyMap& dependencies,
E[1] = units.convertActivationEnergy(cov_vec[2], "K");
} else {
m_lindep.push_back(false);
auto& E_temp = cov_vec[2].asVector<AnyValue>(4);
auto& E_temp = cov_vec[2].asVector<AnyValue>(1, 4);
for (size_t i = 0; i < E_temp.size(); i++) {
E[i+1] = units.convertActivationEnergy(E_temp[i], "K");
}
Expand Down Expand Up @@ -219,7 +219,8 @@ void InterfaceRateBase::getCoverageDependencies(AnyMap& dependencies,
}

void InterfaceRateBase::addCoverageDependence(const std::string& sp,
double a, double m, vector_fp e)
double a, double m,
const vector_fp& e)
{
if (std::find(m_cov.begin(), m_cov.end(), sp) == m_cov.end()) {
m_cov.push_back(sp);
Expand Down Expand Up @@ -264,7 +265,11 @@ void InterfaceRateBase::updateFromStruct(const InterfaceData& shared_data) {
m_mcov = 0.0;
for (auto& [iCov, iKin] : m_indices) {
m_acov += m_ac[iCov] * shared_data.coverages[iKin];
m_ecov += poly4(shared_data.coverages[iKin], m_ec[iCov].data());
if (m_lindep[iCov]) {
m_ecov += m_ec[iCov][1] * shared_data.coverages[iKin];
} else {
m_ecov += poly4(shared_data.coverages[iKin], m_ec[iCov].data());
}
m_mcov += m_mc[iCov] * shared_data.logCoverages[iKin];
}

Expand Down

0 comments on commit 47cdc22

Please sign in to comment.