chombo-discharge
Loading...
Searching...
No Matches
CD_KMCDualStateReaction.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_KMCDUALSTATEREACTION_H
14#define CD_KMCDUALSTATEREACTION_H
15
16// Std includes
17#include <map>
18#include <vector>
19#include <list>
20
21// Chombo includes
22#include <REAL.H>
23
24// Our includes
25#include <CD_KMCDualState.H>
26#include <CD_NamespaceHeader.H>
27
32template <typename State = KMCDualState<long long>, typename T = long long>
34{
35public:
40
45
53 inline KMCDualStateReaction(const std::list<size_t>& a_lhsReactives,
54 const std::list<size_t>& a_rhsReactives,
55 const std::list<size_t>& a_rhsNonReactives) noexcept;
56
60 inline virtual ~KMCDualStateReaction();
61
66 inline Real&
67 rate() const noexcept;
68
75 inline static T
76 population(const size_t& a_reactant, const State& a_state) noexcept;
77
84 inline Real
85 propensity(const State& a_state) const noexcept;
86
92 inline T
93 computeCriticalNumberOfReactions(const State& a_state) const noexcept;
94
102 inline const std::list<size_t>&
103 getReactants() const noexcept;
104
113 inline const std::list<size_t>&
114 getReactiveProducts() const noexcept;
115
121 inline const std::list<size_t>&
122 getNonReactiveProducts() const noexcept;
123
129 inline T
130 getStateChange(const size_t a_reactant) const noexcept;
131
137 inline void
138 advanceState(State& a_state, const T& a_numReactions) const noexcept;
139
140protected:
144 mutable Real m_rate;
145
152
156 std::list<size_t> m_lhsReactives;
157
161 std::list<size_t> m_rhsReactives;
162
166 std::list<size_t> m_rhsNonReactives;
167
171 std::map<size_t, T> m_reactiveStateChange;
172
184
192 std::vector<std::pair<size_t, size_t>> m_lhsOrders;
193
197 std::map<size_t, T> m_nonReactiveStateChange;
198
202 inline void
203 computeStateChanges() noexcept;
204
212 inline void
213 sanityCheck(const State& a_state) const noexcept;
214};
215
216#include <CD_NamespaceFooter.H>
217
219
220#endif
Implementation of CD_KMCDualStateReaction.H.
Declaration of a simple state vector for running Kinetic Monte Carlo for plasma problems.
Reaction type for advancing a KMCDualState for Kinetic Monte Carlo.
Definition CD_KMCDualStateReaction.H:34
const std::list< size_t > & getReactiveProducts() const noexcept
Get the products from the reaction.
Definition CD_KMCDualStateReactionImplem.H:224
T getStateChange(const size_t a_reactant) const noexcept
Get the state change due to a change in the input reactant.
Definition CD_KMCDualStateReactionImplem.H:238
void sanityCheck(const State &a_state) const noexcept
Debugging function which ensures that the class data holders do not reach out of the incoming state.
Definition CD_KMCDualStateReactionImplem.H:276
void computeStateChanges() noexcept
Compute state change vectors from the reactant/product lists.
Definition CD_KMCDualStateReactionImplem.H:46
std::list< size_t > m_lhsReactives
Reactive species (left-hand side).
Definition CD_KMCDualStateReaction.H:156
std::map< size_t, T > m_reactiveStateChange
State change for reactants/products.
Definition CD_KMCDualStateReaction.H:171
KMCDualStateReaction()=default
Default constructor.
virtual ~KMCDualStateReaction()
Destructor.
Definition CD_KMCDualStateReactionImplem.H:41
Real propensity(const State &a_state) const noexcept
Compute the propensity function for this reaction type.
Definition CD_KMCDualStateReactionImplem.H:163
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_KMCDualStateReactionImplem.H:192
std::list< size_t > m_rhsReactives
Product species (right-hand side reactive).
Definition CD_KMCDualStateReaction.H:161
std::map< size_t, T > m_nonReactiveStateChange
State change for non-reactive products.
Definition CD_KMCDualStateReaction.H:197
Real & rate() const noexcept
Get modifiable reaction rate.
Definition CD_KMCDualStateReactionImplem.H:145
void advanceState(State &a_state, const T &a_numReactions) const noexcept
Advance the incoming state with the number of reactions.
Definition CD_KMCDualStateReactionImplem.H:253
std::vector< std::pair< size_t, size_t > > m_lhsOrders
Reactants of the left-hand side, compacted to (species, order) pairs.
Definition CD_KMCDualStateReaction.H:192
std::vector< T > m_reactiveStateChangeDense
Dense form of m_reactiveStateChange, indexed by reactive species.
Definition CD_KMCDualStateReaction.H:183
const std::list< size_t > & getReactants() const noexcept
Get the reactants in the reaction.
Definition CD_KMCDualStateReactionImplem.H:217
Real m_propensityFactor
Factor for the case where two or more particles of the same species react.
Definition CD_KMCDualStateReaction.H:151
std::list< size_t > m_rhsNonReactives
Non-reactive product species.
Definition CD_KMCDualStateReaction.H:166
const std::list< size_t > & getNonReactiveProducts() const noexcept
Get the non-reactive products from the reaction.
Definition CD_KMCDualStateReactionImplem.H:231
KMCDualStateReaction(const KMCDualStateReaction &)=default
Copy constructor.
Real m_rate
Reaction rate.
Definition CD_KMCDualStateReaction.H:144
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_KMCDualStateReactionImplem.H:152