You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code provides a brief example of hwo to simulate the chemical master equation using the FiniteStateProjection.jl package.
5
+
The following code provides a brief example of how to simulate the chemical master equation using the [FiniteStateProjection.jl](https://github.com/SciML/FiniteStateProjection.jl) package.
6
6
```julia
7
7
# Create reaction network model (a bistable switch).
Using chemical master equation simulations, we want to simulate how the *full probability distribution* of these jump simulations develops across the simulation time frame.
71
72
@@ -82,8 +83,9 @@ u0[6] = 1.0
82
83
bar(u0, label = "t = 0.0")
83
84
```
84
85
We also plot the full distribution using the `bar` function. Finally, the initial condition vector defines the finite space onto which we project the CME. I.e. we will assume that, throughout the entire simulation, the probability of $X$ reaching values outside this initial vector is negligible.
85
-
!!! warn
86
-
This last bit is important. Even if the probability seems to be very small on the boundary provided by the initial condition, there is still a risk that probability will "leak". Here, it can be good to make simulations using different projections, ensuring that the results are consistent (especially for longer simulations).
86
+
87
+
!!! warning
88
+
This last bit is important. Even if the probability seems to be very small on the boundary provided by the initial condition, there is still a risk that probability will "leak". Here, it can be good to make simulations using different projections, ensuring that the results are consistent (especially for longer simulations).
87
89
88
90
Now, we can finally create an `ODEProblem` using our `FSPSystem`, initial conditions, and the parameters declared previously. We can simulate this `ODEProblem` like any other ODE.
Finally, we can plot $X$'s probability distribution at various simulation time points. Again, we will use the `bar` function to plot the distribution, and the interface described [here](@ref simulation_structure_interfacing_solutions) to access the simulation at various time points.
97
+
Finally, we can plot $X$'s probability distribution at various simulation time points. Again, we will use the `bar` function to plot the distribution, and the interface described [here](@ref simulation_structure_interfacing_solutions) to access the simulation at specified time points.
In the next step, however, we have to make an additional consideration. Since we have more than one species, we have to define which dimension of the initial condition (and hence also the output solution) corresponds to which species. Here we provide a second argument to `FSPSystem`, which is a vector listing all species in the order they occur in the `u0` array.
122
125
```@example state_projection_multi_species
@@ -128,11 +131,11 @@ Finally, we can simulate the model just like in the 1-dimensional case. In this
128
131
```@example state_projection_multi_species
129
132
using Plots # hide
130
133
using OrdinaryDiffEqRosenbrock
131
-
oprob = ODEProblem(fsp_sys, u0, 100.0, ps)
134
+
oprob = ODEProblem(fsp_sys, u0, 200.0, ps)
132
135
osol = solve(oprob, Rodas5P())
133
136
heatmap(osol[end]; xguide = "X₂", yguide = "X")
134
137
```
135
-
Here we perform a simulation with a long time span ($t = 100$) aiming to find the system's steady state distribution. Next, we plot it using the `heatmap` function.
138
+
Here we perform a simulation with a long time span ($t = 200.0$) aiming to find the system's steady state distribution. Next, we plot it using the `heatmap` function.
136
139
137
140
## [Finite state projection steady state simulations](@id state_projection_steady_state_sim)
138
141
Previously, we have shown how the [SteadyStateDiffEq.jl](https://github.com/SciML/SteadyStateDiffEq.jl) package can be used to [find an ODE's steady state through forward simulation](@ref steady_state_stability). The same interface can be used for ODEs generated through FiniteStateProjection. Below, we use this to find the steady state of the dimerisation example studied in the last example.
0 commit comments