@erlebach wrote:
Hi,
I have a simple function to solve:
using DifferejntialEquations, Plots, BenchmarkTools var = [] function coupledd!(du, u, p, t) α, β, D1, D2 = p c1, c2 = u dc1 = α*c1 + D1 * (c2-c1) dc2 = β*c2 + D2 * (c1-c2) push!(var, c2) du .= [dc1, dc2] # note the broadcast operator! end u0 = rand(2) tspan = (0.,10.) pars = [-.2, -.1, 1., 1.] prob = ODEProblem(coupledd!, u0, tspan, pars) sol = solve(prob, Tsit5()) println("size(var)= ", size(var)) println("nb time steps= ", size(sol.t))
size(var) returns 696
size(sol.t) return 12However, when I print var, I get the output:
87-element Array{Any,1}which seems to imply that Tsit5() calls the right-hand side 8 times every time step.
What I am interested in is the value of a variable at every time step (once per time step). So I would like to monitor variables. Is there a facility for that? Thanks.
Gordon
Posts: 5
Participants: 3