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()
50 InterfaceKinetics& InterfaceKinetics::operator=(
const InterfaceKinetics& right)
62 m_redo_rates = right.m_redo_rates;
82 m_ROP_ok = right.m_ROP_ok;
93 m_ioFlag = right.m_ioFlag;
101 "To be removed after Cantera 2.3.");
102 return cInterfaceKinetics;
131 if (T !=
m_temp || m_redo_rates) {
136 applyStickingCorrection(T,
m_rfn.data());
149 m_redo_rates =
false;
156 for (
size_t n = 0; n <
nPhases(); n++) {
166 for (
size_t n = 0; n <
nPhases(); n++) {
200 doublereal rrt = 1.0 /
thermo(0).
RT();
205 for (
size_t i = 0; i <
m_revindex.size(); i++) {
208 throw CanteraError(
"InterfaceKinetics",
"illegal value: irxn = {}", irxn);
213 for (
size_t i = 0; i !=
m_irrev.size(); ++i) {
226 for (
size_t n = 0; n <
nPhases(); n++) {
239 "To be removed after Cantera 2.3.");
249 for (
size_t n = 0; n <
nPhases(); n++) {
252 for (
size_t k = 0; k < nsp; k++) {
262 for (
size_t i = 0; i <
m_revindex.size(); i++) {
266 writelogf(
"%12.6e %12.6e %12.6e %12.6e \n",
276 doublereal rrt = 1.0 /
thermo(0).
RT();
280 kc[i] = exp(-kc[i]*rrt);
298 for (
size_t n = 0; n <
nPhases(); n++) {
301 for (
size_t k = 0; k < nsp; k++) {
320 for (
size_t n = 0; n <
nPhases(); n++) {
322 for (
size_t k = 0; k < nsp; k++) {
339 for (
size_t i = 0; i <
m_beta.size(); i++) {
347 kf[irxn] *= exp(-eamod/
thermo(0).RT());
358 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
364 if (iECDFormulation) {
410 if (doIrreversible) {
465 for (
size_t p = 0; p <
nPhases(); p++) {
470 for (
size_t rp = 0; rp <
nPhases(); rp++) {
484 for (
size_t p = 0; p <
nPhases(); p++) {
489 for (
size_t rp = 0; rp <
nPhases(); rp++) {
512 for (
size_t n = 0; n <
nPhases(); n++) {
518 if (deltaG != 0 && (
m_deltaG.data() != deltaG)) {
528 for (
size_t n = 0; n <
nPhases(); n++) {
539 for (
size_t n = 0; n <
nPhases(); n++) {
550 for (
size_t n = 0; n <
nPhases(); n++) {
564 for (
size_t n = 0; n <
nPhases(); n++) {
578 for (
size_t n = 0; n <
nPhases(); n++) {
581 for (
size_t k = 0; k <
m_kk; k++) {
594 for (
size_t n = 0; n <
nPhases(); n++) {
597 for (
size_t k = 0; k <
m_kk; k++) {
627 if (re->exchange_current_density_formulation) {
649 for (
const auto& order : r.
orders) {
657 "film resistivity set for elementary reaction");
707 size_t iInterface =
npos;
709 for (
size_t n = 0; n <
nPhases(); n++) {
717 if (sticking_species ==
"") {
719 bool foundStick =
false;
722 if (iPhase != iInterface) {
726 "Multiple non-interface species found" 727 "in sticking reaction: '" + r.
equation() +
"'");
730 sticking_species = sp.first;
735 "No non-interface species found" 736 "in sticking reaction: '" + r.
equation() +
"'");
740 double surface_order = 0.0;
748 if (sp.first == sticking_species) {
760 surface_order += order;
773 if (item.index == i) {
774 item.order = surface_order;
790 rate.addCoverageDependence(k, sp.second.a, sp.second.m, sp.second.E);
795 void InterfaceKinetics::setIOFlag(
int ioFlag)
814 "no surface phase is present.");
820 "expected interface dimension = 2, but got dimension = {}",
830 throw CanteraError(
"InterfaceKinetics::resizeSpecies",
"Cannot add" 831 " species to InterfaceKinetics after reactions have been added.");
846 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
857 vector<InterfaceKinetics*> k{
this};
867 int ifuncOverride, doublereal timeScaleOverride)
871 vector<InterfaceKinetics*> k{
this};
883 throw CanteraError(
"InterfaceKinetics:setPhaseExistence",
"out of bounds");
904 throw CanteraError(
"InterfaceKinetics:phaseExistence()",
"out of bounds");
912 throw CanteraError(
"InterfaceKinetics:phaseStability()",
"out of bounds");
920 throw CanteraError(
"InterfaceKinetics:setPhaseStability",
"out of bounds");
934 for (
const auto& order : r.
orders) {
939 double betaf = r.
beta;
945 fwdFullOrders[k] += betaf * sp.second;
947 if (abs(fwdFullOrders[k]) < 0.00001) {
948 fwdFullOrders[k] = 0.0;
956 fwdFullOrders[k] -= betaf * sp.second;
958 if (abs(fwdFullOrders[k]) < 0.00001) {
959 fwdFullOrders[k] = 0.0;
964 void InterfaceKinetics::applyStickingCorrection(
double T,
double* kf)
975 double n0 = surf.siteDensity();
976 if (!cached.validate(n0)) {
985 if (item.use_motz_wise) {
986 kf[item.index] /= 1 - 0.5 * kf[item.index];
988 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.
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.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
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.
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
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...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
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.
A kinetics manager for heterogeneous reaction mechanisms.
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) ...
virtual void assignShallowPointers(const std::vector< thermo_t *> &tpVector)
Reassign the pointers within the Kinetics object.
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).
Public interface for kinetics managers.
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.
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.
std::string reactionString(size_t i) const
Return a string representing the reaction.
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...
const U & getValue(const std::map< T, U > &m, const T &key)
Const accessor for a value in a std::map.
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...
Kinetics & operator=(const Kinetics &right)
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.
void writelogf(const char *fmt, const Args &... args)
Write a formatted message to the screen.
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.
InterfaceKinetics(thermo_t *thermo=0)
Constructor.
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)
doublereal size(size_t k) const
This routine returns the size of species k.
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.
virtual int type() const
Identifies the kinetics manager type.
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...
virtual Kinetics * duplMyselfAsKinetics(const std::vector< thermo_t *> &tpVector) const
Duplication routine for objects which inherit from Kinetics.
std::string equation() const
The chemical equation for this reaction.