9#ifndef CT_INTERFACERATE_H
10#define CT_INTERFACERATE_H
45 virtual void update(
double T)
override;
51 virtual void perturbTemperature(
double deltaT);
53 virtual void resize(
size_t nSpecies,
size_t nReactions,
size_t nPhases)
override {
123 return m_exchangeCurrentDensityFormulation;
133 void setSpecies(
const std::vector<std::string>& species);
163 double correction = 1.;
174 if (m_exchangeCurrentDensityFormulation) {
233 bool m_exchangeCurrentDensityFormulation;
352template <
class RateType,
class DataType>
359 using RateType::RateType;
363 setParameters(node, rate_units);
366 setParameters(node, {});
369 unique_ptr<MultiRateBase> newMultiRate()
const override {
370 return unique_ptr<MultiRateBase>(
371 new MultiRate<InterfaceRate<RateType, DataType>, DataType>);
375 virtual const std::string
type()
const override {
376 return "interface-" + RateType::type();
379 virtual void setParameters(
383 RateType::setParameters(node, rate_units);
386 virtual void getParameters(AnyMap& node)
const override {
387 RateType::getParameters(node);
388 node[
"type"] =
type();
392 virtual void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
393 RateType::setContext(rxn, kin);
407 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
422 virtual double preExponentialFactor()
const override {
423 return RateType::preExponentialFactor() *
427 virtual double activationEnergy()
const override {
434 template <
typename T=RateType,
435 typename std::enable_if<has_update<T>::value,
bool>
::type =
true>
437 T::updateFromStruct(shared_data);
442 template <
typename T=RateType,
443 typename std::enable_if<!has_update<T>::value,
bool>
::type =
true>
448using InterfaceArrheniusRate = InterfaceRate<ArrheniusRate, InterfaceData>;
449using InterfaceBlowersMaselRate = InterfaceRate<BlowersMaselRate, InterfaceData>;
453template <
class RateType,
class DataType>
460 using RateType::RateType;
465 setParameters(node,
Units(1.0));
469 setParameters(node,
Units(1.0));
472 unique_ptr<MultiRateBase> newMultiRate()
const override {
473 return unique_ptr<MultiRateBase>(
474 new MultiRate<StickingRate<RateType, DataType>, DataType>);
478 virtual const std::string
type()
const override {
479 return "sticking-" + RateType::type();
482 virtual void setParameters(
486 RateType::m_negativeA_ok = node.
getBool(
"negative-A",
false);
488 if (!node.
hasKey(
"sticking-coefficient")) {
489 RateType::setRateParameters(
AnyValue(), node.
units(), rate_units);
492 RateType::setRateParameters(
493 node[
"sticking-coefficient"], node.
units(), rate_units);
496 virtual void getParameters(AnyMap& node)
const override {
497 node[
"type"] =
type();
498 if (RateType::m_negativeA_ok) {
499 node[
"negative-A"] =
true;
502 RateType::getRateParameters(rateNode);
504 if (!rateNode.empty()) {
506 node[
"sticking-coefficient"] = std::move(rateNode);
511 virtual void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
512 RateType::setContext(rxn, kin);
517 virtual void validate(
const std::string &equation,
const Kinetics& kin)
override {
518 RateType::validate(equation, kin);
519 fmt::memory_buffer err_reactions;
520 double T[] = {200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
521 for (
size_t i=0; i < 6; i++) {
522 double k = RateType::evalRate(log(T[i]), 1 / T[i]);
524 fmt_append(err_reactions,
525 "\n Sticking coefficient is greater than 1 for reaction '{}'\n"
526 " at T = {:.1f}\n", equation, T[i]);
529 if (err_reactions.size()) {
530 warn_user(
"StickingRate::validate", to_string(err_reactions));
545 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
553 out /= 1 - 0.5 * out;
565 virtual double preExponentialFactor()
const override {
566 return RateType::preExponentialFactor() *
570 virtual double activationEnergy()
const override {
577 template <
typename T=RateType,
578 typename std::enable_if<has_update<T>::value,
bool>
::type =
true>
580 T::updateFromStruct(shared_data);
585 template <
typename T=RateType,
586 typename std::enable_if<!has_update<T>::value,
bool>
::type =
true>
591using StickingArrheniusRate = StickingRate<ArrheniusRate, InterfaceData>;
592using StickingBlowersMaselRate = StickingRate<BlowersMaselRate, InterfaceData>;
Header for Blowers-Masel reaction rates.
A map of string keys to values whose type can vary at runtime.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
bool getBool(const std::string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
A wrapper for a variable whose type is determined 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.
void addCoverageDependence(const std::string &sp, double a, double m, double e)
Add a coverage dependency for species sp, with exponential dependence a, power-law exponent m,...
void setParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
double m_prodStandardConcentrations
Products of standard concentrations.
std::vector< std::pair< size_t, double > > m_netCharges
Pairs of phase index and net electric charges (same order as m_stoichCoeffs)
double m_deltaGibbs0_RT
Normalized standard state Gibbs free energy change.
vector_fp m_mc
Vector holding coverage-specific power-law exponents.
std::map< size_t, size_t > m_indices
Map holding indices of coverage species.
double beta() const
Return the charge transfer beta parameter.
vector_fp m_ec
Vector holding coverage-specific activation energy dependence.
bool exchangeCurrentDensityFormulation()
Boolean indicating whether rate uses exchange current density formulation.
bool usesElectrochemistry()
Boolean indicating whether rate uses electrochemistry.
vector_fp m_ac
Vector holding coverage-specific exponential dependence.
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.
double m_acov
Coverage contribution to pre-exponential factor.
std::vector< std::pair< size_t, double > > m_stoichCoeffs
Pairs of species index and multiplers to calculate enthalpy change.
void setSpecies(const std::vector< std::string > &species)
Set association with an ordered list of all species associated with a given Kinetics object.
void getParameters(AnyMap &node) const
Store parameters needed to reconstruct an identical object.
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.
std::vector< std::string > m_cov
Vector holding names of coverage species.
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 _update(const DataType &shared_data)
Helper function to process updates for rate types that implement the updateFromStruct method.
double evalFromStruct(const DataType &shared_data) const
Evaluate reaction rate.
virtual const std::string type() const override
Identifier of reaction rate type.
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.
std::string stickingSpecies() const
Get sticking species.
void setStickingWeight(double weight)
Set the molecular weight of the sticking species.
double m_factor
cached factor
std::string m_stickingSpecies
string identifying sticking species
void setStickingSpecies(const std::string &stickingSpecies)
Set 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.
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...
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.
void _update(const DataType &shared_data)
Helper function to process updates for rate types that implement the updateFromStruct method.
double evalFromStruct(const DataType &shared_data) const
Evaluate reaction rate.
virtual const std::string type() const override
Identifier of reaction rate type.
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,...
Namespace for the Cantera kernel.
const double Faraday
Faraday constant [C/kmol].
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Data container holding shared data specific to BlowersMaselRate.
virtual void update(double T) override
Update data container based on temperature T
bool ready
boolean indicating whether vectors are accessible
vector_fp partialMolarEnthalpies
partial molar enthalpies
Data container holding shared data for reaction rate specification with interfaces.
virtual void resize(size_t nSpecies, size_t nReactions, size_t nPhases) override
Update number of species, reactions and phases.
vector_fp electricPotentials
electric potentials of phases
virtual bool update(const ThermoPhase &bulk, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
vector_fp coverages
surface coverages
vector_fp logCoverages
logarithm of surface coverages
vector_fp standardChemPotentials
standard state chemical potentials
vector_fp 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 std::ena...