[Kinetics] Basic implementation of class Reaction and descendants
This commit is contained in:
parent
82dca88af2
commit
c0944f1700
5 changed files with 341 additions and 0 deletions
|
|
@ -160,6 +160,11 @@ const doublereal Tiny = 1.e-20;
|
|||
* to species.
|
||||
*/
|
||||
typedef std::map<std::string, doublereal> compositionMap;
|
||||
|
||||
//! Map from string names to doubles. Used for defining species mole/mass
|
||||
//! fractions, elemental compositions, and reaction stoichiometries.
|
||||
typedef std::map<std::string, doublereal> Composition;
|
||||
|
||||
//! Turn on the use of stl vectors for the basic array type within cantera
|
||||
//! Vector of doubles.
|
||||
typedef std::vector<double> vector_fp;
|
||||
|
|
|
|||
216
include/cantera/kinetics/Reaction.h
Normal file
216
include/cantera/kinetics/Reaction.h
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
/**
|
||||
* @file Reaction.h
|
||||
*/
|
||||
|
||||
#ifndef CT_REACTION_H
|
||||
#define CT_REACTION_H
|
||||
|
||||
#include "cantera/base/utilities.h"
|
||||
#include "cantera/kinetics/RxnRates.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class Kinetics;
|
||||
|
||||
//! Intermediate class which stores data about a reaction and its rate
|
||||
//! parameterization so that it can be added to a Kinetics object.
|
||||
class Reaction
|
||||
{
|
||||
public:
|
||||
Reaction(int type, const Composition& reactants,
|
||||
const Composition& products);
|
||||
virtual ~Reaction() {}
|
||||
|
||||
friend class Kinetics;
|
||||
|
||||
virtual std::string reactantString() { return ""; } //!< @todo: implement
|
||||
virtual std::string productString() { return ""; } //!< @todo: implement
|
||||
std::string equation() { return ""; } //!< @todo: implement
|
||||
|
||||
//! Type of the reaction. The valid types are listed in the file,
|
||||
//! reaction_defs.h, with constants ending in `RXN`.
|
||||
int reaction_type;
|
||||
|
||||
//! Reactant species and stoichiometric coefficients
|
||||
Composition reactants;
|
||||
|
||||
//! Product species and stoichiometric coefficients
|
||||
Composition products;
|
||||
|
||||
//! Forward reaction order with respect to specific species. By default,
|
||||
//! mass-action kinetics is assumed, with the reaction order equal to each
|
||||
//! reactant's stoichiometric coefficient.
|
||||
Composition orders;
|
||||
|
||||
//! An identification string for the reaction, used in some filtering
|
||||
//! operations
|
||||
std::string id;
|
||||
|
||||
//! True if the current reaction is reversible. False otherwise
|
||||
bool reversible;
|
||||
|
||||
bool validate; //!< Perform validation of the rate coefficient data
|
||||
|
||||
//! True if the current reaction is marked as duplicate
|
||||
bool duplicate;
|
||||
};
|
||||
|
||||
|
||||
//! A reaction which follows mass-action kinetics with a modified Arrhenius
|
||||
//! reaction rate.
|
||||
class ElementaryReaction : public Reaction
|
||||
{
|
||||
public:
|
||||
ElementaryReaction(const Composition& reactants, const Composition products,
|
||||
const Arrhenius& rate);
|
||||
|
||||
Arrhenius rate;
|
||||
};
|
||||
|
||||
//! A class for managing third-body efficiencies, including default values
|
||||
class ThirdBody
|
||||
{
|
||||
public:
|
||||
explicit ThirdBody(double default_efficiency=1.0);
|
||||
|
||||
//! Get the third-body efficiency for species *k*
|
||||
double efficiency(const std::string& k) const {
|
||||
return getValue(efficiencies, k, default_efficiency);
|
||||
}
|
||||
|
||||
//! Map of species to third body efficiency
|
||||
Composition efficiencies;
|
||||
|
||||
//! The default third body efficiency for species not listed in
|
||||
//! #third_body_efficiencies.
|
||||
double default_efficiency;
|
||||
};
|
||||
|
||||
|
||||
class ThirdBodyReaction : public ElementaryReaction
|
||||
{
|
||||
public:
|
||||
ThirdBodyReaction(const Composition& reactants, const Composition& products,
|
||||
const Arrhenius& rate, const ThirdBody& tbody);
|
||||
virtual std::string reactantString();
|
||||
virtual std::string productString();
|
||||
|
||||
ThirdBody third_body;
|
||||
};
|
||||
|
||||
|
||||
class FalloffReaction : public Reaction
|
||||
{
|
||||
public:
|
||||
FalloffReaction(const Composition& reactants, const Composition& products,
|
||||
const Arrhenius& low_rate, const Arrhenius& high_rate,
|
||||
const ThirdBody& tbody, int falloff_type,
|
||||
const vector_fp& falloff_params);
|
||||
virtual std::string reactantString();
|
||||
virtual std::string productString();
|
||||
|
||||
Arrhenius low_rate;
|
||||
Arrhenius high_rate;
|
||||
ThirdBody third_body;
|
||||
|
||||
//! Type of falloff parameterization to use. Values are defined in
|
||||
//! reaction_defs.h, with names ending in `FALLOFF`.
|
||||
int falloff_type;
|
||||
|
||||
//! Values used in the falloff parameterization. Meaning of each parameter
|
||||
//! depends on #falloff_type.
|
||||
vector_fp falloff_parameters;
|
||||
};
|
||||
|
||||
|
||||
class ChemicallyActivatedReaction : public FalloffReaction
|
||||
{
|
||||
public:
|
||||
ChemicallyActivatedReaction(const Composition& reactants,
|
||||
const Composition& products, const Arrhenius& low_rate,
|
||||
const Arrhenius& high_rate, const ThirdBody& tbody, int falloff_type,
|
||||
const vector_fp& falloff_params);
|
||||
};
|
||||
|
||||
|
||||
class PlogReaction : public Reaction
|
||||
{
|
||||
public:
|
||||
PlogReaction(const Composition& reactants, const Composition& products,
|
||||
const Plog& rate);
|
||||
|
||||
Plog rate;
|
||||
};
|
||||
|
||||
|
||||
class ChebyshevReaction : public Reaction
|
||||
{
|
||||
public:
|
||||
ChebyshevReaction(const Composition& reactants, const Composition& products,
|
||||
const ChebyshevRate& rate);
|
||||
|
||||
ChebyshevRate rate;
|
||||
};
|
||||
|
||||
|
||||
struct CoverageDependency
|
||||
{
|
||||
CoverageDependency(double a_, double E_, double m_) : a(a_), E(E_), m(m_) {}
|
||||
CoverageDependency() {}
|
||||
double a;
|
||||
double E;
|
||||
double m;
|
||||
};
|
||||
|
||||
|
||||
class InterfaceReaction : public Reaction
|
||||
{
|
||||
public:
|
||||
InterfaceReaction(const Composition& reactants, const Composition& products,
|
||||
const Arrhenius& rate);
|
||||
|
||||
//! Adjustments to the Arrhenius rate expression dependent on surface
|
||||
//! species coverages. Three coverage parameters (a, E, m) are used for each
|
||||
//! species on which the rate depends. See SurfaceArrhenius for details on
|
||||
//! the parameterization.
|
||||
std::map<std::string, CoverageDependency> coverage_deps;
|
||||
|
||||
//! The rate coefficient, without taking into account the coverage
|
||||
//! dependencies.
|
||||
Arrhenius rate;
|
||||
};
|
||||
|
||||
|
||||
class ElectrochemicalReaction : public InterfaceReaction
|
||||
{
|
||||
public:
|
||||
ElectrochemicalReaction(const Composition& reactants,
|
||||
const Composition& products, const Arrhenius& rate);
|
||||
|
||||
//! Film Resistivity value
|
||||
/*!
|
||||
* Only valid for Butler-Volmer formulations. Units are in ohms m2.
|
||||
* Default = 0.0 ohms m2.
|
||||
*/
|
||||
doublereal film_resistivity;
|
||||
|
||||
//! Power of the equilibrium constant within the Affinity representation
|
||||
/*!
|
||||
* Only valid for Affinity representation. Default = 1.0.
|
||||
*/
|
||||
doublereal equilibrium_constant_power;
|
||||
|
||||
//! Power of the "One minus Affinity" term within the Affinity representation
|
||||
/*!
|
||||
* Only valid for Affinity representation. Default = 1.0.
|
||||
*/
|
||||
doublereal affinity_power;
|
||||
|
||||
//! Forward value of the apparent Electrochemical transfer coefficient
|
||||
doublereal beta;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,6 +16,8 @@ namespace Cantera
|
|||
//! parameterization before adding the reaction to a Kinetics object.
|
||||
/*!
|
||||
* All data in this class is public.
|
||||
* @deprecated Use class Reaction and its children. To be removed after
|
||||
* Cantera 2.2.
|
||||
*/
|
||||
class ReactionData
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ const int CHEMACT_RXN = 8;
|
|||
*/
|
||||
const int SURFACE_RXN = 20;
|
||||
|
||||
//! A reaction occurring on an interface, e.g a surface or edge.
|
||||
const int INTERFACE_RXN = 20;
|
||||
|
||||
//! This is a surface reaction that is formulated using the Butler-Volmer
|
||||
//! formulation and using concentrations instead of activity concentrations
|
||||
//! for its exchange current density formulat.
|
||||
|
|
|
|||
115
src/kinetics/Reaction.cpp
Normal file
115
src/kinetics/Reaction.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#include "cantera/kinetics/Reaction.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
Reaction::Reaction(int type, const Composition& reactants_,
|
||||
const Composition& products_)
|
||||
: reaction_type(type)
|
||||
, reactants(reactants_)
|
||||
, products(products_)
|
||||
, reversible(true)
|
||||
, validate(true)
|
||||
, duplicate(false)
|
||||
{
|
||||
}
|
||||
|
||||
ElementaryReaction::ElementaryReaction(const Composition& reactants_,
|
||||
const Composition products_,
|
||||
const Arrhenius& rate_)
|
||||
: Reaction(ELEMENTARY_RXN, reactants_, products_)
|
||||
, rate(rate_)
|
||||
{
|
||||
}
|
||||
|
||||
ThirdBody::ThirdBody(double default_eff)
|
||||
: default_efficiency(default_eff)
|
||||
{
|
||||
}
|
||||
|
||||
ThirdBodyReaction::ThirdBodyReaction(const Composition& reactants_,
|
||||
const Composition& products_,
|
||||
const Arrhenius& rate_,
|
||||
const ThirdBody& tbody)
|
||||
: ElementaryReaction(reactants_, products_, rate_)
|
||||
, third_body(tbody)
|
||||
{
|
||||
reaction_type = THREE_BODY_RXN;
|
||||
}
|
||||
|
||||
std::string ThirdBodyReaction::reactantString() {
|
||||
return ElementaryReaction::reactantString() + " + M";
|
||||
}
|
||||
|
||||
std::string ThirdBodyReaction::productString() {
|
||||
return ElementaryReaction::productString() + " + M";
|
||||
}
|
||||
|
||||
FalloffReaction::FalloffReaction(
|
||||
const Composition& reactants_, const Composition& products_,
|
||||
const Arrhenius& low_rate_, const Arrhenius& high_rate_,
|
||||
const ThirdBody& tbody, int type,
|
||||
const vector_fp& params)
|
||||
: Reaction(FALLOFF_RXN, reactants_, products_)
|
||||
, low_rate(low_rate_)
|
||||
, high_rate(high_rate_)
|
||||
, third_body(tbody)
|
||||
, falloff_type(type)
|
||||
, falloff_parameters(params)
|
||||
{
|
||||
}
|
||||
|
||||
std::string FalloffReaction::reactantString() {
|
||||
return Reaction::reactantString() + " (+M)";
|
||||
}
|
||||
|
||||
std::string FalloffReaction::productString() {
|
||||
return Reaction::productString() + " (+M)";
|
||||
}
|
||||
|
||||
ChemicallyActivatedReaction::ChemicallyActivatedReaction(
|
||||
const Composition& reactants_, const Composition& products_,
|
||||
const Arrhenius& low_rate_, const Arrhenius& high_rate_,
|
||||
const ThirdBody& tbody, int falloff_type,
|
||||
const vector_fp& falloff_params)
|
||||
: FalloffReaction(reactants_, products_, low_rate, high_rate, tbody,
|
||||
falloff_type, falloff_params)
|
||||
{
|
||||
reaction_type = CHEMACT_RXN;
|
||||
}
|
||||
|
||||
PlogReaction::PlogReaction(const Composition& reactants_,
|
||||
const Composition& products_, const Plog& rate_)
|
||||
: Reaction(PLOG_RXN, reactants_, products_)
|
||||
, rate(rate_)
|
||||
{
|
||||
}
|
||||
|
||||
ChebyshevReaction::ChebyshevReaction(const Composition& reactants_,
|
||||
const Composition& products_,
|
||||
const ChebyshevRate& rate_)
|
||||
: Reaction(CHEBYSHEV_RXN, reactants_, products_)
|
||||
, rate(rate_)
|
||||
{
|
||||
}
|
||||
|
||||
InterfaceReaction::InterfaceReaction(const Composition& reactants_,
|
||||
const Composition& products_,
|
||||
const Arrhenius& rate_)
|
||||
: Reaction(INTERFACE_RXN, reactants_, products_)
|
||||
, rate(rate_)
|
||||
{
|
||||
}
|
||||
|
||||
ElectrochemicalReaction::ElectrochemicalReaction(const Composition& reactants_,
|
||||
const Composition& products_,
|
||||
const Arrhenius& rate_)
|
||||
: InterfaceReaction(reactants_, products_, rate_)
|
||||
, film_resistivity(0.0)
|
||||
, equilibrium_constant_power(1.0)
|
||||
, affinity_power(1.0)
|
||||
, beta(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue