The ODEs I’m solving typically takes an hour and I would like it to print the current time step for every, e.g. 10 time steps. I have tried the method shown on this page about progress bar, but it doesn’t work (i.e. nothing is displayed) on both VS Code and jupyter notebook. Then I tried using a discrete callback with the following codes:
function lorenz!(du, u, p, t) du = 10.0 * (u - u) du = u * (28.0 - u) - u du = u * u - (8 / 3) * u end u0 = [1.0; 0.0; 0.0] tspan = (0.0, 100.0) prob = ODEProblem(lorenz!, u0, tspan); function do_nth!(integrator) println(@sprintf("no. of time steps : %4d, t = %.3e", length(integrator.sol.t), integrator.t)) return nothing end condition1(u, t, integrator) = (mod(length(integrator.sol.t), 50) == 0) # triggered every 50 time steps cb1 = DiscreteCallback(condition1, do_nth!; save_positions=(false,false)); sol1 = solve(prob, FBDF(autodiff=true)) sol2 = solve(prob, FBDF(autodiff=true), callback=cb1)
FBDF(autodiff=true) in the above code because that’s the specific solver I will be using for my actual ODE. Now the problem is that
sol2 give different solution, and by comparing the second component of the solution to the example in the documentation, it looks like
sol2 (the one with the callback) is wrong. So what else did I do wrong? What’s the best way to show the progress every X time steps?