-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
solve.jl
31 lines (30 loc) · 1009 Bytes
/
solve.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function DiffEqBase.__solve(prob::AbstractNoiseProblem,
args::Union{Nothing, SciMLBase.DEAlgorithm}...; dt = 0.0,
kwargs...)
if dt == 0.0 || dt == nothing
error("dt must be provided to simulate a noise process. Please pass dt=...")
end
W = copy(prob.noise)
if W isa Union{NoiseProcess, NoiseTransport}
if prob.seed != 0
Random.seed!(W.rng, prob.seed)
else
Random.seed!(W.rng, rand(UInt64))
end
end
if W.reset
reinit!(W, dt, t0 = prob.tspan[1])
end
setup_next_step!(W, nothing, nothing)
tType = typeof(W.curt)
while W.curt < prob.tspan[2]
if tType <: AbstractFloat && abs(W.curt + dt - prob.tspan[2]) < 100 * eps(dt) # Correct the end due to floating point error
dt = prob.tspan[2] - W.curt
accept_step!(W, dt, nothing, nothing)
W.curt = prob.tspan[2]
else
accept_step!(W, dt, nothing, nothing)
end
end
W
end