Go to the documentation of this file.
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++) {
137 for (
size_t i = 0; i <
m_revindex.size(); i++) {
141 "illegal value: irxn = {}", irxn);
146 for (
size_t i = 0; i !=
m_irrev.size(); ++i) {
159 for (
size_t n = 0; n <
nPhases(); n++) {
177 kc[i] = exp(-kc[i]*rrt);
195 for (
size_t n = 0; n <
nPhases(); n++) {
198 for (
size_t k = 0; k < nsp; k++) {
217 for (
size_t n = 0; n <
nPhases(); n++) {
219 for (
size_t k = 0; k < nsp; k++) {
236 for (
size_t i = 0; i <
m_beta.size(); i++) {
255 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
261 if (iECDFormulation) {
307 if (doIrreversible) {
358 for (
size_t p = 0; p <
nPhases(); p++) {
363 for (
size_t rp = 0; rp <
nPhases(); rp++) {
377 for (
size_t p = 0; p <
nPhases(); p++) {
382 for (
size_t rp = 0; rp <
nPhases(); rp++) {
405 for (
size_t n = 0; n <
nPhases(); n++) {
411 if (deltaG != 0 && (
m_deltaG.data() != deltaG)) {
421 for (
size_t n = 0; n <
nPhases(); n++) {
432 for (
size_t n = 0; n <
nPhases(); n++) {
443 for (
size_t n = 0; n <
nPhases(); n++) {
457 for (
size_t n = 0; n <
nPhases(); n++) {
471 for (
size_t n = 0; n <
nPhases(); n++) {
474 for (
size_t k = 0; k <
m_kk; k++) {
487 for (
size_t n = 0; n <
nPhases(); n++) {
490 for (
size_t k = 0; k <
m_kk; k++) {
505 double reac_sites = 0.0;
506 double prod_sites = 0.0;
507 for (
const auto& reactant : r_base->reactants) {
510 reac_sites += reactant.second *
m_surf->
size(k);
513 for (
const auto& product : r_base->products) {
516 prod_sites += product.second *
m_surf->
size(k);
519 if (fabs(reac_sites - prod_sites) > 1e-5 * (reac_sites + prod_sites)) {
520 throw CanteraError(
"InterfaceKinetics::addReaction",
"Number of surface"
521 " sites not balanced in reaction {}.\nReactant sites: {}\n"
522 "Product sites: {}", r_base->equation(), reac_sites, prod_sites);
545 if (re->exchange_current_density_formulation) {
567 for (
const auto& order : r.
orders) {
575 "film resistivity set for elementary reaction");
625 size_t iInterface =
npos;
627 for (
size_t n = 0; n <
nPhases(); n++) {
635 if (sticking_species ==
"") {
637 bool foundStick =
false;
640 if (iPhase != iInterface) {
643 throw CanteraError(
"InterfaceKinetics::buildSurfaceArrhenius",
644 "Multiple non-interface species found"
645 "in sticking reaction: '" + r.
equation() +
"'");
648 sticking_species = sp.first;
652 throw CanteraError(
"InterfaceKinetics::buildSurfaceArrhenius",
653 "No non-interface species found"
654 "in sticking reaction: '" + r.
equation() +
"'");
658 double surface_order = 0.0;
665 if (sp.first == sticking_species) {
677 surface_order += order;
690 if (item.index == i) {
691 item.order = surface_order;
712 void InterfaceKinetics::setIOFlag(
int ioFlag)
732 "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++) {
774 doublereal atol, doublereal maxStepSize,
775 size_t maxSteps,
size_t maxErrTestFails)
778 vector<InterfaceKinetics*> k{
this};
791 int ifuncOverride, doublereal timeScaleOverride)
795 vector<InterfaceKinetics*> k{
this};
850 for (
const auto& order : r.
orders) {
855 double betaf = r.
beta;
861 fwdFullOrders[k] += betaf * sp.second;
863 if (abs(fwdFullOrders[k]) < 0.00001) {
864 fwdFullOrders[k] = 0.0;
872 fwdFullOrders[k] -= betaf * sp.second;
874 if (abs(fwdFullOrders[k]) < 0.00001) {
875 fwdFullOrders[k] = 0.0;
880 void InterfaceKinetics::applyStickingCorrection(
double T,
double* kf)
891 if (!cached.validate(n0)) {
900 if (item.use_motz_wise) {
901 kf[item.index] /= 1 - 0.5 * kf[item.index];
903 kf[item.index] *= factors[n] * sqrt(T) * item.multiplier;
doublereal beta
Forward value of the apparent Electrochemical transfer coefficient.
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.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
ImplicitSurfChem * m_integrator
Pointer to the Implicit surface chemistry object.
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
std::vector< thermo_t * > m_thermo
m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator
size_t m_nDim
Number of dimensions of reacting phase (2 for InterfaceKinetics, 1 for EdgeKinetics)
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
An interface reaction which involves charged species.
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.
SurfPhase * m_surf
Pointer to the single surface phase.
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
vector_fp m_ropf
Forward rate-of-progress for each reaction.
const int SURFACEAFFINITY_RXN
This is a surface reaction that is formulated using the affinity representation, common in the geoche...
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
vector_fp m_StandardConc
Vector of standard concentrations.
vector_fp m_phi
Vector of phase electric potentials.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
bool m_has_electrochem_rxns
Boolean flag indicating whether any reaction in the mechanism has a beta electrochemical parameter.
vector_fp m_deltaG0
Vector of delta G^0, the standard state Gibbs free energies for each reaction.
CachedArray getArray(int id)
Get a reference to a CachedValue object representing an array (vector_fp) with the given id.
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
doublereal m_temp
Current temperature of the data.
void addCoverageDependence(size_t k, doublereal a, doublereal m, doublereal e)
Add a coverage dependency for species k, with exponential dependence a, power-law exponent m,...
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
std::vector< StickData > m_stickingData
Data for sticking reactions.
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
size_t reactionPhaseIndex() const
Phase where the reactions occur.
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
void setPhaseExistence(const size_t iphase, const int exists)
Set the existence of a phase in the reaction object.
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
virtual void getEquilibriumConstants(doublereal *kc)
Equilibrium constant for all reactions including the voltage term.
Composition reactants
Reactant species and stoichiometric coefficients.
virtual void getActivityConcentrations(doublereal *const conc)
Get the vector of activity concentrations used in the kinetics object.
std::string equation() const
The chemical equation for this reaction.
vector_fp m_deltaG
Vector of deltaG[] of reaction, the delta Gibbs free energies for each reaction.
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
A reaction occurring on an interface (i.e. a SurfPhase or an EdgePhase)
bool use_motz_wise_correction
Set to true if rate is a sticking coefficient which should be translated into a rate coefficient usin...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
bool reversible
True if the current reaction is reversible. False otherwise.
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
void getConcentrations(double *const c) const
Get the species concentrations (kmol/m^3).
void convertExchangeCurrentDensityFormulation(doublereal *const kfwd)
When an electrode reaction rate is optionally specified in terms of its exchange current density,...
doublereal m_logtemp
Current log of the temperature.
virtual void setMaxErrTestFails(size_t maxErrTestFails=7)
std::vector< std::vector< bool > > m_rxnPhaseIsProduct
Vector of vector of booleans indicating whether a phase participates in a reaction as a product.
Composition products
Product species and stoichiometric coefficients.
vector_fp m_mu0_Kc
Vector of standard state electrochemical potentials modified by a standard concentration term.
vector_fp m_conc
Array of concentrations for each species in the kinetics mechanism.
std::vector< size_t > m_ctrxn_BVform
Vector of Reactions which follow the Butler-Volmer methodology for specifying the exchange current de...
int reaction_type
Type of the reaction.
vector_fp m_grt
Temporary work vector of length m_kk.
void setElectricPotential(int n, doublereal V)
Set the electric potential in the nth phase.
void setElectricPotential(doublereal v)
Set the electric potential of this phase (V).
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
int phaseStability(const size_t iphase) const
Gets the phase stability int for the ith phase.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
int getId()
Get a unique id for a cached value.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
double temperatureExponent() const
Return the temperature exponent b
void setPhaseStability(const size_t iphase, const int isStable)
Set the stability of a phase in the reaction object.
bool m_has_coverage_dependence
Boolean flag indicating whether any reaction in the mechanism has a coverage dependent forward reacti...
void _update_rates_T()
Update properties that depend on temperature.
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state Gibbs free energy change.
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
std::vector< bool > m_phaseExists
Vector of booleans indicating whether phases exist or not.
vector_fp deltaElectricEnergy_
Storage for the net electric energy change due to reaction.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
doublereal film_resistivity
Film Resistivity value.
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.
virtual void setTolerances(double rtol=1.e-7, double atol=1.e-14)
ValueCache m_cache
Cache for saved calculations within each Kinetics object.
void _update_rates_phi()
Update properties that depend on the electric potential.
virtual void updateROP()
Internal routine that updates the Rates of Progress of the reactions.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
void advanceCoverages(doublereal tstep, double rtol=1.e-7, double atol=1.e-14, double maxStepSize=0, size_t maxSteps=20000, size_t maxErrTestFails=7)
Advance the surface coverages in time.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
std::string sticking_species
For reactions with multiple non-surface species, the sticking species needs to be explicitly identifi...
vector_fp m_pot
Vector of potential energies due to Voltages.
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...
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.
bool is_sticking_coefficient
Set to true if rate is a parameterization of the sticking coefficient rather than the forward rate co...
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
Values used for converting sticking coefficients into rate constants.
Base class for a phase with thermodynamic properties.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
vector_int m_phaseIsStable
Vector of int indicating whether phases are stable or not.
std::vector< size_t > m_ctrxn
Vector of reaction indexes specifying the id of the charge transfer reactions in the mechanism.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
vector_fp m_rfn
Forward rate constant for each reaction.
const int GLOBAL_RXN
A global reaction.
Rate1< SurfaceArrhenius > m_rates
Templated class containing the vector of reactions for this interface.
virtual void initialize(doublereal t0=0.0)
doublereal temperature() const
Temperature (K).
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
Composition orders
Forward reaction order with respect to specific species.
doublereal activationEnergy_R() const
Return the activation energy divided by the gas constant (i.e.
vector_fp m_mu0
Vector of standard state chemical potentials for all species.
size_t nSpecies() const
Returns the number of species in the phase.
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_mu
Vector of chemical potentials for all species.
std::vector< size_t > m_revindex
List of reactions numbers which are reversible reactions.
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
virtual void determineFwdOrdersBV(ElectrochemicalReaction &r, vector_fp &fwdFullorders)
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
bool m_has_exchange_current_density_formulation
Boolean flag indicating whether any reaction in the mechanism is described by an exchange current den...
Advances the surface coverages of the associated set of SurfacePhase objects in time.
size_t speciesPhaseIndex(size_t k) const
This function takes as an argument the kineticsSpecies index (i.e., the list index in the list of spe...
vector_fp m_ropnet
Net rate-of-progress for each reaction.
virtual void updateMu0()
Update the standard state chemical potentials and species equilibrium constant entries.
vector_fp m_beta
Electrochemical transfer coefficient for the forward direction.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
std::vector< std::vector< bool > > m_rxnPhaseIsReactant
Vector of vector of booleans indicating whether a phase participates in a reaction as a reactant.
const int BUTLERVOLMER_NOACTIVITYCOEFFS_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation and using concentra...
vector_int m_ctrxn_ecdf
Vector of booleans indicating whether the charge transfer reaction rate constant is described by an e...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
int phaseExistence(const size_t iphase) const
Gets the phase existence int for the ith phase.
double preExponentialFactor() const
Return the pre-exponential factor A (in m, kmol, s to powers depending on the reaction order)
void _update_rates_C()
Update properties that depend on the species mole fractions and/or concentration,.
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
const int BUTLERVOLMER_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation.
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
doublereal siteDensity()
Returns the site density.
void checkPhaseIndex(size_t m) const
Check that the specified phase index is in range Throws an exception if m is greater than nPhases()
void integrate(doublereal t0, doublereal t1)
Integrate from t0 to t1. The integrator is reinitialized first.
void updateKc()
Update the equilibrium constants and stored electrochemical potentials in molar units for all reversi...
const double GasConstant
Universal Gas Constant [J/kmol/K].
virtual void setMaxSteps(size_t maxsteps=20000)
const double Faraday
Faraday constant [C/kmol].
Base class for exceptions thrown by Cantera classes.
size_t nReactions() const
Number of reactions in the reaction mechanism.
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
const size_t npos
index returned by functions to indicate "no position"
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
void applyVoltageKfwdCorrection(doublereal *const kfwd)
Apply modifications for the forward reaction rate for interfacial charge transfer reactions.
SurfaceArrhenius buildSurfaceArrhenius(size_t i, InterfaceReaction &r, bool replace)
Build a SurfaceArrhenius object from a Reaction, taking into account the possible sticking coefficien...
virtual void setMaxStepSize(double maxstep=0.0)
std::vector< size_t > m_irrev
Vector of irreversible reaction numbers.
void updateExchangeCurrentQuantities()
values needed to convert from exchange current density to surface reaction rate.
Namespace for the Cantera kernel.
virtual void getDeltaElectrochemPotentials(doublereal *deltaM)
Return the vector of values for the reaction electrochemical free energy change.
std::map< std::string, CoverageDependency > coverage_deps
Adjustments to the Arrhenius rate expression dependent on surface species coverages.
size_t surfacePhaseIndex() const
This returns the integer index of the phase which has ThermoPhase type cSurf.
vector_fp m_ProdStanConcReac
Vector of the products of the standard concentrations of the reactants.
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 doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
An Arrhenius rate with coverage-dependent terms.
vector_fp m_actConc
Array of activity concentrations for each species in the kinetics object.
virtual double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.