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 {
119 const vector<double>& e);
123 return m_exchangeCurrentDensityFormulation;
133 void setSpecies(
const vector<string>& species);
163 double correction = 1.;
174 if (m_exchangeCurrentDensityFormulation) {
235 bool m_exchangeCurrentDensityFormulation;
363 template <
class RateType,
class DataType>
370 using RateType::RateType;
374 setParameters(node, rate_units);
377 setParameters(node, {});
380 unique_ptr<MultiRateBase> newMultiRate()
const override {
381 return make_unique<MultiRate<InterfaceRate<RateType, DataType>, DataType>>();
385 const string type()
const override {
386 return "interface-" + RateType::type();
389 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
391 RateType::setParameters(node, rate_units);
394 void getParameters(AnyMap& node)
const override {
395 RateType::getParameters(node);
396 node[
"type"] =
type();
400 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
401 RateType::setContext(rxn, kin);
408 if constexpr (has_update<RateType>::value) {
409 RateType::updateFromStruct(shared_data);
417 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
432 double preExponentialFactor()
const override {
433 return RateType::preExponentialFactor() *
437 double activationEnergy()
const override {
442 const vector<double>& e)
override
445 RateType::setCompositionDependence(
true);
460 template <
class RateType,
class DataType>
467 using RateType::RateType;
471 setParameters(node, rate_units);
474 setParameters(node, {});
477 unique_ptr<MultiRateBase> newMultiRate()
const override {
478 return make_unique<MultiRate<StickingRate<RateType, DataType>, DataType>>();
482 const string type()
const override {
483 return "sticking-" + RateType::type();
486 void setRateUnits(
const UnitStack& rate_units)
override {
488 RateType::m_conversion_units =
Units(1.0);
491 void setParameters(
const AnyMap& node,
const UnitStack& rate_units)
override {
493 setRateUnits(rate_units);
494 RateType::m_negativeA_ok = node.getBool(
"negative-A",
false);
496 if (!node.hasKey(
"sticking-coefficient")) {
497 RateType::setRateParameters(AnyValue(), node.units(), rate_units);
500 RateType::setRateParameters(
501 node[
"sticking-coefficient"], node.units(), rate_units);
504 void getParameters(AnyMap& node)
const override {
505 node[
"type"] =
type();
506 if (RateType::m_negativeA_ok) {
507 node[
"negative-A"] =
true;
510 RateType::getRateParameters(rateNode);
512 if (!rateNode.empty()) {
514 node[
"sticking-coefficient"] = std::move(rateNode);
519 void setContext(
const Reaction& rxn,
const Kinetics& kin)
override {
520 RateType::setContext(rxn, kin);
525 void validate(
const string &equation,
const Kinetics& kin)
override {
526 RateType::validate(equation, kin);
527 fmt::memory_buffer err_reactions;
528 double T[] = {200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
529 for (
size_t i=0; i < 6; i++) {
530 double k = RateType::evalRate(log(T[i]), 1 / T[i]);
532 fmt_append(err_reactions,
"at T = {:.1f}\n", T[i]);
535 if (err_reactions.size()) {
537 "\nSticking coefficient is greater than 1 for reaction '{}'\n{}",
538 equation, to_string(err_reactions));
545 if constexpr (has_update<RateType>::value) {
546 RateType::updateFromStruct(shared_data);
555 double out = RateType::evalRate(shared_data.logT, shared_data.recipT) *
563 out /= 1 - 0.5 * out;
575 double preExponentialFactor()
const override {
576 return RateType::preExponentialFactor() *
580 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,...
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)
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
bool ready
boolean indicating whether vectors are accessible
virtual void update(double T)
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.
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...