13#ifndef CD_KMCSINGLESTATEREACTIONIMPLEM_H
14#define CD_KMCSINGLESTATEREACTIONIMPLEM_H
21#include <CD_NamespaceHeader.H>
23template <
typename State,
typename T>
28 CH_TIME(
"KMCSingleStateReaction::KMCSingleStateReaction");
30 this->computeStateChanges();
33template <
typename State,
typename T>
36 CH_TIME(
"KMCSingleStateReaction::~KMCSingleStateReaction");
39template <
typename State,
typename T>
43 CH_TIME(
"KMCSingleStateReaction::computeStateChanges");
46 for (
const auto&
r : m_reactants) {
47 if (m_stateChange.find(
r) == m_stateChange.end()) {
48 m_stateChange.emplace(
r, -1);
56 for (
const auto& p : m_products) {
57 if (m_stateChange.find(p) == m_stateChange.end()) {
58 m_stateChange.emplace(p, +1);
78 m_propensityFactor = 1.0;
81 for (
const auto&
r : m_reactants) {
91 m_propensityFactor *= 1.0 / factorial(
rn.second);
95template <
typename State,
typename T>
102template <
typename State,
typename T>
109template <
typename State,
typename T>
113 CH_TIME(
"KMCSingleStateReaction::propensity");
115 Real A = m_rate * m_propensityFactor;
119 for (
const auto&
r : m_reactants) {
128template <
typename State,
typename T>
132 CH_TIME(
"KMCSingleStateReaction::computeCriticalNumberOfReactions");
134 T Lj = std::numeric_limits<T>::max();
136 for (
const auto&
s : m_stateChange) {
138 const size_t rI =
s.first;
149template <
typename State,
typename T>
156template <
typename State,
typename T>
160 CH_TIME(
"KMCSingleStateReaction::getStateChange");
171template <
typename State,
typename T>
175 CH_TIME(
"KMCSingleStateReaction::advanceState");
177 for (
const auto&
s : m_stateChange) {
182#include <CD_NamespaceFooter.H>
Declaration of a simple reaction type for advancing "single states" in Kinetic Monte Carlo codes.
std::list< size_t > getReactants() const noexcept
Get the reactants involved in the reaction.
Definition CD_KMCSingleStateReactionImplem.H:151
virtual ~KMCSingleStateReaction()
Destructor.
Definition CD_KMCSingleStateReactionImplem.H:34
Real propensity(const State &a_state) const noexcept
Compute the propensity function for this reaction type.
Definition CD_KMCSingleStateReactionImplem.H:111
T getStateChange(const size_t a_particleReactant) const noexcept
Get the state change due to a change in the input reactant species.
Definition CD_KMCSingleStateReactionImplem.H:158
void computeStateChanges() noexcept
Compute state change vectors from the reactant/product lists.
Definition CD_KMCSingleStateReactionImplem.H:41
static T population(const size_t &a_reactant, const State &a_state) noexcept
Get the population of the reactant in the input state.
Definition CD_KMCSingleStateReactionImplem.H:104
T computeCriticalNumberOfReactions(const State &a_state) const noexcept
Compute the number of times the reaction can fire before exhausting one of the reactants.
Definition CD_KMCSingleStateReactionImplem.H:130
void advanceState(State &a_state, const T &a_numReactions) const noexcept
Advance the incoming state with the number of reactions.
Definition CD_KMCSingleStateReactionImplem.H:173
KMCSingleStateReaction()=default
Default constructor.
Real & rate() const noexcept
Get modifiable reaction rate.
Definition CD_KMCSingleStateReactionImplem.H:97
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26