Reaction type for advancing a KMCDualState for Kinetic Monte Carlo.
More...
#include <CD_KMCDualStateReaction.H>
|
|
| KMCDualStateReaction ()=default |
| | Default constructor.
|
| |
|
| KMCDualStateReaction (const KMCDualStateReaction &)=default |
| | Copy constructor.
|
| |
| | KMCDualStateReaction (const std::list< size_t > &a_lhsReactives, const std::list< size_t > &a_rhsReactives, const std::list< size_t > &a_rhsNonReactives) noexcept |
| | Full constructor.
|
| |
|
virtual | ~KMCDualStateReaction () |
| | Destructor.
|
| |
| Real & | rate () const noexcept |
| | Get modifiable reaction rate.
|
| |
| Real | propensity (const State &a_state) const noexcept |
| | Compute the propensity function for this reaction type.
|
| |
| T | computeCriticalNumberOfReactions (const State &a_state) const noexcept |
| | Compute the number of times the reaction can fire before exhausting one of the reactants.
|
| |
| const std::list< size_t > & | getReactants () const noexcept |
| | Get the reactants in the reaction.
|
| |
| std::list< size_t > | getReactiveProducts () const noexcept |
| | Get the products from the reaction.
|
| |
| std::list< size_t > | getNonReactiveProducts () const noexcept |
| | Get the non-reactive products from the reaction.
|
| |
| T | getStateChange (const size_t a_reactant) const noexcept |
| | Get the state change due to a change in the input reactant.
|
| |
| void | advanceState (State &a_state, const T &a_numReactions) const noexcept |
| | Advance the incoming state with the number of reactions.
|
| |
|
| static T | population (const size_t &a_reactant, const State &a_state) noexcept |
| | Get the population of the reactant in the input state.
|
| |
|
|
void | computeStateChanges () noexcept |
| | Compute state change vectors from the reactant/product lists.
|
| |
| 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.
|
| |
|
|
Real | m_rate |
| | Reaction rate.
|
| |
| Real | m_propensityFactor |
| | Factor for the case where two or more particles of the same species react.
|
| |
|
std::list< size_t > | m_lhsReactives |
| | Reactive species (left-hand side).
|
| |
|
std::list< size_t > | m_rhsReactives |
| | Product species (right-hand side reactive).
|
| |
|
std::list< size_t > | m_rhsNonReactives |
| | Non-reactive product species.
|
| |
|
std::map< size_t, T > | m_reactiveStateChange |
| | State change for reactants/products.
|
| |
| std::vector< T > | m_reactiveStateChangeDense |
| | Dense form of m_reactiveStateChange, indexed by reactive species.
|
| |
| std::vector< std::pair< size_t, size_t > > | m_lhsOrders |
| | Reactants of the left-hand side, compacted to (species, order) pairs.
|
| |
|
std::map< size_t, T > | m_nonReactiveStateChange |
| | State change for non-reactive products.
|
| |
template<typename State = KMCDualState<long long>, typename T = long long>
class KMCDualStateReaction< State, T >
Reaction type for advancing a KMCDualState for Kinetic Monte Carlo.
- Note
- T is the integer type used for the state.
◆ KMCDualStateReaction()
template<typename State , typename T >
Full constructor.
- Parameters
-
| [in] | a_lhsReactives | Reactive species on the left-hand side of the reaction (i.e., the reactants). |
| [in] | a_rhsReactives | Reactive species on the right-hand side of the reaction (i.e., the products). |
| [in] | a_rhsNonReactives | Non-reactive species on the right-hand side of the reaction (i.e., piggybacked products). |
◆ advanceState()
template<typename State , typename T >
| void KMCDualStateReaction< State, T >::advanceState |
( |
State & |
a_state, |
|
|
const T & |
a_numReactions |
|
) |
| const |
|
inlinenoexcept |
Advance the incoming state with the number of reactions.
- Parameters
-
| [in,out] | a_state | State vector. |
| [in] | a_numReactions | Number of reactions. |
◆ computeCriticalNumberOfReactions()
template<typename State , typename T >
Compute the number of times the reaction can fire before exhausting one of the reactants.
- Parameters
-
- Returns
- Critical number of reactions.
◆ getNonReactiveProducts()
template<typename State , typename T >
Get the non-reactive products from the reaction.
- Returns
- m_rhsNonReactives
◆ getReactants()
template<typename State , typename T >
Get the reactants in the reaction.
Returned by reference because KMCSolver walks this list once per reaction per grid cell when it assembles the reactant set for the time step calculation; returning by value deep-copied the list, and with it one heap allocation per element, on every one of those walks.
- Returns
- m_lhsReactives
◆ getReactiveProducts()
template<typename State , typename T >
Get the products from the reaction.
- Returns
- m_rhsReactives
◆ getStateChange()
template<typename State , typename T >
Get the state change due to a change in the input reactant.
- Parameters
-
| [in] | a_reactant | Reactive species. |
- Returns
- State change for the reactant.
◆ population()
template<typename State , typename T >
Get the population of the reactant in the input state.
- Parameters
-
| [in] | a_reactant | Reactive species. |
| [in] | a_state | State vector. |
- Returns
- Population of the reactant.
◆ propensity()
template<typename State , typename T >
Compute the propensity function for this reaction type.
- Parameters
-
- Returns
- Reaction propensity.
- Note
- User should set the rate before calling this routine.
◆ rate()
template<typename State , typename T >
Get modifiable reaction rate.
- Returns
- m_rate
◆ sanityCheck()
template<typename State , typename T >
Debugging function which ensures that the class data holders do not reach out of the incoming state.
This is necessary because PlasmaReaction does not have compile-time size restrictions on the incoming state. The internals of this method uses Chombo assertions so the compiler should be able to take this function out of the executable if compiling with the correct flags.
- Parameters
-
◆ m_lhsOrders
template<typename State = KMCDualState<long long>, typename T = long long>
Reactants of the left-hand side, compacted to (species, order) pairs.
Built once in computeStateChanges() from the same reactant tally that fixes m_propensityFactor. propensity() uses it to form the falling factorial directly from the incoming state; without it the reaction has to copy the whole state vector on every call so that it can decrement its own copy while multiplying.
◆ m_propensityFactor
template<typename State = KMCDualState<long long>, typename T = long long>
Factor for the case where two or more particles of the same species react.
For reactions X + X -> null the propensity is k * X * (X-1)/2 because there are X * (X-1)/2 unique pairs of particles in the cell.
◆ m_reactiveStateChangeDense
template<typename State = KMCDualState<long long>, typename T = long long>
Dense form of m_reactiveStateChange, indexed by reactive species.
Built once in computeStateChanges() and holding the same values as m_reactiveStateChange, with zero for species the reaction does not touch. It exists because getStateChange() sits in the innermost loop of KMCSolver::computeDt and KMCSolver::getNonCriticalTimeStep, which run once per reactant per reaction per grid cell. Serving those from the map cost two red-black-tree walks (find followed by at) per lookup. Species indices at or beyond the vector's length are not involved in the reaction and their state change is zero.
The documentation for this class was generated from the following files: