Hi,
I am running a two differential equations over a range of parameters, and it works fine. I loop over two parameters (double loop). I would like to know the Julia way of doing this. Here is my code.
Run all α, β pairs
println(αs)
sols = Any
for α ∈ αs
for β ∈ βs
p1 = [α, β, 8., 5.] # α, β, D1, D2
println("α, β= ", α, β)
prob = ODEProblem(coupled!, u0, tspan, p1)
sol = solve(prob, Tsit5())
println("sol: ", size(sol))
append!(sols, [sol]) # <<< NOTICE
end
end
plot([sols[1]])
Notice the use of “append!”. “sol” is the output to “solve”, and I wish to concatenate the solutions into a Vector of four elements. To do this and properly access the variables, I had to enclose “sol” with brackets. If I do not do this, size(sols) returns 84 instead of 4. I do not quite understand why.
Next step, DiffEqFlux perhaps, which is my ultimate goal for now.
I will read the link. I did not think a MWE was necessary in this case since the code worked properly, and I was only asking for an alternative to the section I posted.
But I will do so next time.
The map solution does not work. If as=[1,2] and bs=[3,4], I expect to iterate over the combinations (1,3), (1,4), (2,3), (2,4). Your approach loops over (1,3) and (2,4).
Probably the OP has already considered this himself, and it also depends a bit on his particular purpose, but instead of creating simulations over a parameter grid, it may be more elegant and provide more insight to use a numerical continuation package.
(This is particularly true if you are interested in stability and destabilization of simple invariants such as stationary and periodic solutions.)
Right now, I am learning Julia, but I would be interested in a continuation package to study a system of reaction/diffusion equations. Could you point me to the latest stable resources? Thanks.
Although it overlaps with packages that I am familiar with (AUTO, MATCONT) or involved with (DDE-BIFTOOL), I think it is only fair to point you to PseudoArcLengthContinuation.jl for a project by @rveltz specifically in Julia. Hope, that helps, and enjoy the learning.