forked from SciML/ModelingToolkit.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistributed.jl
36 lines (26 loc) · 845 Bytes
/
distributed.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
32
33
34
35
36
using Distributed
# add processes to workspace
addprocs(2)
@everywhere using ModelingToolkit, OrdinaryDiffEq
# create the Lorenz system
@everywhere @parameters t σ ρ β
@everywhere @variables x(t) y(t) z(t)
@everywhere D = Differential(t)
@everywhere eqs = [D(x) ~ σ * (y - x),
D(y) ~ x * (ρ - z) - y,
D(z) ~ x * y - β * z]
@everywhere @named de = ODESystem(eqs)
@everywhere ode_func = ODEFunction(de, [x, y, z], [σ, ρ, β])
@everywhere u0 = [19.0, 20.0, 50.0]
@everywhere params = [16.0, 45.92, 4]
@everywhere ode_prob = ODEProblem(ode_func, u0, (0.0, 10.0), params)
@everywhere begin
using OrdinaryDiffEq
using ModelingToolkit
function solve_lorenz(ode_problem)
print(solve(ode_problem, Tsit5()))
end
end
solve_lorenz(ode_prob)
future = @spawn solve_lorenz(ode_prob)
@test_broken fetch(future)