Skip to content

Commit 03de344

Browse files
committed
add two state model
1 parent fe62c54 commit 03de344

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

docs/src/catalyst_functionality/example_networks/basic_CRN_library.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# [Library of Basic Chemical Reaction Network Models](@id basic_CRN_library)
22
Below we will present various simple and established chemical reaction network (CRN) models. Each model is given some brief background, implemented using the `@reaction_network` DSL, and basic simulations are performed.
33

4-
## Birth-death process
4+
## [Birth-death process](@id basic_CRN_library_bd)
55
The birth-death process is one of the simplest possible CRN models. It consists of a single component ($X$) which is both produced and degraded at linear rates:
66
```@example crn_library_birth_death
77
using Catalyst
@@ -47,7 +47,37 @@ jplt = plot(jsol; title = "Stochastic chemical kinetics (Jump)")
4747
plot(oplt, splt, jplt; lw = 3, size=(800,700), layout = (3,1))
4848
```
4949

50-
## Michaelis-Menten enzyme kinetics
50+
## [Two-state model](@id basic_CRN_library_two_states)
51+
The two-state model describes a component (here called $X$) which can exist in two different forms (here called $X₁$ and $X₂$). It switches between these forms at linear rates. First, we simulate the model using both ODEs and SDEs:
52+
```@example crn_library_two_states
53+
using Catalyst, OrdinaryDiffEq, StochasticDiffEq, Plots
54+
two_state_model = @reaction_network begin
55+
(k1,k2), X₁ <--> X₂
56+
end
57+
58+
u0 = [:X₁ => 50.0, :X₂ => 50.0]
59+
tspan = (0.0, 1.0)
60+
ps = [:k1 => 2.0, :k2 => 3.0]
61+
62+
oprob = ODEProblem(two_state_model, u0, tspan, ps)
63+
osol = solve(oprob, Tsit5())
64+
oplt = plot(osol; title = "Reaction rate equation (ODE)")
65+
66+
sprob = SDEProblem(two_state_model, u0, tspan, ps)
67+
ssol = solve(sprob, ImplicitEM())
68+
splt = plot(ssol; title = "Chemical Langevin equation (SDE)")
69+
70+
plot(oplt, splt; lw = 3, size = (800,550), layout = (2,1))
71+
```
72+
What is interesting about this model is that it has a *conserved quantity*, where $X₁ + X₂$ remains constant throughout the simulation (both in deterministic and stochastic cases). We can show this by instead plotting this conserved quantity.
73+
```@example crn_library_two_states
74+
@unpack X₁, X₂ = two_state_model
75+
oplt = plot(osol; idxs = X₁ + X₂, title = "Reaction rate equation (ODE)")
76+
splt = plot(ssol; idxs = X₁ + X₂, title = "Chemical Langevin equation (SDE)")
77+
plot(oplt, splt; lw = 3, size = (800,550), layout = (2,1))
78+
```
79+
80+
## [Michaelis-Menten enzyme kinetics](@id basic_CRN_library_mm)
5181
[Michaelis-Menten enzyme kinetics](https://en.wikipedia.org/wiki/Michaelis%E2%80%93Menten_kinetics) is a simple description of an enzyme ($E$) transforming a substrate ($S$) into a product ($P$). Under certain assumptions, it can be simplified to a single function (a Michaelis-Menten function) and used as a reaction rate. Here we instead present the full system model:
5282
```@example crn_library_michaelis_menten
5383
using Catalyst
@@ -84,7 +114,7 @@ plot(oplt, splt, jplt; lw = 2, size=(800,800), layout = (3,1))
84114
plot!(bottom_margin = 3Plots.Measures.mm) # hide
85115
```
86116

87-
## SIR infection model
117+
## [SIR infection model](@id basic_CRN_library_sir)
88118
The [SIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology#The_SIR_model) is the simplest model of the spread of an infectious disease. While the real system is very different from the chemical and cellular processes typically modelled with CRNs, it (and several other epidemiological systems) can be modelled using the same CRN formalism. The SIR model consists of three species: susceptible ($S$), infected ($I$), and removed ($R$) individuals, and two reaction events: infection and recovery.
89119
```@example crn_library_sir
90120
using Catalyst
@@ -124,7 +154,7 @@ jplt3 = plot(jsol3; title = "No outbreak")
124154
plot(jplt1, jplt2, jplt3; lw = 3, size=(800,700), layout = (3,1))
125155
```
126156

127-
## The Wilhelm model
157+
## [The Wilhelm model](@id basic_CRN_library_wilhelm)
128158
The Wilhelm model was introduced in [*Wilhelm (2009)*](https://bmcsystbiol.biomedcentral.com/articles/10.1186/1752-0509-3-90) as the smallest CRN model (with constant rates) that exhibits bistability.
129159
```@example crn_library_wilhelm
130160
using Catalyst
@@ -152,7 +182,7 @@ plot!(osol2; lw = 4, idxs = :X, label = "X(0) = 2.5", yguide = "X", size = (800,
152182
plot!(bottom_margin = 3Plots.Measures.mm) # hide
153183
```
154184

155-
## Simple self-activation loop
185+
## [Simple self-activation loop](@id basic_CRN_library_self_activation)
156186
The simplest self-activation loop consists of a single species (here called $X$) which activates its own production. If its production rate is modelled with a hill function with $n>1$, the system may exhibit bistability.
157187
```@example crn_library_self_activation
158188
using Catalyst
@@ -183,7 +213,7 @@ plot!(jsol; lw = 3, label = "Stochastic chemical kinetics (Jump)", yguide = "X",
183213
plot!(bottom_margin = 3Plots.Measures.mm, left_margin=3Plots.Measures.mm) # hide
184214
```
185215

186-
## The Brusselator
216+
## [The Brusselator](@id basic_CRN_library_brusselator)
187217
The [Brusselator](https://en.wikipedia.org/wiki/Brusselator) is a well-known (theoretical) CRN model able to produce oscillations (its name is a portmanteau of "Brussels" and "oscillator").
188218
```@example crn_library_brusselator
189219
using Catalyst
@@ -209,10 +239,10 @@ osol2 = solve(oprob2, Rodas5P())
209239
oplt1 = plot(osol1; title = "No Oscillation")
210240
oplt2 = plot(osol2; title = "Oscillation")
211241
212-
plot(oplt1, oplt2; lw = 3, layout = (2,1), size = (800,600))
242+
plot(oplt1, oplt2; lw = 3, size = (800,600), layout = (2,1))
213243
```
214244

215-
## The repressilator
245+
## [The repressilator](@id basic_CRN_library_)
216246
The repressilator was introduced in [*Elowitz & Leibler (2000)*](https://www.nature.com/articles/35002125) as a simple system that can generate oscillations (most notably, they demonstrated this both in a model and in a synthetic in vivo implementation in *Escherichia col*). It consists of three genes, repressing each other in a cycle. Here, we will implement it using three species ($X$, $Y$, and $Z$) whose production rates are (repressing) [Hill functions](https://en.wikipedia.org/wiki/Hill_equation_(biochemistry)).
217247
```@example crn_library_brusselator
218248
using Catalyst
@@ -250,7 +280,7 @@ splt2 = plot(ssol2; title = "Oscillation (SDE, K = 50)")
250280
plot(oplt1, oplt2, splt1, splt2; lw = 2, layout = (2,2), size = (800,600))
251281
```
252282

253-
## The Willamowski–Rössler model
283+
## [The Willamowski–Rössler model](@id basic_CRN_library_wr)
254284
The Willamowski–Rössler model was introduced in [*Willamowski & Rössler (1979)*](https://www.degruyter.com/document/doi/10.1515/zna-1980-0308/html?lang=en) as an example of a simple CRN model which exhibits [*chaotic behaviours*](https://en.wikipedia.org/wiki/Chaos_theory). This means that small changes in initial conditions can produce relatively large changes in the system's trajectory.
255285
```@example crn_library_chaos
256286
using Catalyst

0 commit comments

Comments
 (0)