Hi, I have a problem with using distributed solving ODEs, here is a simple example,
@everywhere begin
function test(dy, y, p, t)
a, b, c = p
dy[1] = a * y[1] + b * y[2] + c
dy[2] = b * y[2] + c * y[3] + a
dy[3] = c * y[3] + a * y[1] + b
end
end
@everywhere begin
function main(a, b, c)
tstart = 0.0
tend = 1.0e-2
tspan = (tstart, tend)
u0 = [0.0, 0.0, 1.0]
p = [a, b, c]
prob = ODEProblem(test, u0, tspan, p)
y = solve(prob, Tsit5())
return y[1, end]
end
end
using DifferentialEquations, LinearAlgebra, Distributed,SharedArrays
atemp = [1, 2, 3, 4, 5]
btemp = [2, 3, 4, 5, 6]
ctemp = [3, 4, 5, 6, 7]
#addprocs(2)
F = SharedVector{Float64}(5)
@distributed for i = 1:5
a = atemp[i]
b = btemp[i]
c = ctemp[i]
F[i] = main(a, b, c)
end
here is the error
Task (runnable) @0x0000000073511560
Unhandled Task ERROR: On worker 5:
UndefVarError: ODEProblem not defined
Anyone can show me how to solve this problem? Thanks~