16InterfaceData::InterfaceData()
21void InterfaceData::update(
double T)
24 "Missing state information: 'InterfaceData' requires species coverages.");
27void InterfaceData::update(
double T,
const vector_fp& values)
30 "This method does not update the site density.");
31 ReactionData::update(T);
33 if (coverages.size() == 0) {
35 logCoverages.resize(values.size());
36 }
else if (values.size() == coverages.size()) {
37 std::copy(values.begin(), values.end(), coverages.begin());
40 "Incompatible lengths of coverage arrays: received {} elements while "
41 "{} are required.", values.size(), coverages.size());
43 for (
size_t n = 0; n < coverages.size(); n++) {
44 logCoverages[n] = std::log(std::max(coverages[n],
Tiny));
51 for (
size_t n = 0; n < kin.
nPhases(); n++) {
57 const auto& surf =
dynamic_cast<const SurfPhase&
>(
60 if (density != site_density) {
61 density = surf.siteDensity();
64 if (T != temperature) {
65 ReactionData::update(T);
69 if (changed || mf != m_state_mf_number) {
70 surf.getCoverages(coverages.data());
71 for (
size_t n = 0; n < coverages.size(); n++) {
72 logCoverages[n] = std::log(std::max(coverages[n],
Tiny));
74 for (
size_t n = 0; n < kin.
nPhases(); n++) {
76 const auto& ph = kin.
thermo(n);
78 ph.getPartialMolarEnthalpies(partialMolarEnthalpies.data() + start);
79 ph.getStandardChemPotentials(standardChemPotentials.data() + start);
80 size_t nsp = ph.nSpecies();
81 for (
size_t k = 0; k < nsp; k++) {
83 standardConcentrations[k + start] = ph.standardConcentration(k);
86 m_state_mf_number = mf;
92void InterfaceData::perturbTemperature(
double deltaT)
97InterfaceRateBase::InterfaceRateBase()
102 , m_chargeTransfer(false)
103 , m_exchangeCurrentDensityFormulation(false)
105 , m_deltaPotential_RT(NAN)
106 , m_deltaGibbs0_RT(NAN)
107 , m_prodStandardConcentrations(NAN)
113 if (node.
hasKey(
"coverage-dependencies")) {
115 node[
"coverage-dependencies"].as<AnyMap>(), node.
units());
117 if (node.
hasKey(
"beta")) {
118 m_beta = node[
"beta"].asDouble();
120 m_exchangeCurrentDensityFormulation = node.
getBool(
121 "exchange-current-density-formulation",
false);
126 if (!
m_cov.empty()) {
129 node[
"coverage-dependencies"] = std::move(deps);
135 if (m_exchangeCurrentDensityFormulation) {
136 node[
"exchange-current-density-formulation"] =
true;
148 for (
const auto& item : dependencies) {
150 if (item.second.is<
AnyMap>()) {
151 auto& cov_map = item.second.as<
AnyMap>();
152 a = cov_map[
"a"].asDouble();
153 m = cov_map[
"m"].asDouble();
156 auto& cov_vec = item.second.asVector<
AnyValue>(3);
158 m = cov_vec[1].asDouble();
168 for (
size_t k = 0; k <
m_cov.size(); k++) {
175 dependencies[
m_cov[k]] = std::move(dep);
180 dep[
"E"].setQuantity(
m_ec[k],
"K",
true);
181 dependencies[
m_cov[k]] = std::move(dep);
187 double a,
double m,
double e)
196 throw CanteraError(
"InterfaceRateBase::addCoverageDependence",
197 "Coverage for species '{}' is already specified.", sp);
204 for (
size_t k = 0; k <
m_cov.size(); k++) {
205 auto it = find(species.begin(), species.end(),
m_cov[k]);
206 if (it != species.end()) {
207 m_indices.emplace(k, it - species.begin());
209 throw CanteraError(
"InterfaceRateBase:setSpeciesIndices",
210 "Species list does not contain '{}'.",
m_cov[k]);
216 if (shared_data.
ready) {
247 if (m_exchangeCurrentDensityFormulation) {
253 if (item.second > 0.) {
275 for (
const auto& sp : rxn.
products) {
288StickingCoverage::StickingCoverage()
290 , m_explicitMotzWise(false)
291 , m_stickingSpecies(
"")
292 , m_explicitSpecies(false)
293 , m_surfaceOrder(NAN)
321 const auto& surf =
dynamic_cast<const SurfPhase&
>(phase);
331 if (sticking_species ==
"") {
333 std::vector<std::string> gasSpecies;
334 std::vector<std::string> anySpecies;
337 if (iPhase != iInterface) {
341 gasSpecies.push_back(sp.first);
343 anySpecies.push_back(sp.first);
346 if (gasSpecies.size() == 1) {
348 sticking_species = gasSpecies[0];
349 }
else if (anySpecies.size() == 1) {
351 sticking_species = anySpecies[0];
352 }
else if (anySpecies.size() == 0) {
354 rxn.
input,
"No non-interface species found "
355 "in sticking reaction: '{}'", rxn.
equation());
358 rxn.
input,
"Multiple non-interface species ({})\nfound in sticking "
359 "reaction: '{}'.\nSticking species must be explicitly specified.",
360 fmt::format(
"'{}'", fmt::join(anySpecies,
"', '")), rxn.
equation());
365 double surface_order = 0.0;
366 double multiplier = 1.0;
372 if (sp.first == sticking_species) {
383 multiplier *= pow(surf.size(k), order);
384 surface_order += order;
Header for reaction rates that occur at interfaces.
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
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.
const std::string & getString(const std::string &key, const std::string &default_) const
If key exists, return it as a string, otherwise return default_.
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.
double & asDouble()
Return the held value as a double, if it is a double or a long int.
Base class for exceptions thrown by Cantera classes.
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.
vector_fp m_ec
Vector holding coverage-specific activation energy dependence.
vector_fp m_ac
Vector holding coverage-specific exponential dependence.
bool m_chargeTransfer
Boolean indicating use of electrochemistry.
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.
void updateFromStruct(const InterfaceData &shared_data)
Update reaction rate parameters.
std::vector< std::string > m_cov
Vector holding names of coverage species.
double m_deltaPotential_RT
Normalized electric potential energy change.
Public interface for kinetics managers.
size_t reactionPhaseIndex() const
Phase where the reactions occur.
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
size_t surfacePhaseIndex() const
This returns the integer index of the phase which has ThermoPhase type cSurf.
size_t speciesPhaseIndex(size_t k) const
This function takes as an argument the kineticsSpecies index (that is, the list index in the list of ...
An error indicating that an unimplemented function has been called.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
int stateMFNumber() const
Return the State Mole Fraction Number.
doublereal temperature() const
Temperature (K).
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Composition orders
Forward reaction order with respect to specific species.
bool usesElectrochemistry(const Kinetics &kin) const
Check whether reaction uses electrochemistry.
Composition products
Product species and stoichiometric coefficients.
Composition reactants
Reactant species and stoichiometric coefficients.
AnyMap input
Input data used for specific models.
std::string equation() const
The chemical equation for this reaction.
void setStickingParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
bool m_explicitSpecies
Boolean flag.
std::string m_stickingSpecies
string identifying sticking species
bool m_explicitMotzWise
Correction cannot be overriden by default.
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.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
double siteDensity() const
Returns the site density.
Base class for a phase with thermodynamic properties.
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
const AnyMap & input() const
Access input data associated with the phase description.
double convertActivationEnergy(double value, const std::string &src, const std::string &dest) const
Convert value from the units of src to the units of dest, allowing for the different dimensions that ...
Namespace for the Cantera kernel.
const double Tiny
Small number to compare differences of mole fractions against.
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.
const U & getValue(const std::map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a std::map.
bool ready
boolean indicating whether vectors are accessible
double density
used to determine if updates are needed
Data container holding shared data for reaction rate specification with interfaces.
vector_fp electricPotentials
electric potentials of phases
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 temperature
temperature