9#ifndef CT_INTERFACERATE_H
10#define CT_INTERFACERATE_H
33 void update(
double T)
override;
34 void update(
double T, span<const double> values)
override;
36 virtual void perturbTemperature(
double deltaT);
106 span<const double> e);
110 return m_exchangeCurrentDensityFormulation;
150 double correction = 1.;
161 if (m_exchangeCurrentDensityFormulation) {
222 bool m_exchangeCurrentDensityFormulation;
350template <
class RateType,
class DataType>
357 using RateType::RateType;
361 setParameters(node, rate_units);
364 setParameters(node, {});
367 unique_ptr<MultiRateBase> newMultiRate()
const override {
368 return make_unique<MultiRate<InterfaceRate<RateType, DataType>, DataType>>();
372 const string type()
const override {
373 return "interface-" + RateType::type();
376 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
378 RateType::setParameters(node, rate_units);
381 void getParameters(AnyMap& node)
const override {
382 RateType::getParameters(node);
383 node[
"type"] =
type();
387 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
388 RateType::setContext(rxn, kin);
395 if constexpr (has_update<RateType>::value) {
396 RateType::updateFromStruct(shared_data);
404 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
419 double preExponentialFactor()
const override {
420 return RateType::preExponentialFactor() *
424 double activationEnergy()
const override {
429 span<const double> e)
override
432 RateType::setCompositionDependence(
true);
447template <
class RateType,
class DataType>
454 using RateType::RateType;
458 setParameters(node, rate_units);
461 setParameters(node, {});
464 unique_ptr<MultiRateBase> newMultiRate()
const override {
465 return make_unique<MultiRate<StickingRate<RateType, DataType>, DataType>>();
469 const string type()
const override {
470 return "sticking-" + RateType::type();
473 void setRateUnits(
const UnitStack& rate_units)
override {
475 RateType::m_conversion_units =
Units(1.0);
478 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
480 setRateUnits(rate_units);
481 RateType::m_negativeA_ok = node.getBool(
"negative-A",
false);
483 if (!node.hasKey(
"sticking-coefficient")) {
484 RateType::setRateParameters(AnyValue(), node.units(), rate_units);
487 RateType::setRateParameters(
488 node[
"sticking-coefficient"], node.units(), rate_units);
491 void getParameters(AnyMap& node)
const override {
492 node[
"type"] =
type();
493 if (RateType::m_negativeA_ok) {
494 node[
"negative-A"] =
true;
497 RateType::getRateParameters(rateNode);
499 if (!rateNode.empty()) {
501 node[
"sticking-coefficient"] = std::move(rateNode);
506 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
507 RateType::setContext(rxn, kin);
512 void validate(
const string &equation,
const Kinetics& kin)
override {
513 RateType::validate(equation, kin);
514 fmt::memory_buffer err_reactions;
515 double T[] = {200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
516 for (
size_t i=0; i < 6; i++) {
517 double k = RateType::evalRate(log(T[i]), 1 / T[i]);
519 fmt_append(err_reactions,
"at T = {:.1f}\n", T[i]);
522 if (err_reactions.size()) {
524 "\nSticking coefficient is greater than 1 for reaction '{}'\n{}",
525 equation, to_string(err_reactions));
532 if constexpr (has_update<RateType>::value) {
533 RateType::updateFromStruct(shared_data);
542 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
550 out /= 1 - 0.5 * out;
562 double preExponentialFactor()
const override {
563 return RateType::preExponentialFactor() *
567 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 setSpecies(span< const string > species)
Set association with an ordered list of all species associated with a given Kinetics object.
void setParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
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.
void getCoverageDependencies(AnyMap &dependencies) const
Store parameters needed to reconstruct coverage dependencies.
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].
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)
virtual void addCoverageDependence(const string &sp, double a, double m, span< const double > e)
Add a coverage dependency for species sp, with exponential dependence a, power-law exponent m,...
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, span< const 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.
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.
void update(double T) override
Update data container based on temperature T
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.
vector< double > coverages
surface coverages
vector< double > standardChemPotentials
standard state chemical potentials
vector< double > standardConcentrations
standard state concentrations
void resize(Kinetics &kin) override
Update array sizes that depend on number of species, reactions and phases.
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...