12#ifndef CD_KMCSingleStateReactionImplem_H
13#define CD_KMCSingleStateReactionImplem_H
20#include <CD_NamespaceHeader.H>
22template <
typename State,
typename T>
26 CH_TIME(
"KMCSingleStateReaction::KMCSingleStateReaction");
31 this->computeStateChanges();
34template <
typename State,
typename T>
37 CH_TIME(
"KMCSingleStateReaction::~KMCSingleStateReaction");
40template <
typename State,
typename T>
44 CH_TIME(
"KMCSingleStateReaction::computeStateChanges");
47 for (
const auto&
r : m_reactants) {
48 if (m_stateChange.find(
r) == m_stateChange.end()) {
49 m_stateChange.emplace(
r, -1);
57 for (
const auto& p : m_products) {
58 if (m_stateChange.find(p) == m_stateChange.end()) {
59 m_stateChange.emplace(p, +1);
79 m_propensityFactor = 1.0;
82 for (
const auto&
r : m_reactants) {
92 m_propensityFactor *= 1.0 / factorial(
rn.second);
96template <
typename State,
typename T>
103template <
typename State,
typename T>
110template <
typename State,
typename T>
114 CH_TIME(
"KMCSingleStateReaction::propensity");
116 Real A = m_rate * m_propensityFactor;
120 for (
const auto&
r : m_reactants) {
129template <
typename State,
typename T>
133 CH_TIME(
"KMCSingleStateReaction::computeCriticalNumberOfReactions");
135 T
Lj = std::numeric_limits<T>::max();
137 for (
const auto&
s : m_stateChange) {
139 const size_t rI =
s.first;
140 const T
nuIJ =
s.second;
150template <
typename State,
typename T>
157template <
typename State,
typename T>
161 CH_TIME(
"KMCSingleStateReaction::getStateChange");
172template <
typename State,
typename T>
176 CH_TIME(
"KMCSingleStateReaction::advanceState");
178 for (
const auto&
s : m_stateChange) {
183#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:152
virtual ~KMCSingleStateReaction()
Destructor.
Definition CD_KMCSingleStateReactionImplem.H:35
Real propensity(const State &a_state) const noexcept
Compute the propensity function for this reaction type.
Definition CD_KMCSingleStateReactionImplem.H:112
T getStateChange(const size_t a_reactant) const noexcept
Get the state change due to a change in the input reactant species.
Definition CD_KMCSingleStateReactionImplem.H:159
void computeStateChanges() noexcept
Compute state change.
Definition CD_KMCSingleStateReactionImplem.H:42
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:105
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:131
void advanceState(State &a_state, const T &a_numReactions) const noexcept
Advance the incoming state with the number of reactions.
Definition CD_KMCSingleStateReactionImplem.H:174
KMCSingleStateReaction()=default
Disallowed constructor. Use the full constructor.
Real & rate() const noexcept
Get modifiable reaction rate.
Definition CD_KMCSingleStateReactionImplem.H:98
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:25