|
33 | 33 | @continuous_events begin
|
34 | 34 | [V ~ 2.0] => [V ~ V/2, A ~ A/2]
|
35 | 35 | end
|
36 |
| - end |
37 |
| - jinput = JumpInputs(rn, [:A => 0, :V => 1.0], (0.0, 10.0), [:k => 1.0, :λ => .4], |
| 36 | + end |
| 37 | + jinput = JumpInputs(rn, [:A => 0, :V => 1.0], (0.0, 10.0), [:k => 1.0, :λ => .4], |
38 | 38 | remake_warn = false)
|
39 | 39 | @test jinput.prob isa ODEProblem
|
40 | 40 | jprob = JumpProblem(jinput; rng)
|
41 |
| - sol = solve(jprob, Tsit5()) |
| 41 | + sol = solve(jprob, Tsit5()) |
42 | 42 | end
|
43 | 43 |
|
44 | 44 | # solution correctness tests
|
|
47 | 47 | Random.seed!(rng, seed)
|
48 | 48 | rn = @reaction_network begin
|
49 | 49 | β, X --> 0
|
50 |
| - β, Y --> 0 |
| 50 | + β, Y --> 0 |
51 | 51 | α, 0 --> Y
|
52 | 52 | (α * (1 + Y)), 0 --> X, [physical_scale = PhysicalScale.ODE]
|
53 |
| - end |
| 53 | + end |
54 | 54 | p = (α = 6.0, β = 2.0, X₀ = 2.0, Y₀ = 1.0)
|
55 | 55 | u0map = [:X => p.X₀, :Y => p.Y₀]
|
56 | 56 | pmap = [:α => p.α, :β => p.β]
|
57 | 57 | tspan = (0.0, 20.0)
|
58 | 58 | jinputs = JumpInputs(rn, u0map, tspan, pmap; save_positions = (false, false))
|
59 | 59 | jprob = JumpProblem(jinputs; rng, save_positions = (false, false))
|
60 | 60 | times = range(0.0, tspan[2], length = 100)
|
61 |
| - Nsims = 4000 |
| 61 | + Nsims = 4000 |
62 | 62 | Xv = zeros(length(times))
|
63 | 63 | Yv = zeros(length(times))
|
64 | 64 | for n in 1:Nsims
|
|
91 | 91 | end
|
92 | 92 | rn = @network_component begin
|
93 | 93 | β, X --> 0
|
94 |
| - β, Y --> 0 |
| 94 | + β, Y --> 0 |
95 | 95 | α, 0 --> Y
|
96 | 96 | (α * (1 + Y)), 0 --> X, [physical_scale = PhysicalScale.ODE]
|
97 |
| - end |
| 97 | + end |
98 | 98 | t = Catalyst.default_t()
|
99 | 99 | cevents = [t ~ 0.2] => (affect!, [], [], [], nothing)
|
100 | 100 | @named rn2 = ReactionSystem([], t; continuous_events = cevents)
|
|
116 | 116 |
|
117 | 117 | # Checks that a disjoint hybrid model (i.e. where the Jump and ODE parts do not interact) gives the
|
118 | 118 | # same results as simulating the two parts separately.
|
119 |
| -let |
| 119 | +let |
120 | 120 | # Creates the disjoint ODE/Jump models, and the hybrid model combining both.
|
121 | 121 | rn_ode = @reaction_network begin
|
122 | 122 | A, ∅ → X
|
@@ -144,10 +144,10 @@ let
|
144 | 144 | ps_ode = [:A => 1.0, :B => 4.0]
|
145 | 145 | ps_jump = [:p => 2.0, :d => 0.1, :k1 => 0.2, :k2 => 1.0]
|
146 | 146 | ps_hybrid = [ps_ode; ps_jump]
|
147 |
| - tspan = (0.0, 1000.0) |
| 147 | + tspan = (0.0, 10000.0) |
148 | 148 | ode_prob = ODEProblem(rn_ode, u0_ode, tspan, ps_ode)
|
149 |
| - jump_prob = JumpProblem(JumpInputs(rn_jump, u0_jump, tspan, ps_jump; remake_warn = false); save_positions = (false,false)) |
150 |
| - hybrid_prob = JumpProblem(JumpInputs(rn_hybrid, u0_hybrid, tspan, ps_hybrid; remake_warn = false); save_positions = (false,false)) |
| 149 | + jump_prob = JumpProblem(JumpInputs(rn_jump, u0_jump, tspan, ps_jump; remake_warn = false); save_positions = (false,false), rng) |
| 150 | + hybrid_prob = JumpProblem(JumpInputs(rn_hybrid, u0_hybrid, tspan, ps_hybrid; remake_warn = false); save_positions = (false,false), rng) |
151 | 151 |
|
152 | 152 | # Performs simulations. Checks that ODE parts are identical. Check that jump parts have similar statistics.
|
153 | 153 | ode_sol = solve(ode_prob, Tsit5(); saveat = 1.0, abstol = 1e-10, reltol = 1e-10)
|
|
246 | 246 | # Checks that various model options (observables, events, defaults and metadata, differential equations,
|
247 | 247 | # non-default_iv) works for hybrid models.
|
248 | 248 | let
|
249 |
| - # Creates the model (X species is pure jump, Y is pure ODE, and Z1,Z2 are mixed). |
250 |
| - # Hybrid species have non-constant rates containing the two other species. |
| 249 | + # Creates the model (X species is pure jump, Y is pure ODE, and Z1,Z2 are mixed). |
| 250 | + # Hybrid species have non-constant rates containing the two other species. |
251 | 251 | rn = @reaction_network begin
|
252 | 252 | @ivs τ
|
253 | 253 | @differentials Δ = Differential(τ)
|
|
282 | 282 | end
|
283 | 283 |
|
284 | 284 | # Checks the types of species when various combinations of default/non-default types are used.
|
285 |
| -let |
| 285 | +let |
286 | 286 | # Creates model and parameter set. Model have one pure ODE and one pure Jump species.
|
287 | 287 | rn = @reaction_network begin
|
288 | 288 | d, X --> 0
|
|
0 commit comments