27 m_has_coverage_dependence(false),
28 m_has_electrochem_rxns(false),
29 m_has_exchange_current_density_formulation(false),
30 m_phaseExistsCheck(false),
39InterfaceKinetics::~InterfaceKinetics()
75 if (T !=
m_temp || m_redo_rates) {
80 for (
size_t n = 0; n <
nPhases(); n++) {
86 applyStickingCorrection(T,
m_rfn.data());
105 rates->getRateConstants(
m_rfn.data());
119 for (
size_t n = 0; n <
nPhases(); n++) {
129 for (
size_t n = 0; n <
nPhases(); n++) {
168 for (
size_t i = 0; i <
m_revindex.size(); i++) {
172 "illegal value: irxn = {}", irxn);
177 for (
size_t i = 0; i !=
m_irrev.size(); ++i) {
192 for (
size_t n = 0; n <
nPhases(); n++) {
210 kc[i] = exp(-kc[i]*rrt);
228 for (
size_t n = 0; n <
nPhases(); n++) {
231 for (
size_t k = 0; k < nsp; k++) {
250 for (
size_t n = 0; n <
nPhases(); n++) {
252 for (
size_t k = 0; k < nsp; k++) {
269 for (
size_t i = 0; i <
m_beta.size(); i++) {
285 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
291 if (iECDFormulation) {
314 if (doIrreversible) {
365 for (
size_t p = 0; p <
nPhases(); p++) {
370 for (
size_t rp = 0; rp <
nPhases(); rp++) {
384 for (
size_t p = 0; p <
nPhases(); p++) {
389 for (
size_t rp = 0; rp <
nPhases(); rp++) {
412 for (
size_t n = 0; n <
nPhases(); n++) {
418 if (deltaG != 0 && (
m_deltaG.data() != deltaG)) {
428 for (
size_t n = 0; n <
nPhases(); n++) {
439 for (
size_t n = 0; n <
nPhases(); n++) {
450 for (
size_t n = 0; n <
nPhases(); n++) {
464 for (
size_t n = 0; n <
nPhases(); n++) {
478 for (
size_t n = 0; n <
nPhases(); n++) {
481 for (
size_t k = 0; k <
m_kk; k++) {
494 for (
size_t n = 0; n <
nPhases(); n++) {
497 for (
size_t k = 0; k <
m_kk; k++) {
517 if (r_base->reversible) {
526 for (
const auto& sp : r_base->reactants) {
531 for (
const auto& sp : r_base->products) {
537 if (!(r_base->usesLegacy())) {
539 shared_ptr<ReactionRate> rate = r_base->rate();
541 rate->setContext(*r_base, *
this);
568 if (re->exchange_current_density_formulation) {
589 if (!(r_base->usesLegacy())) {
590 shared_ptr<ReactionRate> rate = r_base->rate();
591 rate->setRateIndex(i);
592 rate->setContext(*r_base, *
this);
594 const auto& rtype = rate->type();
598 "Interface evaluator not available for type '{}'.", rtype);
621 size_t iInterface =
npos;
623 for (
size_t n = 0; n <
nPhases(); n++) {
631 if (sticking_species ==
"") {
633 bool foundStick =
false;
636 if (iPhase != iInterface) {
640 r.
input,
"Multiple non-interface species ('{}' and '{}')\n"
641 "found in sticking reaction: '{}'.\nSticking species "
642 "must be explicitly specified.",
643 sticking_species, sp.first, r.
equation());
646 sticking_species = sp.first;
651 r.
input,
"No non-interface species found "
652 "in sticking reaction: '{}'", r.
equation());
656 double surface_order = 0.0;
663 if (sp.first == sticking_species) {
675 surface_order += order;
688 if (item.index == i) {
689 item.order = surface_order;
710void InterfaceKinetics::setIOFlag(
int ioFlag)
730 "no surface phase is present.");
737 "expected interface dimension = 2, but got dimension = {}",
747 throw CanteraError(
"InterfaceKinetics::resizeSpecies",
"Cannot add"
748 " species to InterfaceKinetics after reactions have been added.");
764 "This function only works for the legacy framework. "
765 "To be removed after Cantera 2.6.");
767 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
776 doublereal atol, doublereal maxStepSize,
777 size_t maxSteps,
size_t maxErrTestFails)
780 vector<InterfaceKinetics*> k{
this};
793 int ifuncOverride, doublereal timeScaleOverride)
797 vector<InterfaceKinetics*> k{
this};
847void InterfaceKinetics::applyStickingCorrection(
double T,
double* kf)
858 if (!cached.validate(n0)) {
867 if (item.use_motz_wise) {
868 kf[item.index] /= 1 - 0.5 * kf[item.index];
870 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 activationEnergy_R() const
Return the activation energy divided by the gas constant (that is, the activation temperature) [K].
virtual double temperatureExponent() const
Return the temperature exponent b
virtual 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.
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 resizeReactions()
Finalize Kinetics object and associated objects.
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.
SurfaceArrhenius buildSurfaceArrhenius(size_t i, InterfaceReaction2 &r, bool replace)
Build a SurfaceArrhenius object from a Reaction, taking into account the possible sticking coefficien...
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< unique_ptr< MultiRateBase > > m_interfaceRates
Vector of rate handlers for interface reactions.
virtual void addPhase(ThermoPhase &thermo)
Add a phase to the kinetics manager object.
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.
virtual bool addReaction(shared_ptr< Reaction > r, bool resize=true)
Add a single reaction to the mechanism.
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.
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.
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.
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.
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.
InterfaceKinetics(ThermoPhase *thermo=0)
Constructor.
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.
std::map< std::string, size_t > m_interfaceTypes
Rate handler mapping.
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.
A reaction occurring on an interface (for example, 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.
virtual void resizeReactions()
Finalize Kinetics object and associated objects.
void checkPhaseIndex(size_t m) const
Check that the specified phase index is in range Throws an exception if m is greater than nPhases()
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
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.
virtual void getRevReactionDelta(const double *g, double *dg) const
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 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.
virtual void getReactionDelta(const double *property, double *deltaProperty) const
Change in species properties.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
virtual void addPhase(ThermoPhase &thermo)
Add a phase to the kinetics manager object.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
vector_fp m_ropf
Forward rate-of-progress for each reaction.
vector_fp m_dH
The enthalpy change for each reaction to calculate Blowers-Masel rates.
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
virtual bool addReaction(shared_ptr< Reaction > r, bool resize=true)
Add a single reaction to the mechanism.
std::vector< ThermoPhase * > 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.
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.
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.
Composition reactants
Reactant species and stoichiometric coefficients.
AnyMap input
Input data used for specific models.
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.
double siteDensity() const
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.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double Faraday
Faraday constant [C/kmol].
const int SURFACE_RXN
A reaction occurring on a surface.
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
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].
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.
Values used for converting sticking coefficients into rate constants.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...