Skip to content

Commit 9a78fe6

Browse files
test: test initialization of DiscreteProblem(::JumpSystem)
1 parent 3ea956c commit 9a78fe6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/initializationsystem.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,3 +1306,24 @@ end
13061306
@test integ[X] 4.0
13071307
@test integ[Y] 7.0
13081308
end
1309+
1310+
@testset "Issue#3297: `generate_initializesystem(::JumpSystem)`" begin
1311+
@parameters β γ S0
1312+
@variables S(t)=S0 I(t) R(t)
1313+
rate₁ = β * S * I
1314+
affect₁ = [S ~ S - 1, I ~ I + 1]
1315+
rate₂ = γ * I
1316+
affect₂ = [I ~ I - 1, R ~ R + 1]
1317+
j₁ = ConstantRateJump(rate₁, affect₁)
1318+
j₂ = ConstantRateJump(rate₂, affect₂)
1319+
j₃ = MassActionJump(2 * β + γ, [R => 1], [S => 1, R => -1])
1320+
@mtkbuild js = JumpSystem([j₁, j₂, j₃], t, [S, I, R], [β, γ, S0])
1321+
1322+
u0s = [I => 1, R => 0]
1323+
ps = [S0 => 999, β => 0.01, γ => 0.001]
1324+
dprob = DiscreteProblem(js, u0s, (0.0, 10.0), ps)
1325+
@test dprob.f.initialization_data !== nothing
1326+
sol = solve(dprob, FunctionMap())
1327+
@test sol[S, 1] 999
1328+
@test SciMLBase.successful_retcode(sol)
1329+
end

0 commit comments

Comments
 (0)