Skip to content

Commit 15610c0

Browse files
committed
try using vector parameters
1 parent 1c56c60 commit 15610c0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/src/model_creation/examples/smoluchowski_coagulation_equation.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ elseif i==2
6060
kv = fill(C / V, nr)
6161
end
6262
```
63-
We'll store the reaction rates in `pars` as `Pair`s, and set the initial condition that only monomers are present at ``t=0`` in `u₀map`.
63+
We'll set the parameters and the initial condition that only monomers are present at ``t=0`` in `u₀map`.
6464
```julia
65-
# unknown variables are X, pars stores rate parameters for each rx
65+
# k is a vector of the parameters, with values given by the vector kv
66+
@parameters k[1:nr] = kv
67+
68+
# create the vector of species X_1,...,X_N
6669
t = default_t()
67-
@parameters k[1:nr]
6870
@species (X(t))[1:N]
69-
pars = Pair.(collect(k), kv)
7071

7172
# time-span
7273
if i == 1
@@ -78,7 +79,7 @@ end
7879
# initial condition of monomers
7980
u₀ = zeros(Int64, N)
8081
u₀[1] = uₒ
81-
u₀map = Pair.(collect(X), u₀) # map variable to its initial value
82+
u₀map = Pair.(collect(X), u₀) # map species to its initial value
8283
```
8384
Here we generate the reactions programmatically. We systematically create Catalyst `Reaction`s for each possible reaction shown in the figure on [Wikipedia](https://en.wikipedia.org/wiki/Smoluchowski_coagulation_equation). When `vᵢ[n] == vⱼ[n]`, we set the stoichiometric coefficient of the reactant multimer to two.
8485
```julia
@@ -100,7 +101,7 @@ We now convert the [`ReactionSystem`](@ref) into a `ModelingToolkit.JumpSystem`,
100101
```julia
101102
# solving the system
102103
jumpsys = convert(JumpSystem, rs)
103-
dprob = DiscreteProblem(jumpsys, u₀map, tspan, pars)
104+
dprob = DiscreteProblem(jumpsys, u₀map, tspan)
104105
jprob = JumpProblem(jumpsys, dprob, Direct(), save_positions = (false, false))
105106
jsol = solve(jprob, SSAStepper(), saveat = tspan[2] / 30)
106107
```

0 commit comments

Comments
 (0)