20 InterfaceKinetics::InterfaceKinetics(
thermo_t* thermo) :
27 m_has_coverage_dependence(false),
28 m_has_electrochem_rxns(false),
29 m_has_exchange_current_density_formulation(false),
30 m_phaseExistsCheck(false),
39 InterfaceKinetics::~InterfaceKinetics()
63 if (T !=
m_temp || m_redo_rates) {
68 applyStickingCorrection(T,
m_rfn.data());
88 for (
size_t n = 0; n <
nPhases(); n++) {
98 for (
size_t n = 0; n <
nPhases(); n++) {
132 doublereal rrt = 1.0 /
thermo(0).
RT();
137 for (
size_t i = 0; i <
m_revindex.size(); i++) {
140 throw CanteraError(
"InterfaceKinetics",
"illegal value: irxn = {}", irxn);
145 for (
size_t i = 0; i !=
m_irrev.size(); ++i) {
158 for (
size_t n = 0; n <
nPhases(); n++) {
171 doublereal rrt = 1.0 /
thermo(0).
RT();
175 kc[i] = exp(-kc[i]*rrt);
193 for (
size_t n = 0; n <
nPhases(); n++) {
196 for (
size_t k = 0; k < nsp; k++) {
215 for (
size_t n = 0; n <
nPhases(); n++) {
217 for (
size_t k = 0; k < nsp; k++) {
234 for (
size_t i = 0; i <
m_beta.size(); i++) {
242 kf[irxn] *= exp(-eamod/
thermo(0).RT());
253 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
259 if (iECDFormulation) {
305 if (doIrreversible) {
360 for (
size_t p = 0; p <
nPhases(); p++) {
365 for (
size_t rp = 0; rp <
nPhases(); rp++) {
379 for (
size_t p = 0; p <
nPhases(); p++) {
384 for (
size_t rp = 0; rp <
nPhases(); rp++) {
407 for (
size_t n = 0; n <
nPhases(); n++) {
413 if (deltaG != 0 && (
m_deltaG.data() != deltaG)) {
423 for (
size_t n = 0; n <
nPhases(); n++) {
434 for (
size_t n = 0; n <
nPhases(); n++) {
445 for (
size_t n = 0; n <
nPhases(); n++) {
459 for (
size_t n = 0; n <
nPhases(); n++) {
473 for (
size_t n = 0; n <
nPhases(); n++) {
476 for (
size_t k = 0; k <
m_kk; k++) {
489 for (
size_t n = 0; n <
nPhases(); n++) {
492 for (
size_t k = 0; k <
m_kk; k++) {
507 double reac_sites = 0.0;
508 double prod_sites = 0.0;
509 for (
const auto& reactant : r_base->reactants) {
512 reac_sites += reactant.second *
m_surf->
size(k);
515 for (
const auto& product : r_base->products) {
518 prod_sites += product.second *
m_surf->
size(k);
521 if (fabs(reac_sites - prod_sites) > 1e-5 * (reac_sites + prod_sites)) {
522 throw CanteraError(
"InterfaceKinetics::addReaction",
"Number of surface" 523 " sites not balanced in reaction {}.\nReactant sites: {}\n" 524 "Product sites: {}", r_base->equation(), reac_sites, prod_sites);
547 if (re->exchange_current_density_formulation) {
569 for (
const auto& order : r.
orders) {
577 "film resistivity set for elementary reaction");
627 size_t iInterface =
npos;
629 for (
size_t n = 0; n <
nPhases(); n++) {
637 if (sticking_species ==
"") {
639 bool foundStick =
false;
642 if (iPhase != iInterface) {
646 "Multiple non-interface species found" 647 "in sticking reaction: '" + r.
equation() +
"'");
650 sticking_species = sp.first;
655 "No non-interface species found" 656 "in sticking reaction: '" + r.
equation() +
"'");
660 double surface_order = 0.0;
667 if (sp.first == sticking_species) {
679 surface_order += order;
692 if (item.index == i) {
693 item.order = surface_order;
709 rate.addCoverageDependence(k, sp.second.a, sp.second.m, sp.second.E);
714 void InterfaceKinetics::setIOFlag(
int ioFlag)
733 "no surface phase is present.");
739 "expected interface dimension = 2, but got dimension = {}",
749 throw CanteraError(
"InterfaceKinetics::resizeSpecies",
"Cannot add" 750 " species to InterfaceKinetics after reactions have been added.");
765 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
776 vector<InterfaceKinetics*> k{
this};
786 int ifuncOverride, doublereal timeScaleOverride)
790 vector<InterfaceKinetics*> k{
this};
802 throw CanteraError(
"InterfaceKinetics:setPhaseExistence",
"out of bounds");
823 throw CanteraError(
"InterfaceKinetics:phaseExistence()",
"out of bounds");
831 throw CanteraError(
"InterfaceKinetics:phaseStability()",
"out of bounds");
839 throw CanteraError(
"InterfaceKinetics:setPhaseStability",
"out of bounds");
853 for (
const auto& order : r.
orders) {
858 double betaf = r.
beta;
864 fwdFullOrders[k] += betaf * sp.second;
866 if (abs(fwdFullOrders[k]) < 0.00001) {
867 fwdFullOrders[k] = 0.0;
875 fwdFullOrders[k] -= betaf * sp.second;
877 if (abs(fwdFullOrders[k]) < 0.00001) {
878 fwdFullOrders[k] = 0.0;
883 void InterfaceKinetics::applyStickingCorrection(
double T,
double* kf)
894 if (!cached.validate(n0)) {
903 if (item.use_motz_wise) {
904 kf[item.index] /= 1 - 0.5 * kf[item.index];
906 kf[item.index] *= factors[n] * sqrt(T) * item.multiplier;
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
virtual double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.
std::string sticking_species
For reactions with multiple non-surface species, the sticking species needs to be explicitly identifi...
void applyVoltageKfwdCorrection(doublereal *const kfwd)
Apply modifications for the forward reaction rate for interfacial charge transfer reactions...
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
void setElectricPotential(int n, doublereal V)
Set the electric potential in the nth phase.
vector_fp m_deltaG0
Vector of delta G^0, the standard state Gibbs free energies for each reaction.
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
std::vector< thermo_t * > m_thermo
m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator...
bool is_sticking_coefficient
Set to true if rate is a parameterization of the sticking coefficient rather than the forward rate co...
int getId()
Get a unique id for a cached value.
int reaction_type
Type of the reaction.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
doublereal electrochem_beta(size_t irxn) const
Return the charge transfer rxn Beta parameter for the ith reaction.
doublereal m_logtemp
Current log of the temperature.
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
doublereal temperature() const
Temperature (K).
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism...
void setElectricPotential(doublereal v)
Set the electric potential of this phase (V).
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
SurfPhase * m_surf
Pointer to the single surface phase.
std::vector< size_t > m_start
m_start is a vector of integers specifying the beginning position for the species vector for the n'th...
const size_t npos
index returned by functions to indicate "no position"
vector_fp m_phi
Vector of phase electric potentials.
void advanceCoverages(doublereal tstep)
Advance the surface coverages in time.
vector_fp m_deltaG
Vector of deltaG[] of reaction, the delta Gibbs free energies for each reaction.
const int SURFACEAFFINITY_RXN
This is a surface reaction that is formulated using the affinity representation, common in the geoche...
Composition orders
Forward reaction order with respect to specific species.
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
vector_fp m_beta
Electrochemical transfer coefficient for the forward direction.
virtual void updateMu0()
Update the standard state chemical potentials and species equilibrium constant entries.
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction...
virtual void getEquilibriumConstants(doublereal *kc)
Equilibrium constant for all reactions including the voltage term.
size_t nSpecies() const
Returns the number of species in the phase.
std::vector< std::vector< bool > > m_rxnPhaseIsProduct
Vector of vector of booleans indicating whether a phase participates in a reaction as a product...
vector_fp m_StandardConc
Vector of standard concentrations.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
virtual void getRevReactionDelta(const doublereal *g, doublereal *dg)
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
vector_fp m_ropnet
Net rate-of-progress for each reaction.
size_t reactionPhaseIndex()
Phase where the reactions occur.
void convertExchangeCurrentDensityFormulation(doublereal *const kfwd)
When an electrode reaction rate is optionally specified in terms of its exchange current density...
size_t nPhases() const
The number of phases participating in the reaction mechanism.
bool m_has_electrochem_rxns
Boolean flag indicating whether any reaction in the mechanism has a beta electrochemical parameter...
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
void multiply_each(OutputIter x_begin, OutputIter x_end, InputIter y_begin)
Multiply each entry in x by the corresponding entry in y.
int m_phaseExistsCheck
Int flag to indicate that some phases in the kinetics mechanism are non-existent. ...
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
vector_fp m_mu0_Kc
Vector of standard state electrochemical potentials modified by a standard concentration term...
vector_fp deltaElectricEnergy_
Storage for the net electric energy change due to reaction.
SurfaceArrhenius buildSurfaceArrhenius(size_t i, InterfaceReaction &r, bool replace)
Build a SurfaceArrhenius object from a Reaction, taking into account the possible sticking coefficien...
vector_fp m_ropf
Forward rate-of-progress for each reaction.
Base class for a phase with thermodynamic properties.
Values used for converting sticking coefficients into rate constants.
void updateKc()
Update the equilibrium constants and stored electrochemical potentials in molar units for all reversi...
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
doublereal m_temp
Current temperature of the data.
std::map< std::string, CoverageDependency > coverage_deps
Adjustments to the Arrhenius rate expression dependent on surface species coverages.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
size_t surfacePhaseIndex()
This returns the integer index of the phase which has ThermoPhase type cSurf.
bool m_has_coverage_dependence
Boolean flag indicating whether any reaction in the mechanism has a coverage dependent forward reacti...
ValueCache m_cache
Cache for saved calculations within each Kinetics object.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
vector_int m_ctrxn_ecdf
Vector of booleans indicating whether the charge transfer reaction rate constant is described by an e...
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
bool reversible
True if the current reaction is reversible. False otherwise.
std::vector< size_t > m_ctrxn_BVform
Vector of Reactions which follow the Butler-Volmer methodology for specifying the exchange current de...
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
vector_int m_phaseIsStable
Vector of int indicating whether phases are stable or not.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
vector_fp m_conc
Array of concentrations for each species in the kinetics mechanism.
doublereal multiplier(size_t i) const
The current value of the multiplier for reaction i.
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
std::vector< bool > m_phaseExists
Vector of booleans indicating whether phases exist or not.
vector_fp m_rfn
Forward rate constant for each reaction.
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
size_t m_nDim
Number of dimensions of reacting phase (2 for InterfaceKinetics, 1 for EdgeKinetics) ...
void _update_rates_T()
Update properties that depend on temperature.
A reaction occurring on an interface (i.e. a SurfPhase or an EdgePhase)
vector_fp m_actConc
Array of activity concentrations for each species in the kinetics object.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
double preExponentialFactor() const
Return the pre-exponential factor A (in m, kmol, s to powers depending on the reaction order) ...
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
virtual void getActivityConcentrations(doublereal *const conc)
Get the vector of activity concentrations used in the kinetics object.
void _update_rates_C()
Update properties that depend on the species mole fractions and/or concentration,.
vector_fp m_pot
Vector of potential energies due to Voltages.
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.
int phaseExistence(const size_t iphase) const
Gets the phase existence int for the ith phase.
void setPhaseStability(const size_t iphase, const int isStable)
Set the stability of a phase in the reaction object.
Base class for exceptions thrown by Cantera classes.
doublereal activationEnergy_R() const
Return the activation energy divided by the gas constant (i.e.
size_t nReactions() const
Number of reactions in the reaction mechanism.
Composition reactants
Reactant species and stoichiometric coefficients.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
double temperatureExponent() const
Return the temperature exponent b
bool m_has_exchange_current_density_formulation
Boolean flag indicating whether any reaction in the mechanism is described by an exchange current den...
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
Declarations for the implicit integration of surface site density equations (see Kinetics Managers an...
std::vector< std::vector< bool > > m_rxnPhaseIsReactant
Vector of vector of booleans indicating whether a phase participates in a reaction as a reactant...
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
std::vector< size_t > m_revindex
List of reactions numbers which are reversible reactions.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
int phaseStability(const size_t iphase) const
Gets the phase stability int for the ith phase.
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
std::vector< StickData > m_stickingData
Data for sticking reactions.
const int GLOBAL_RXN
A global reaction.
void _update_rates_phi()
Update properties that depend on the electric potential.
doublereal film_resistivity
Film Resistivity value.
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
std::vector< size_t > m_irrev
Vector of irreversible reaction numbers.
Advances the surface coverages of the associated set of SurfacePhase objects in time.
virtual void initialize(doublereal t0=0.0)
vector_fp m_mu
Vector of chemical potentials for all species.
void updateExchangeCurrentQuantities()
values needed to convert from exchange current density to surface reaction rate.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
virtual void updateROP()
Internal routine that updates the Rates of Progress of the reactions.
size_t speciesPhaseIndex(size_t k)
This function takes as an argument the kineticsSpecies index (i.e., the list index in the list of spe...
bool use_motz_wise_correction
Set to true if rate is a sticking coefficient which should be translated into a rate coefficient usin...
doublereal beta
Forward value of the apparent Electrochemical transfer coefficient.
Rate1< SurfaceArrhenius > m_rates
Templated class containing the vector of reactions for this interface.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
std::vector< size_t > m_ctrxn
Vector of reaction indexes specifying the id of the charge transfer reactions in the mechanism...
vector_fp m_ProdStanConcReac
Vector of the products of the standard concentrations of the reactants.
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
const int BUTLERVOLMER_NOACTIVITYCOEFFS_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation and using concentra...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void setPhaseExistence(const size_t iphase, const int exists)
Set the existence of a phase in the reaction object.
CachedArray getArray(int id)
Get a reference to a CachedValue object representing an array (vector_fp) with the given id...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
const int BUTLERVOLMER_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation.
Composition products
Product species and stoichiometric coefficients.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state Gibbs free energy change.
Namespace for the Cantera kernel.
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
virtual void getDeltaElectrochemPotentials(doublereal *deltaM)
Return the vector of values for the reaction electrochemical free energy change.
vector_fp m_mu0
Vector of standard state chemical potentials for all species.
vector_fp m_grt
Temporary work vector of length m_kk.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
ImplicitSurfChem * m_integrator
Pointer to the Implicit surface chemistry object.
An Arrhenius rate with coverage-dependent terms.
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
An interface reaction which involves charged species.
void integrate(doublereal t0, doublereal t1)
Integrate from t0 to t1. The integrator is reinitialized first.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
doublereal siteDensity()
Returns the site density.
std::string equation() const
The chemical equation for this reaction.