-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkmc.qmd
130 lines (89 loc) · 8.16 KB
/
kmc.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# kmc { #kimmdy.kmc }
`kmc`
Kinetic Monte Carlo (KMC) classes and functions.
In our system, the reaction rate r = (deterministic) reaction constant k
= stochastic reaction constant c (from gillespie 1977)
= propensity a (from Anderson 2007)
because of the fundamental premise of chemical kinetics
and because we have one reactant molecule
## Classes
| Name | Description |
| --- | --- |
| [KMCResult](#kimmdy.kmc.KMCResult) | The result of a KMC step. Similar to a Recipe but for the concrete realization of a reaction. |
### KMCResult { #kimmdy.kmc.KMCResult }
`kmc.KMCResult(recipe=field(default_factory=lambda: Recipe([], [], [])), reaction_probability=None, time_delta=None, time_start=None)`
The result of a KMC step. Similar to a Recipe but for the concrete realization of a reaction.
#### Attributes
| Name | Type | Description |
|----------------------|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| recipe | [Recipe](`kimmdy.recipe.Recipe`) | Single sequence of RecipeSteps to build product |
| reaction_probability | [Optional](`typing.Optional`)\[[list](`list`)\[[float](`float`)\]\] | Integral of reaction propensity with respect to time |
| time_delta | [Optional](`typing.Optional`)\[[float](`float`)\] | MC time jump during which the reaction occurs [ps] |
| time_start | [Optional](`typing.Optional`)\[[float](`float`)\] | Time, from which the reaction starts. The reaction changes the geometry/topology of this timestep and continues from there. [ps] |
## Functions
| Name | Description |
| --- | --- |
| [extrande](#kimmdy.kmc.extrande) | Extrande KMC |
| [extrande_mod](#kimmdy.kmc.extrande_mod) | Modified Extrande KMC |
| [frm](#kimmdy.kmc.frm) | First Reaction Method variant of Kinetic Monte Carlo. |
| [rf_kmc](#kimmdy.kmc.rf_kmc) | Rejection-Free Monte Carlo. |
### extrande { #kimmdy.kmc.extrande }
`kmc.extrande(recipe_collection, tau_scale, logger=logging.getLogger(__name__), rng=default_rng())`
Extrande KMC
Implemented as in
`Stochastic Simulation of Biomolecular Networks in Dynamic Environments`
[10.1371/journal.pcbi.1004923](https://doi.org/10.1371/journal.pcbi.1004923)
#### Parameters
| Name | Type | Description | Default |
|---------------------|------------------------------------------------------------------------------|-----------------------------------------------------|-----------------|
| `recipe_collection` | [RecipeCollection](`kimmdy.recipe.RecipeCollection`) | from which one will be choosen | _required_ |
| `rng` | [np](`numpy`).[random](`numpy.random`).[Generator](`numpy.random.Generator`) | function to generate random numbers in the KMC step | `default_rng()` |
| `tau_scale` | [float](`float`) | Scaling factor for tau, by default 1.0 | _required_ |
#### Returns
| Type | Description |
|-------------------------------------|---------------------|
| [KMCResult](`kimmdy.kmc.KMCResult`) | time delta set to 0 |
### extrande_mod { #kimmdy.kmc.extrande_mod }
`kmc.extrande_mod(recipe_collection, tau_scale, logger=logging.getLogger(__name__), rng=default_rng())`
Modified Extrande KMC
Improved implementation of
`Stochastic Simulation of Biomolecular Networks in Dynamic Environments`
[10.1371/journal.pcbi.1004923](https://doi.org/10.1371/journal.pcbi.1004923)
Changes: The considered time window is chosen to be a window containing
constant rates. This prevents very small tau caused by a spike in the rate
at a later point. As a side effect, the upper rate bound b and current rate
a0 are the same, and the 'extra' side channel can not be triggered anymore.
This should be more efficient given a limited number of time windows
containing constant rates.
#### Parameters
| Name | Type | Description | Default |
|---------------------|------------------------------------------------------------------------------|-----------------------------------------------------|-----------------|
| `recipe_collection` | [RecipeCollection](`kimmdy.recipe.RecipeCollection`) | from which one will be choosen | _required_ |
| `rng` | [np](`numpy`).[random](`numpy.random`).[Generator](`numpy.random.Generator`) | function to generate random numbers in the KMC step | `default_rng()` |
| `tau_scale` | [float](`float`) | Scaling factor for tau, by default 1.0 | _required_ |
#### Returns
| Type | Description |
|-------------------------------------|---------------------|
| [KMCResult](`kimmdy.kmc.KMCResult`) | time delta set to 0 |
### frm { #kimmdy.kmc.frm }
`kmc.frm(recipe_collection, logger=logging.getLogger(__name__), rng=default_rng(), MD_time=None)`
First Reaction Method variant of Kinetic Monte Carlo.
takes RecipeCollection and choses a recipe based on which reaction would occur.
Compare e.g. [Wikipedia KMC - time dependent](https://en.wikipedia.org/wiki/Kinetic_Monte_Carlo#Time-dependent_Algorithms)
#### Parameters
| Name | Type | Description | Default |
|---------------------|------------------------------------------------------------------------------|------------------------------------------------------------------------------------|-----------------|
| `recipe_collection` | [RecipeCollection](`kimmdy.recipe.RecipeCollection`) | from which one will be choosen | _required_ |
| `rng` | [np](`numpy`).[random](`numpy.random`).[Generator](`numpy.random.Generator`) | to generate random numbers in the KMC step | `default_rng()` |
| `MD_time` | [Optional](`typing.Optional`)\[[float](`float`)\] | time [ps] to compare conformational events with reaction events in the time domain | `None` |
### rf_kmc { #kimmdy.kmc.rf_kmc }
`kmc.rf_kmc(recipe_collection, logger=logging.getLogger(__name__), rng=default_rng())`
Rejection-Free Monte Carlo.
Takes RecipeCollection and choses a recipe based on the relative propensity of the events.
The 'start' time of the reaction is the time of the highest rate of the accepted reaction.
Compare e.g. [Wikipedia KMC - rejection free](https://en.wikipedia.org/wiki/Kinetic_Monte_Carlo#Rejection-free_KMC)
#### Parameters
| Name | Type | Description | Default |
|---------------------|------------------------------------------------------------------------------|-----------------------------------------------------|-----------------|
| `recipe_collection` | [RecipeCollection](`kimmdy.recipe.RecipeCollection`) | from which one will be choosen | _required_ |
| `rng` | [np](`numpy`).[random](`numpy.random`).[Generator](`numpy.random.Generator`) | function to generate random numbers in the KMC step | `default_rng()` |