Skip to content

Commit 24fe115

Browse files
authored
Merge branch 'master' into noise_hygiene
2 parents 1666719 + ee5d071 commit 24fe115

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/solve.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,15 @@ function DiffEqBase.__init(
413413
end
414414
elseif typeof(prob) <: DiffEqBase.AbstractRODEProblem
415415
W = deepcopy(prob.noise)
416-
if hasfield(typeof(W),:t) && W.reset
417-
if W.t[end] != t
418-
reinit!(W,t, t0=t)
416+
if W.reset
417+
if W.curt != t
418+
reinit!(W,t,t0=t)
419419
end
420420
# Reseed
421421
if typeof(W) <: NoiseProcess && W.reseed
422422
Random.seed!(W.rng,_seed)
423423
end
424-
elseif hasfield(typeof(W),:t) && W.t[end] != t
424+
elseif W.curt != t
425425
error("Starting time in the noise process is not the starting time of the simulation. The noise process should be re-initialized for repeated use")
426426
end
427427
else # Only a jump problem

test/noise_type_test.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,24 @@ end
5151
prob = SDEProblem(f,g,ones(2),(0.0,1.0),noise_rate_prototype=sprand(2,4,1.0))
5252

5353
sol = solve(prob,EM(),dt=1/1000)
54-
5554
@test length(sol.W[1]) == 4
5655

56+
sol2 = solve(prob,EM(),dt=1/1000)
57+
@test sol.W.curt sol2.W.curt 1.0
58+
5759
ff = (u,p,t) -> exp(t)
5860
W = NoiseFunction(0.0,ff)
5961
drift(u,p,t) = u
6062
vol(u,p,t) = u
6163
dt = 0.01
6264
tspan = (0.0,1.0)
6365
u0 = 0.0
64-
prob = SDEProblem(drift,vol,u0,(0.0,1.0), noise=W)
66+
prob = SDEProblem(drift,vol,u0,tspan, noise=W)
6567
sol = solve(prob,EM(),dt=0.1)
68+
@test sol.W.curt last(tspan)
69+
sol2 = solve(prob,EM(),dt=0.1)
70+
@test sol2.W.curt last(tspan)
71+
tspan = (0.0,2.0)
72+
prob = SDEProblem(drift,vol,u0,tspan, noise=W)
73+
sol = solve(prob,EM(),dt=0.01)
74+
@test sol.W.curt last(tspan)

0 commit comments

Comments
 (0)