|
chombo-discharge
|
Class for running Kinetic Monte-Carlo simulations. More...
#include <CD_KMCSolver.H>
Public Types | |
| using | ReactionList = std::vector< std::shared_ptr< const R > > |
Public Member Functions | |
| KMCSolver () noexcept | |
| Default constructor – must subsequently define the object. | |
| KMCSolver (const KMCSolver &)=default | |
| Disallowed copy constructor. | |
| KMCSolver (const KMCSolver &&)=delete | |
| Disallowed move constructor. | |
| KMCSolver (const ReactionList &a_reactions) noexcept | |
| Full constructor. | |
| virtual | ~KMCSolver () noexcept |
| Destructor. | |
| KMCSolver & | operator= (const KMCSolver &)=default |
| Copy assignment operator. | |
| KMCSolver & | operator= (const KMCSolver &&)=delete |
| Disallowed move assignment operator. | |
| void | define (const ReactionList &a_reactions) noexcept |
| Define function. Sets the reactions. | |
| void | setSolverParameters (const T a_numCrit, const T a_numSSA, const T a_maxIter, const Real a_eps, const Real a_SSAlim, const Real a_exitTol) noexcept |
| Set solver parameters. | |
| std::vector< std::vector< T > > | getNu (const State &a_state, const ReactionList &a_reactions) const noexcept |
| Compute the state vector changes for all reactions. | |
| std::vector< Real > | propensities (const State &a_state) const noexcept |
| Compute propensities for ALL reactions. | |
| std::vector< Real > | propensities (const State &a_state, const ReactionList &a_reactions) const noexcept |
| Compute propensities for a subset of reactions. | |
| Real | totalPropensity (const State &a_state) const noexcept |
| Compute the total propensity for ALL reactions. | |
| Real | totalPropensity (const State &a_state, const ReactionList &a_reactions) const noexcept |
| Compute the total propensity for a subset of reactions. | |
| std::pair< ReactionList, ReactionList > | partitionReactions (const State &a_state) const noexcept |
| Partition reactions into critical and non-critical reactions. | |
| std::pair< ReactionList, ReactionList > | partitionReactions (const State &a_state, const ReactionList &a_reactions) const noexcept |
| Partition reactions into critical and non-critical reactions. | |
| Real | getCriticalTimeStep (const State &a_state) const noexcept |
| Get the time to the next critical reaction. | |
| Real | getCriticalTimeStep (const State &a_state, const ReactionList &a_criticalReactions) const noexcept |
| Get the time to the next critical reaction. | |
| Real | getCriticalTimeStep (const std::vector< Real > &a_propensities) const noexcept |
| Get the time to the next critical reaction. | |
| Real | getCriticalTimeStep (const Real &a_totalPropensity) const noexcept |
| Get the time to the next critical reaction. | |
| Real | getNonCriticalTimeStep (const State &a_state) const noexcept |
| Get the non-critical time step. | |
| Real | getNonCriticalTimeStep (const State &a_state, const ReactionList &a_reactions) const noexcept |
| Get the non-critical time step. | |
| Real | getNonCriticalTimeStep (const State &a_state, const ReactionList &a_nonCriticalReactions, const std::vector< Real > &a_nonCriticalPropensities) const noexcept |
| Get the non-critical time step. | |
| Real | computeDt (const State &a_state, const ReactionList &a_reactions, const std::vector< Real > &a_propensities, const Real a_epsilon) const noexcept |
| Compute a time step, using the leap condition on the mean value with eps = 1. | |
| void | stepSSA (State &a_state) const noexcept |
| Perform a single SSA step. | |
| void | stepSSA (State &a_state, const ReactionList &a_reactions) const noexcept |
| Perform a single SSA step. | |
| void | stepSSA (State &a_state, const ReactionList &a_reactions, const std::vector< Real > &a_propensities) const noexcept |
| Perform a single SSA step. This version has pre-computed propensities (for optimization reasons) | |
| void | advanceSSA (State &a_state, const Real a_dt) const noexcept |
| Advance with the SSA over the input time. This can end up using substepping. | |
| void | advanceSSA (State &a_state, const ReactionList &a_reactions, const Real a_dt) const noexcept |
| Advance with the SSA over the input time. This can end up using substepping. | |
| void | stepExplicitEuler (State &a_state, const Real a_dt) const noexcept |
| Perform one plain tau-leaping step using ALL reactions. | |
| void | stepExplicitEuler (State &a_state, const ReactionList &a_reactions, const Real a_dt) const noexcept |
| Perform one plain tau-leaping step over the input reactions using a time step a_dt. | |
| void | stepMidpoint (State &a_state, const Real a_dt) const noexcept |
| Perform one leaping step using the midpoint method for ALL reactions over a time step a_dt. | |
| void | stepMidpoint (State &a_state, const ReactionList &a_reactions, const Real a_dt) const noexcept |
| Perform one leaping step using the midpoint method for the input reactions over a time step a_dt. | |
| void | stepPRC (State &a_state, const Real a_dt) const noexcept |
| Perform one leaping step using the PRC method for ALL reactions over a time step a_dt. | |
| void | stepPRC (State &a_state, const ReactionList &a_reactions, const Real a_dt) const noexcept |
| Perform one leaping step using the PRC method for the input reactions over a time step a_dt. | |
| void | stepImplicitEuler (State &a_state, const Real a_dt) const noexcept |
| Perform one implicit Euler tau-leaping step using ALL reactions. | |
| void | stepImplicitEuler (State &a_state, const ReactionList &a_reactions, const Real a_dt) const noexcept |
| Perform one implicit Euler tau-leaping step over the input reactions using a time step a_dt. | |
| void | advanceTau (State &a_state, const Real &a_dt, const KMCLeapPropagator &a_leapPropagator=KMCLeapPropagator::ExplicitEuler) const noexcept |
| Advance using a specified tau-leaping algorithm. | |
| void | advanceTau (State &a_state, const ReactionList &a_reactions, const Real &a_dt, const KMCLeapPropagator &a_leapPropagator=KMCLeapPropagator::ExplicitEuler) const noexcept |
| Advance using a specified tau-leaping algorithm. | |
| void | advanceHybrid (State &a_state, const Real a_dt, const KMCLeapPropagator &a_leapPropagator=KMCLeapPropagator::ExplicitEuler) const noexcept |
| Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping. | |
| void | advanceHybrid (State &a_state, const ReactionList &a_reactions, const Real a_dt, const KMCLeapPropagator &a_leapPropagator=KMCLeapPropagator::ExplicitEuler) const noexcept |
| Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping. | |
| void | advanceHybrid (State &a_state, const ReactionList &a_reactions, const Real a_dt, const std::function< void(State &, const ReactionList &a_reactions, const Real a_dt)> &a_propagator) const noexcept |
| Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping. | |
Protected Attributes | |
| ReactionList | m_reactions |
| List of reactions used when advancing states. | |
| T | m_Ncrit |
| Definition of critical reactions. | |
| T | m_numSSA |
| Maximum number of SSA steps to run when switching into SSA-based advancement for non-critical reactions. | |
| T | m_maxIter |
| Maximum number of iterations for implicit solvers. | |
| Real | m_eps |
| Maximum permitted change in propensities for non-critical reactions. | |
| Real | m_SSAlim |
| Threshold for switching to SSA-based algorithm within the Cao algorithm. | |
| Real | m_exitTol |
| Exit tolerance for implicit solvers. | |
| std::vector< std::vector< int > > | m_nu |
| List of state changes for each reaction. | |
Class for running Kinetic Monte-Carlo simulations.
The template parameter State is the underlying state type that KMC operators on. There are rather simple required member functions on the State parameter, but the reaction type (template parameter R) MUST be able to operate on the state through the following functions:
The template parameter T should agree across both both R, State, and KMCSolver. Note that this must be a signed integer type.
|
inlinenoexcept |
Full constructor.
| [in] | a_reactions | List of reactions. |
|
inlinenoexcept |
Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping.
| [in,out] | a_state | State vector to advance. |
| [in] | a_reactions | Reactions to advance. |
| [in] | a_dt | Time increment. |
| [in] | a_leapPropagator | Which leap propagator to use. |
|
inlinenoexcept |
Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping.
| [in,out] | a_state | State vector to advance |
| [in] | a_reactions | Reactions to advance with |
| [in] | a_dt | Time increment |
| [in] | a_leapPropagator | Leaping propagator |
|
inlinenoexcept |
Advance using Cao et. al. hybrid algorithm over the input time. This can end up using substepping.
| [in,out] | a_state | State vector to advance |
| [in] | a_dt | Time increment |
| [in] | a_leapPropagator | Which leap propagator to use. |
|
inlinenoexcept |
Advance with the SSA over the input time. This can end up using substepping.
| [in,out] | a_state | State vector to advance |
| [in] | a_reactions | Reactions to advance with |
| [in] | a_dt | Time increment |
Advance with the SSA over the input time. This can end up using substepping.
| [in,out] | a_state | State vector to advance |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Advance using a specified tau-leaping algorithm.
| [in,out] | a_state | State vector to advance. |
| [in] | a_reactions | Reactions to advance. |
| [in] | a_dt | Time increment. |
| [in] | a_leapPropagator | Which leap propagator to use. |
|
inlinenoexcept |
Advance using a specified tau-leaping algorithm.
| [in,out] | a_state | State vector to advance |
| [in] | a_dt | Time increment |
| [in] | a_leapPropagator | Which leap propagator to use. |
|
inlinenoexcept |
Compute a time step, using the leap condition on the mean value with eps = 1.
This is just like getNonCriticalTimeStep EXCEPT that the leap condition is not applied for the deviation
| [in] | a_state | State vector |
| [in] | a_reactions | Reactions |
| [in] | a_propensities | Propensities |
| [in] | a_epsilon | Epsilon value for maximum change in propensities |
Define function. Sets the reactions.
| [in] | a_reactions | List of reactions. |
|
inlinenoexcept |
Get the time to the next critical reaction.
| [in] | a_totalPropensity | Total propensity |
Get the time to the next critical reaction.
| [in] | a_state | State vector |
|
inlinenoexcept |
Get the time to the next critical reaction.
| [in] | a_state | State vector |
| [in] | a_criticalReactions | Reaction list. |
|
inlinenoexcept |
Get the time to the next critical reaction.
| [in] | a_propensities | Reaction propensities |
Get the non-critical time step.
| [in] | a_state | State vector |
|
inlinenoexcept |
Get the non-critical time step.
| [in] | a_state | State vector |
| [in] | a_nonCriticalReactions | Non-critical reactions |
| [in] | a_nonCriticalPropensities | Non-critical propensities |
|
inlinenoexcept |
Get the non-critical time step.
| [in] | a_state | State vector |
| [in] | a_reactions | Reaction list |
|
inlinenoexcept |
Compute the state vector changes for all reactions.
| [in] | a_state | Input state. |
| [in] | a_reactions | Reaction list. |
|
inlinenoexcept |
Partition reactions into critical and non-critical reactions.
First member in the pair is the critical reactions, then the non-critical reactions.
| [in] | a_state | State vector |
|
inlinenoexcept |
Partition reactions into critical and non-critical reactions.
First member in the pair is the critical reactions, then the non-critical reactions
| [in] | a_state | State vector |
| [in] | a_reactions | Reaction list to be partitioned |
|
inlinenoexcept |
Compute propensities for ALL reactions.
| [in] | a_state | State vector |
|
inlinenoexcept |
Compute propensities for a subset of reactions.
| [in] | a_state | State vector |
| [in] | a_reactions | Reaction list |
|
inlinenoexcept |
Set solver parameters.
| [in] | a_numCrit | Determines critical reactions. This is the number of reactions that need to fire before depleting a reactant. |
| [in] | a_numSSA | Maximum number of SSA steps to run when switching from tau-leaping to SSA (hybrid algorithm only). |
| [in] | a_maxIter | Maximum permitted number of iterations for the implicit solver |
| [in] | a_eps | Maximum permitted change in propensities when performing tau-leaping for non-critical reactions. |
| [in] | a_SSAlim | Threshold for switching from tau-leaping of non-critical reactions to SSA for all reactions (hybrid algorithm only) |
| [in] | a_exitTol | Exit tolerance for implicit solvres. |
|
inlinenoexcept |
Perform one plain tau-leaping step over the input reactions using a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_reactions | List of reactions to advance with |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one plain tau-leaping step using ALL reactions.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one implicit Euler tau-leaping step over the input reactions using a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_reactions | List of reactions to advance with |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one implicit Euler tau-leaping step using ALL reactions.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one leaping step using the midpoint method for the input reactions over a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_reactions | List of reactions to advance with |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one leaping step using the midpoint method for ALL reactions over a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_dt | Time increment |
|
inlinenoexcept |
Perform one leaping step using the PRC method for the input reactions over a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_reactions | List of reactions to advance with |
| [in] | a_dt | Time increment |
Perform one leaping step using the PRC method for ALL reactions over a time step a_dt.
| [in,out] | a_state | State vector to be advanced |
| [in] | a_dt | Time increment |
Perform a single SSA step.
| [in,out] | a_state | State vector to advance |
|
inlinenoexcept |
Perform a single SSA step.
| [in,out] | a_state | State vector to advance |
| [in] | a_reactions | Reactions to advance with |
|
inlinenoexcept |
Perform a single SSA step. This version has pre-computed propensities (for optimization reasons)
| [in,out] | a_state | State vector to advance |
| [in] | a_reactions | Reactions to advance with |
| [in] | a_propensities | Propensities for the reactions |
Compute the total propensity for ALL reactions.
| [in] | a_state | State vector |
|
inlinenoexcept |
Compute the total propensity for a subset of reactions.
| [in] | a_state | State vector |
| [in] | a_reactions | Reaction list |
|
protected |
Definition of critical reactions.
A reaction is critical if it is m_Ncrit firings away from depleting a reactant.
|
protected |
List of state changes for each reaction.