Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsas committed Sep 2, 2024
1 parent 3f74888 commit 7be0f01
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/variable_rate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ let
@test allunique(sjm_prob.prob.u0.jump_u)
u0old = copy(sjm_prob.prob.u0.jump_u)
for i in 1:Nsims
sol = solve(sjm_prob, Tsit5(); saveat = tspan[2])
sol = solve(sjm_prob, Tsit5(); saveat = tspan[2])
@test allunique(sjm_prob.prob.u0.jump_u)
@test all(u0old != sjm_prob.prob.u0.jump_u)
u0old .= sjm_prob.prob.u0.jump_u
Expand All @@ -279,12 +279,12 @@ let
rng = StableRNG(12345)
b = 2.0
d = 1.0
n0 = 1
n0 = 1
tspan = (0.0, 4.0)
Nsims = 10000
n(t) = n0 * exp((b - d)*t)
n(t) = n0 * exp((b - d) * t)
u0 = [n0]
p = [b,d]
p = [b, d]

function ode_fxn(du, u, p, t)
du .= 0
Expand All @@ -293,7 +293,7 @@ let

b_rate(u, p, t) = (u[1] * p[1])
function birth!(integrator)
integrator.u[1] += 1
integrator.u[1] += 1
nothing
end
b_jump = VariableRateJump(b_rate, birth!)
Expand All @@ -307,13 +307,13 @@ let

ode_prob = ODEProblem(ode_fxn, u0, tspan, p)
sjm_prob = JumpProblem(ode_prob, b_jump, d_jump; rng)
dt = .1
dt = 0.1
tsave = range(tspan[1], tspan[2]; step = dt)
umean = zeros(length(tsave))
for i in 1:Nsims
sol = solve(sjm_prob, Tsit5(); saveat = dt)
umean .+= Array(sol(tsave; idxs = 1))
end
umean ./= Nsims
@test all(abs.(umean .- n.(tsave)) .< .05 * n.(tsave))
end
@test all(abs.(umean .- n.(tsave)) .< 0.05 * n.(tsave))
end

0 comments on commit 7be0f01

Please sign in to comment.