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;
Declarations for the implicit integration of surface site density equations (see Kinetics Managers an...
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
double temperatureExponent() const
Return the temperature exponent b
doublereal activationEnergy_R() const
Return the activation energy divided by the gas constant (i.e.
double preExponentialFactor() const
Return the pre-exponential factor A (in m, kmol, s to powers depending on the reaction order)
Base class for exceptions thrown by Cantera classes.
An interface reaction which involves charged species.
doublereal beta
Forward value of the apparent Electrochemical transfer coefficient.
doublereal film_resistivity
Film Resistivity value.
Advances the surface coverages of the associated set of SurfacePhase objects in time.
void integrate(doublereal t0, doublereal t1)
Integrate from t0 to t1. The integrator is reinitialized first.
virtual void setTolerances(double rtol=1.e-7, double atol=1.e-14)
virtual void setMaxStepSize(double maxstep=0.0)
virtual void setMaxSteps(size_t maxsteps=20000)
virtual void initialize(doublereal t0=0.0)
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
virtual void setMaxErrTestFails(size_t maxErrTestFails=7)
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state Gibbs free energy change.
std::vector< size_t > m_revindex
List of reactions numbers which are reversible reactions.
int phaseExistence(const size_t iphase) const
Gets the phase existence int for the ith phase.
SurfPhase * m_surf
Pointer to the single surface phase.
vector_fp m_beta
Electrochemical transfer coefficient for the forward direction.
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
void applyVoltageKfwdCorrection(doublereal *const kfwd)
Apply modifications for the forward reaction rate for interfacial charge transfer reactions.
size_t m_nDim
Number of dimensions of reacting phase (2 for InterfaceKinetics, 1 for EdgeKinetics)
vector_fp m_deltaG0
Vector of delta G^0, the standard state Gibbs free energies for each reaction.
void setPhaseStability(const size_t iphase, const int isStable)
Set the stability of a phase in the reaction object.
vector_fp m_StandardConc
Vector of standard concentrations.
vector_fp m_deltaG
Vector of deltaG[] of reaction, the delta Gibbs free energies for each reaction.
vector_fp m_phi
Vector of phase electric potentials.
virtual void getDeltaElectrochemPotentials(doublereal *deltaM)
Return the vector of values for the reaction electrochemical free energy change.
void convertExchangeCurrentDensityFormulation(doublereal *const kfwd)
When an electrode reaction rate is optionally specified in terms of its exchange current density,...
void _update_rates_phi()
Update properties that depend on the electric potential.
doublereal m_temp
Current temperature of the data.
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 getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
bool m_has_electrochem_rxns
Boolean flag indicating whether any reaction in the mechanism has a beta electrochemical parameter.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
std::vector< size_t > m_ctrxn
Vector of reaction indexes specifying the id of the charge transfer reactions in the mechanism.
std::vector< StickData > m_stickingData
Data for sticking reactions.
vector_fp m_actConc
Array of activity concentrations for each species in the kinetics object.
void setElectricPotential(int n, doublereal V)
Set the electric potential in the nth phase.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
vector_int m_ctrxn_ecdf
Vector of booleans indicating whether the charge transfer reaction rate constant is described by an e...
vector_fp m_conc
Array of concentrations for each species in the kinetics mechanism.
void updateKc()
Update the equilibrium constants and stored electrochemical potentials in molar units for all reversi...
void setPhaseExistence(const size_t iphase, const int exists)
Set the existence of a phase in the reaction object.
std::vector< size_t > m_irrev
Vector of irreversible reaction numbers.
vector_fp m_mu0
Vector of standard state chemical potentials for all species.
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 getActivityConcentrations(doublereal *const conc)
Get the vector of activity concentrations used in the kinetics object.
vector_fp m_pot
Vector of potential energies due to Voltages.
void _update_rates_C()
Update properties that depend on the species mole fractions and/or concentration,.
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
std::vector< size_t > m_ctrxn_BVform
Vector of Reactions which follow the Butler-Volmer methodology for specifying the exchange current de...
vector_fp m_mu
Vector of chemical potentials for all species.
vector_fp m_grt
Temporary work vector of length m_kk.
vector_fp deltaElectricEnergy_
Storage for the net electric energy change due to reaction.
doublereal m_logtemp
Current log of the temperature.
int phaseStability(const size_t iphase) const
Gets the phase stability int for the ith phase.
ImplicitSurfChem * m_integrator
Pointer to the Implicit surface chemistry object.
virtual void getEquilibriumConstants(doublereal *kc)
Equilibrium constant for all reactions including the voltage term.
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction.
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
void _update_rates_T()
Update properties that depend on temperature.
virtual void updateROP()
Internal routine that updates the Rates of Progress of the reactions.
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
virtual void determineFwdOrdersBV(ElectrochemicalReaction &r, vector_fp &fwdFullorders)
bool m_has_coverage_dependence
Boolean flag indicating whether any reaction in the mechanism has a coverage dependent forward reacti...
virtual void updateMu0()
Update the standard state chemical potentials and species equilibrium constant entries.
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_mu0_Kc
Vector of standard state electrochemical potentials modified by a standard concentration term.
vector_int m_phaseIsStable
Vector of int indicating whether phases are stable or not.
void updateExchangeCurrentQuantities()
values needed to convert from exchange current density to surface reaction rate.
std::vector< bool > m_phaseExists
Vector of booleans indicating whether phases exist or not.
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
int m_phaseExistsCheck
Int flag to indicate that some phases in the kinetics mechanism are non-existent.
vector_fp m_ProdStanConcReac
Vector of the products of the standard concentrations of the reactants.
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.
doublereal electrochem_beta(size_t irxn) const
Return the charge transfer rxn Beta parameter for the ith reaction.
bool m_has_exchange_current_density_formulation
Boolean flag indicating whether any reaction in the mechanism is described by an exchange current den...
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
Rate1< SurfaceArrhenius > m_rates
Templated class containing the vector of reactions for this interface.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
A reaction occurring on an interface (i.e. a SurfPhase or an EdgePhase)
bool is_sticking_coefficient
Set to true if rate is a parameterization of the sticking coefficient rather than the forward rate co...
std::map< std::string, CoverageDependency > coverage_deps
Adjustments to the Arrhenius rate expression dependent on surface species coverages.
std::string sticking_species
For reactions with multiple non-surface species, the sticking species needs to be explicitly identifi...
bool use_motz_wise_correction
Set to true if rate is a sticking coefficient which should be translated into a rate coefficient usin...
size_t reactionPhaseIndex() const
Phase where the reactions occur.
void checkPhaseIndex(size_t m) const
Check that the specified phase index is in range Throws an exception if m is greater than nPhases()
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...
ValueCache m_cache
Cache for saved calculations within each Kinetics object.
vector_fp m_ropnet
Net rate-of-progress for each reaction.
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
doublereal multiplier(size_t i) const
The current value of the multiplier for reaction i.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
vector_fp m_ropf
Forward rate-of-progress for each reaction.
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_ropr
Reverse rate-of-progress for each reaction.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
std::vector< thermo_t * > m_thermo
m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
size_t nReactions() const
Number of reactions 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.
vector_fp m_rfn
Forward rate constant for each reaction.
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
size_t surfacePhaseIndex() const
This returns the integer index of the phase which has ThermoPhase type cSurf.
virtual void resizeSpecies()
Resize arrays with sizes that depend on the total number of species.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
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...
void getConcentrations(double *const c) const
Get the species concentrations (kmol/m^3).
size_t nSpecies() const
Returns the number of species in the phase.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
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.
Composition orders
Forward reaction order with respect to specific species.
bool reversible
True if the current reaction is reversible. False otherwise.
Composition products
Product species and stoichiometric coefficients.
Composition reactants
Reactant species and stoichiometric coefficients.
int reaction_type
Type of the reaction.
std::string equation() const
The chemical equation for this reaction.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
virtual double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.
doublereal siteDensity()
Returns the site density.
An Arrhenius rate with coverage-dependent terms.
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,...
Base class for a phase with thermodynamic properties.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
void setElectricPotential(doublereal v)
Set the electric potential of this phase (V).
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
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.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
doublereal electricPotential() const
Returns the electric potential of this phase (V).
CachedArray getArray(int id)
Get a reference to a CachedValue object representing an array (vector_fp) with the given id.
int getId()
Get a unique id for a cached value.
const size_t npos
index returned by functions to indicate "no position"
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].
Namespace for the Cantera kernel.
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.
const int BUTLERVOLMER_NOACTIVITYCOEFFS_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation and using concentra...
const int BUTLERVOLMER_RXN
This is a surface reaction that is formulated using the Butler-Volmer formulation.
const int GLOBAL_RXN
A global reaction.
const int SURFACEAFFINITY_RXN
This is a surface reaction that is formulated using the affinity representation, common in the geoche...
Values used for converting sticking coefficients into rate constants.