Skip to content

Commit 9a460bf

Browse files
authored
Merge pull request #617 from isaacsas/event_doc_tweaks
tweak event tutorial
2 parents 0c005a5 + 8a9b2e3 commit 9a460bf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/src/catalyst_functionality/constraint_equations.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ plot(sol)
8888
## Adding events
8989
Our current model is unrealistic in assuming the cell will grow exponentially
9090
forever. Let's modify it such that the cell divides in half every time its
91-
volume reaches a size of `2`. Note, we will only keep track of one cell, and
92-
hence follow a specific lineage of the system. To do this we can create a
93-
continuous event using the ModelingToolkit symbolic event interface and attach
94-
it to our system. Please see the associated [ModelingToolkit
91+
volume reaches a size of `2`. We also assume we lose half of the protein upon
92+
division. Note, we will only keep track of one cell, and hence follow a specific
93+
lineage of the system. To do this we can create a continuous event using the
94+
ModelingToolkit symbolic event interface and attach it to our system. Please see
95+
the associated [ModelingToolkit
9596
tutorial](https://docs.sciml.ai/ModelingToolkit/stable/basics/Events/) for more
9697
details on the types of events that can be represented symbolically. A
9798
lower-level approach for creating events via the DifferentialEquations.jl
@@ -104,20 +105,20 @@ using Catalyst, DifferentialEquations, Plots
104105
105106
@parameters λ = 1.0
106107
@variables t V(t) = 1.0
108+
@species P(t) = 0.0
107109
D = Differential(t)
108110
eq = D(V) ~ λ * V
109-
rx1 = @reaction $V, 0 --> P
110-
rx2 = @reaction 1.0, P --> 0
111+
rx1 = @reaction $V, 0 --> $P
112+
rx2 = @reaction 1.0, $P --> 0
111113
```
112114
Before creating our `ReactionSystem` we make the event.
113115
```@example ceq3
114-
# every 1.0 time unit we half the volume of the cell
115-
continuous_events = [V ~ 2.0] => [V ~ V/2]
116+
# every 1.0 time unit we half the volume of the cell and the number of proteins
117+
continuous_events = [V ~ 2.0] => [V ~ V/2, P ~ P/2]
116118
```
117119
We can now create and simulate our model
118120
```@example ceq3
119121
@named rs = ReactionSystem([rx1, rx2, eq], t; continuous_events)
120-
setdefaults!(rs, [:P => 0.0])
121122
122123
oprob = ODEProblem(rs, [], (0.0, 10.0))
123124
sol = solve(oprob, Tsit5())

0 commit comments

Comments
 (0)