20 "Missing state information: 'InterfaceData' requires species coverages.");
26 "This method does not update the site density.");
32 }
else if (values.size() ==
coverages.size()) {
33 std::copy(values.begin(), values.end(),
coverages.begin());
36 "Incompatible lengths of coverage arrays: received {} elements while "
37 "{} are required.", values.size(),
coverages.size());
39 for (
size_t n = 0; n <
coverages.size(); n++) {
47 for (
size_t n = 0; n < kin.
nPhases(); n++) {
66 for (
size_t n = 0; n <
coverages.size(); n++) {
69 for (
size_t n = 0; n < kin.
nPhases(); n++) {
71 const auto& ph = kin.
thermo(n);
75 size_t nsp = ph.nSpecies();
76 for (
size_t k = 0; k < nsp; k++) {
87void InterfaceData::perturbTemperature(
double deltaT)
92InterfaceRateBase::InterfaceRateBase()
97 , m_chargeTransfer(false)
98 , m_exchangeCurrentDensityFormulation(false)
100 , m_deltaPotential_RT(NAN)
101 , m_deltaGibbs0_RT(NAN)
102 , m_prodStandardConcentrations(NAN)
108 if (node.
hasKey(
"coverage-dependencies")) {
110 node[
"coverage-dependencies"].as<AnyMap>(), node.
units());
112 if (node.
hasKey(
"beta")) {
113 m_beta = node[
"beta"].asDouble();
115 m_exchangeCurrentDensityFormulation = node.
getBool(
116 "exchange-current-density-formulation",
false);
121 if (!
m_cov.empty()) {
124 node[
"coverage-dependencies"] = std::move(deps);
130 if (m_exchangeCurrentDensityFormulation) {
131 node[
"exchange-current-density-formulation"] =
true;
144 for (
const auto& [species, coeffs] : dependencies) {
146 vector<double> E(5, 0.0);
147 if (coeffs.is<
AnyMap>()) {
148 auto& cov_map = coeffs.as<
AnyMap>();
149 a = cov_map[
"a"].asDouble();
150 m = cov_map[
"m"].asDouble();
151 if (cov_map[
"E"].isScalar()) {
156 auto& E_temp = cov_map[
"E"].asVector<
AnyValue>(1, 4);
157 for (
size_t i = 0; i < E_temp.size(); i++) {
162 auto& cov_vec = coeffs.asVector<
AnyValue>(3);
164 m = cov_vec[1].asDouble();
165 if (cov_vec[2].isScalar()) {
170 auto& E_temp = cov_vec[2].asVector<
AnyValue>(1, 4);
171 for (
size_t i = 0; i < E_temp.size(); i++) {
182 for (
size_t k = 0; k <
m_cov.size(); k++) {
187 dep[
"E"].setQuantity(
m_ec[k][1],
"K",
true);
189 vector<AnyValue> E_temp(4);
190 for (
size_t i = 0; i <
m_ec[k].size() - 1; i++) {
191 E_temp[i].setQuantity(
m_ec[k][i+1],
"K",
true);
195 dependencies[
m_cov[k]] = std::move(dep);
200 const vector<double>& e)
209 throw CanteraError(
"InterfaceRateBase::addCoverageDependence",
210 "Coverage for species '{}' is already specified.", sp);
217 for (
size_t k = 0; k <
m_cov.size(); k++) {
218 auto it = find(species.begin(), species.end(),
m_cov[k]);
219 if (it != species.end()) {
220 m_indices.emplace(k, it - species.begin());
222 throw CanteraError(
"InterfaceRateBase:setSpeciesIndices",
223 "Species list does not contain '{}'.",
m_cov[k]);
229 if (shared_data.
ready) {
264 if (m_exchangeCurrentDensityFormulation) {
289 for (
const auto& [name, stoich] : rxn.
reactants) {
292 for (
const auto& [name, stoich] : rxn.
products) {
305StickingCoverage::StickingCoverage()
307 , m_explicitMotzWise(false)
308 , m_stickingSpecies(
"")
309 , m_explicitSpecies(false)
310 , m_surfaceOrder(NAN)
338 const auto& surf =
dynamic_cast<const SurfPhase&
>(phase);
345 if (sticking_species ==
"") {
347 vector<string> gasSpecies;
348 vector<string> anySpecies;
349 for (
const auto& [name, stoich] : rxn.
reactants) {
355 gasSpecies.push_back(name);
357 anySpecies.push_back(name);
360 if (gasSpecies.size() == 1) {
362 sticking_species = gasSpecies[0];
363 }
else if (anySpecies.size() == 1) {
365 sticking_species = anySpecies[0];
366 }
else if (anySpecies.size() == 0) {
368 rxn.
input,
"No non-interface species found "
369 "in sticking reaction: '{}'", rxn.
equation());
372 rxn.
input,
"Multiple non-interface species ({})\nfound in sticking "
373 "reaction: '{}'.\nSticking species must be explicitly specified.",
374 fmt::format(
"'{}'", fmt::join(anySpecies,
"', '")), rxn.
equation());
379 double surface_order = 0.0;
380 double multiplier = 1.0;
382 for (
const auto& [name, stoich] : rxn.
reactants) {
386 if (name == sticking_species) {
397 multiplier *= pow(surf.size(k), order);
398 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.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
const string & getString(const string &key, const string &default_) const
If key exists, return it as a string, otherwise return default_.
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.
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.
bool m_chargeTransfer
Boolean indicating use of electrochemistry.
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.
void updateFromStruct(const InterfaceData &shared_data)
Update reaction rate parameters.
double m_deltaPotential_RT
Normalized electric potential energy change.
Public interface for kinetics managers.
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 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.
double temperature() const
Temperature (K).
size_t speciesIndex(const string &name) const
Returns the index of a species named 'name' within the Phase object.
int stateMFNumber() const
Return the State Mole Fraction Number.
const vector< string > & speciesNames() const
Return a const reference to the vector of species names.
double molecularWeight(size_t k) const
Molecular weight of species k.
double charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
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.
string equation() const
The chemical equation for this reaction.
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.
void setStickingParameters(const AnyMap &node)
Perform object setup based on AnyMap node information.
bool m_explicitSpecies
Boolean flag.
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 double standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
const AnyMap & input() const
Access input data associated with the phase description.
double convertActivationEnergy(double value, const string &src, const string &dest) const
Convert value from the units of src to the units of dest, allowing for the different dimensions that ...
R poly4(D x, R *c)
Evaluates a polynomial of order 4.
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.
const double Tiny
Small number to compare differences of mole fractions against.
const U & getValue(const map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a map.
int m_state_mf_number
integer that is incremented when composition changes
vector< double > partialMolarEnthalpies
partial molar enthalpies
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< 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
double sqrtT
square root of temperature
virtual void update(double T)
Update data container based on temperature T
double temperature
temperature
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...