Skip to content

Commit d2b8957

Browse files
authored
Merge pull request #1255 from SciML/fix_hybrid_test
Fix ocasional hybrid test failure
2 parents 0b15ca1 + aa10184 commit d2b8957

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/simulation_and_solving/hybrid_models.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ let
3333
@continuous_events begin
3434
[V ~ 2.0] => [V ~ V/2, A ~ A/2]
3535
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],
3838
remake_warn = false)
3939
@test jinput.prob isa ODEProblem
4040
jprob = JumpProblem(jinput; rng)
41-
sol = solve(jprob, Tsit5())
41+
sol = solve(jprob, Tsit5())
4242
end
4343

4444
# solution correctness tests
@@ -47,18 +47,18 @@ let
4747
Random.seed!(rng, seed)
4848
rn = @reaction_network begin
4949
β, X --> 0
50-
β, Y --> 0
50+
β, Y --> 0
5151
α, 0 --> Y
5252
* (1 + Y)), 0 --> X, [physical_scale = PhysicalScale.ODE]
53-
end
53+
end
5454
p == 6.0, β = 2.0, X₀ = 2.0, Y₀ = 1.0)
5555
u0map = [:X => p.X₀, :Y => p.Y₀]
5656
pmap = [ => p.α, => p.β]
5757
tspan = (0.0, 20.0)
5858
jinputs = JumpInputs(rn, u0map, tspan, pmap; save_positions = (false, false))
5959
jprob = JumpProblem(jinputs; rng, save_positions = (false, false))
6060
times = range(0.0, tspan[2], length = 100)
61-
Nsims = 4000
61+
Nsims = 4000
6262
Xv = zeros(length(times))
6363
Yv = zeros(length(times))
6464
for n in 1:Nsims
@@ -91,10 +91,10 @@ let
9191
end
9292
rn = @network_component begin
9393
β, X --> 0
94-
β, Y --> 0
94+
β, Y --> 0
9595
α, 0 --> Y
9696
* (1 + Y)), 0 --> X, [physical_scale = PhysicalScale.ODE]
97-
end
97+
end
9898
t = Catalyst.default_t()
9999
cevents = [t ~ 0.2] => (affect!, [], [], [], nothing)
100100
@named rn2 = ReactionSystem([], t; continuous_events = cevents)
@@ -116,7 +116,7 @@ end
116116

117117
# Checks that a disjoint hybrid model (i.e. where the Jump and ODE parts do not interact) gives the
118118
# same results as simulating the two parts separately.
119-
let
119+
let
120120
# Creates the disjoint ODE/Jump models, and the hybrid model combining both.
121121
rn_ode = @reaction_network begin
122122
A, ∅ X
@@ -144,10 +144,10 @@ let
144144
ps_ode = [:A => 1.0, :B => 4.0]
145145
ps_jump = [:p => 2.0, :d => 0.1, :k1 => 0.2, :k2 => 1.0]
146146
ps_hybrid = [ps_ode; ps_jump]
147-
tspan = (0.0, 1000.0)
147+
tspan = (0.0, 10000.0)
148148
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)
151151

152152
# Performs simulations. Checks that ODE parts are identical. Check that jump parts have similar statistics.
153153
ode_sol = solve(ode_prob, Tsit5(); saveat = 1.0, abstol = 1e-10, reltol = 1e-10)
@@ -246,8 +246,8 @@ end
246246
# Checks that various model options (observables, events, defaults and metadata, differential equations,
247247
# non-default_iv) works for hybrid models.
248248
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.
251251
rn = @reaction_network begin
252252
@ivs τ
253253
@differentials Δ = Differential(τ)
@@ -282,7 +282,7 @@ let
282282
end
283283

284284
# Checks the types of species when various combinations of default/non-default types are used.
285-
let
285+
let
286286
# Creates model and parameter set. Model have one pure ODE and one pure Jump species.
287287
rn = @reaction_network begin
288288
d, X --> 0

0 commit comments

Comments
 (0)