9#ifndef CT_INTERFACERATE_H
10#define CT_INTERFACERATE_H
35 void update(
double T)
override;
37 void update(
double T,
const vector<double>& values)
override;
41 virtual void perturbTemperature(
double deltaT);
43 void resize(
size_t nSpecies,
size_t nReactions,
size_t nPhases)
override {
121 const vector<double>& e);
125 return m_exchangeCurrentDensityFormulation;
135 void setSpecies(
const vector<string>& species);
165 double correction = 1.;
176 if (m_exchangeCurrentDensityFormulation) {
237 bool m_exchangeCurrentDensityFormulation;
365template <
class RateType,
class DataType>
372 using RateType::RateType;
376 setParameters(node, rate_units);
379 setParameters(node, {});
382 unique_ptr<MultiRateBase> newMultiRate()
const override {
383 return make_unique<MultiRate<InterfaceRate<RateType, DataType>, DataType>>();
387 const string type()
const override {
388 return "interface-" + RateType::type();
391 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
393 RateType::setParameters(node, rate_units);
396 void getParameters(AnyMap& node)
const override {
397 RateType::getParameters(node);
398 node[
"type"] =
type();
402 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
403 RateType::setContext(rxn, kin);
410 if constexpr (has_update<RateType>::value) {
411 RateType::updateFromStruct(shared_data);
419 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
434 double preExponentialFactor()
const override {
435 return RateType::preExponentialFactor() *
439 double activationEnergy()
const override {
444 const vector<double>& e)
override
447 RateType::setCompositionDependence(
true);
462template <
class RateType,
class DataType>
469 using RateType::RateType;
473 setParameters(node, rate_units);
476 setParameters(node, {});
479 unique_ptr<MultiRateBase> newMultiRate()
const override {
480 return make_unique<MultiRate<StickingRate<RateType, DataType>, DataType>>();
484 const string type()
const override {
485 return "sticking-" + RateType::type();
488 void setRateUnits(
const UnitStack& rate_units)
override {
490 RateType::m_conversion_units =
Units(1.0);
493 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
495 setRateUnits(rate_units);
496 RateType::m_negativeA_ok = node.getBool(
"negative-A",
false);
498 if (!node.hasKey(
"sticking-coefficient")) {
499 RateType::setRateParameters(AnyValue(), node.units(), rate_units);
502 RateType::setRateParameters(
503 node[
"sticking-coefficient"], node.units(), rate_units);
506 void getParameters(AnyMap& node)
const override {
507 node[
"type"] =
type();
508 if (RateType::m_negativeA_ok) {
509 node[
"negative-A"] =
true;
512 RateType::getRateParameters(rateNode);
514 if (!rateNode.empty()) {
516 node[
"sticking-coefficient"] = std::move(rateNode);
521 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
522 RateType::setContext(rxn, kin);
527 void validate(
const string &equation,
const Kinetics& kin)
override {
528 RateType::validate(equation, kin);
529 fmt::memory_buffer err_reactions;
530 double T[] = {200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
531 for (
size_t i=0; i < 6; i++) {
532 double k = RateType::evalRate(log(T[i]), 1 / T[i]);
534 fmt_append(err_reactions,
"at T = {:.1f}\n", T[i]);
537 if (err_reactions.size()) {
539 "\nSticking coefficient is greater than 1 for reaction '{}'\n{}",
540 equation, to_string(err_reactions));
547 if constexpr (has_update<RateType>::value) {
548 RateType::updateFromStruct(shared_data);
557 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
565 out /= 1 - 0.5 * out;
577 double preExponentialFactor()
const override {
578 return RateType::preExponentialFactor() *
582 double activationEnergy()
const override {
Header for Blowers-Masel reaction rates.
A map of string keys to values whose type can vary at runtime.
Base class for rate parameterizations that involve interfaces.
double m_mcov
Coverage term in reaction rate.
void setCoverageDependencies(const AnyMap &dependencies, const UnitSystem &units=UnitSystem())
Set coverage dependencies based on AnyMap node information.
double m_beta
Electrochemistry only.
double m_ecov
Coverage contribution to activation energy.
vector< pair< size_t, double > > m_stoichCoeffs
Pairs of species index and multipliers to calculate enthalpy change.
vector< double > m_ac
Vector holding coverage-specific exponential dependence.
void setParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
void setSpecies(const vector< string > &species)
Set association with an ordered list of all species associated with a given Kinetics object.
vector< string > m_cov
Vector holding names of coverage species.
double m_prodStandardConcentrations
Products of standard concentrations.
double m_deltaGibbs0_RT
Normalized standard state Gibbs free energy change.
virtual void addCoverageDependence(const string &sp, double a, double m, const vector< double > &e)
Add a coverage dependency for species sp, with exponential dependence a, power-law exponent m,...
double beta() const
Return the charge transfer beta parameter.
bool exchangeCurrentDensityFormulation()
Boolean indicating whether rate uses exchange current density formulation.
bool usesElectrochemistry()
Boolean indicating whether rate uses electrochemistry.
bool m_chargeTransfer
Boolean indicating use of electrochemistry.
double siteDensity() const
Return site density [kmol/m^2].
void getCoverageDependencies(AnyMap &dependencies, bool asVector=false) const
Store parameters needed to reconstruct coverage dependencies.
vector< double > m_mc
Vector holding coverage-specific power-law exponents.
map< size_t, size_t > m_indices
Map from coverage dependencies stored in this object to the index of the coverage species in the Kine...
vector< pair< size_t, double > > m_netCharges
Pairs of phase index and net electric charges (same order as m_stoichCoeffs)
double m_acov
Coverage contribution to pre-exponential factor.
vector< bool > m_lindep
Vector holding boolean for linear dependence.
void getParameters(AnyMap &node) const
Store parameters needed to reconstruct an identical object.
vector< vector< double > > m_ec
Vector holding coverage-specific activation energy dependence as a 5-membered array of polynomial coe...
double m_siteDensity
Site density [kmol/m^2].
void setContext(const Reaction &rxn, const Kinetics &kin)
Build rate-specific parameters based on Reaction and Kinetics context.
double voltageCorrection() const
Calculate modifications for the forward reaction rate for interfacial charge transfer reactions.
void updateFromStruct(const InterfaceData &shared_data)
Update reaction rate parameters.
void setSiteDensity(double siteDensity)
Set site density [kmol/m^2].
double m_deltaPotential_RT
Normalized electric potential energy change.
A class template for interface reaction rate specifications.
double ddTScaledFromStruct(const DataType &shared_data) const
Evaluate derivative of reaction rate with respect to temperature divided by reaction rate.
InterfaceRate(const AnyMap &node, const UnitStack &rate_units)
Constructor based on AnyMap content.
void updateFromStruct(const DataType &shared_data)
Update reaction rate parameters.
void addCoverageDependence(const string &sp, double a, double m, const vector< double > &e) override
Add a coverage dependency for species sp, with exponential dependence a, power-law exponent m,...
const string type() const override
Identifier of reaction rate type.
double evalFromStruct(const DataType &shared_data) const
Evaluate reaction rate.
Public interface for kinetics managers.
An error indicating that an unimplemented function has been called.
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Base class for rate parameterizations that implement sticking coefficients.
void setStickingParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
bool m_explicitSpecies
Boolean flag.
void setStickingWeight(double weight)
Set the molecular weight of the sticking species.
double m_factor
cached factor
string m_stickingSpecies
string identifying sticking species
void setStickingOrder(double order)
Set exponent applied to site density (sticking order)
bool m_explicitMotzWise
Correction cannot be overriden by default.
void setMotzWiseCorrection(bool motz_wise)
Set flag for Motz & Wise correction factor.
void getStickingParameters(AnyMap &node) const
Store parameters needed to reconstruct an identical object.
string stickingSpecies() const
Get sticking species.
double m_multiplier
multiplicative factor in rate expression
bool m_motzWise
boolean indicating whether Motz & Wise correction is used
double m_surfaceOrder
exponent applied to site density term
void setContext(const Reaction &rxn, const Kinetics &kin)
Build rate-specific parameters based on Reaction and Kinetics context.
double stickingWeight()
Get the molecular weight of the sticking species.
bool motzWiseCorrection() const
Get flag indicating whether sticking rate uses the correction factor developed by Motz & Wise for rea...
void setStickingSpecies(const string &stickingSpecies)
Set sticking species.
double stickingOrder()
Get exponent applied to site density (sticking order)
A class template for interface sticking rate specifications.
double ddTScaledFromStruct(const DataType &shared_data) const
Evaluate derivative of reaction rate with respect to temperature divided by reaction rate.
StickingRate(const AnyMap &node, const UnitStack &rate_units)
Constructor based on AnyMap content.
void updateFromStruct(const DataType &shared_data)
Update reaction rate parameters.
const string type() const override
Identifier of reaction rate type.
double evalFromStruct(const DataType &shared_data) const
Evaluate reaction rate.
Base class for a phase with thermodynamic properties.
A representation of the units associated with a dimensional quantity.
void fmt_append(fmt::memory_buffer &b, Args... args)
Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they include windows....
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double Faraday
Faraday constant [C/kmol].
const double GasConstant
Universal Gas Constant [J/kmol/K].
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
Data container holding shared data specific to BlowersMaselRate.
vector< double > partialMolarEnthalpies
partial molar enthalpies
void update(double T) override
Update data container based on temperature T
bool ready
boolean indicating whether vectors are accessible
Data container holding shared data for reaction rate specification with interfaces.
vector< double > logCoverages
logarithm of surface coverages
vector< double > electricPotentials
electric potentials of phases
bool update(const ThermoPhase &bulk, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
void resize(size_t nSpecies, size_t nReactions, size_t nPhases) override
Update number of species, reactions and phases.
vector< double > coverages
surface coverages
vector< double > standardChemPotentials
standard state chemical potentials
vector< double > standardConcentrations
standard state concentrations
double sqrtT
square root of temperature
Unit aggregation utility.
#define CT_DEFINE_HAS_MEMBER(detector_name, func_name)
A macro for generating member function detectors, which can then be used in combination with if const...