chombo-discharge
CD_KMCDualStateReaction.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_KMCDualStateReaction_H
13 #define CD_KMCDualStateReaction_H
14 
15 // Std includes
16 #include <map>
17 #include <vector>
18 #include <list>
19 
20 // Chombo includes
21 #include <REAL.H>
22 
23 // Our includes
24 #include <CD_KMCDualState.H>
25 #include <CD_NamespaceHeader.H>
26 
31 template <typename State = KMCDualState<long long>, typename T = long long>
33 {
34 public:
38  KMCDualStateReaction() = default;
39 
44 
51  inline KMCDualStateReaction(const std::list<size_t>& a_lhsReactives,
52  const std::list<size_t>& a_rhsReactives,
53  const std::list<size_t>& a_rhsNonReactives) noexcept;
54 
58  inline virtual ~KMCDualStateReaction();
59 
64  inline Real&
65  rate() const noexcept;
66 
72  inline T
73  population(const size_t& a_reactant, const State& a_state) const noexcept;
74 
80  inline Real
81  propensity(const State& a_state) const noexcept;
82 
87  inline T
88  computeCriticalNumberOfReactions(const State& a_state) const noexcept;
89 
94  inline std::list<size_t>
95  getReactants() const noexcept;
96 
101  inline std::list<size_t>
102  getReactiveProducts() const noexcept;
103 
108  inline std::list<size_t>
109  getNonReactiveProducts() const noexcept;
110 
115  inline T
116  getStateChange(const size_t a_reactant) const noexcept;
117 
123  inline void
124  advanceState(State& a_state, const T& a_numReactions) const noexcept;
125 
126 protected:
130  mutable Real m_rate;
131 
137 
141  std::list<size_t> m_lhsReactives;
142 
146  std::list<size_t> m_rhsReactives;
147 
151  std::list<size_t> m_rhsNonReactives;
152 
156  std::map<size_t, T> m_reactiveStateChange;
157 
161  std::map<size_t, T> m_nonReactiveStateChange;
162 
166  inline void
167  computeStateChanges() noexcept;
168 
175  inline void
176  sanityCheck(const State& a_state) const noexcept;
177 };
178 
179 #include <CD_NamespaceFooter.H>
180 
182 
183 #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:33
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:200
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:236
void computeStateChanges() noexcept
Compute state change.
Definition: CD_KMCDualStateReactionImplem.H:41
std::list< size_t > getNonReactiveProducts() const noexcept
Get the non-reactive products from the reaction.
Definition: CD_KMCDualStateReactionImplem.H:193
std::list< size_t > m_lhsReactives
Reactive species.
Definition: CD_KMCDualStateReaction.H:141
T population(const size_t &a_reactant, const State &a_state) const noexcept
Get the population of the reactant in the input state.
Definition: CD_KMCDualStateReactionImplem.H:122
std::map< size_t, T > m_reactiveStateChange
State change for reactants/products.
Definition: CD_KMCDualStateReaction.H:156
KMCDualStateReaction()=default
Disallowed constructor. Use the full constructor.
virtual ~KMCDualStateReaction()
Destructor.
Definition: CD_KMCDualStateReactionImplem.H:36
std::list< size_t > getReactiveProducts() const noexcept
Get the products from the reaction.
Definition: CD_KMCDualStateReactionImplem.H:186
Real propensity(const State &a_state) const noexcept
Compute the propensity function for this reaction type.
Definition: CD_KMCDualStateReactionImplem.H:133
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:154
std::list< size_t > getReactants() const noexcept
Get the reactants in the reaction.
Definition: CD_KMCDualStateReactionImplem.H:179
std::list< size_t > m_rhsReactives
Product species.
Definition: CD_KMCDualStateReaction.H:146
std::map< size_t, T > m_nonReactiveStateChange
State change for non-reactive products.
Definition: CD_KMCDualStateReaction.H:161
Real & rate() const noexcept
Get modifiable reaction rate.
Definition: CD_KMCDualStateReactionImplem.H:115
void advanceState(State &a_state, const T &a_numReactions) const noexcept
Advance the incoming state with the number of reactions.
Definition: CD_KMCDualStateReactionImplem.H:213
Real m_propensityFactor
Factor for the case where two or more particles of the same species react.
Definition: CD_KMCDualStateReaction.H:136
std::list< size_t > m_rhsNonReactives
Non-reactive product species.
Definition: CD_KMCDualStateReaction.H:151
KMCDualStateReaction(const KMCDualStateReaction &)=default
Copy constructor (uses default).
Real m_rate
Reaction rate.
Definition: CD_KMCDualStateReaction.H:130