Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Solving and ODE system starting from different initial points

$
0
0

@cshen wrote:

Hello,

I have a simple system of which i would like to build the phase portrait.
I thought of creating a mesh of interesting points and solve the problem for each of them.
This is what i naively tried until now but it does not work.

xs = -0.5:0.1:1.5
ys = -0.5:0.1:3
u0s = [[x,y] for x in xs, y in ys]
tspan = (0.0, 200.0)
λ = 0
prob = ODEProblem(f, u0s, tspan, λ)
sol = solve(prob, progress=true)

I could not find anything specific in the documentation on how to approach this problem, i know about remake but i am not sure if it is useful or a good idea to use it with so many new initialisations.

Could a for loop work where every time i store the solution for every initial point?
something on the likes of

for u0 in u0s
    sol = solve(remake(prob; u0=u0))
end

and then store sol somewhere for later access and/or plotting.
(in this case, how do i store the solutions correctly?)

Any smarter ideas, this feels really dumb.

Thanks!

EDIT: added the fix in the second answer

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles