juliadifferential-equationsstochastic-processdifferentialequations.jl

Getting updates from SDE solver in Julia


I'm solving a system of stochastic differential equations in Julia:

#define drift fuction
F!(du,u,t,p)=...
#define noise function 
G!(du,u,t,p)=...

#constructing and solving the problem

u_0=zeros(100,100)#initial condition
tspan=(0.0,10.0)
problem=SDEProblem(F!,G!,u_0,tspan,p)

solution=solve(problem,SOSRA(),reltol=1e-3,abstol=1e-3,save_everystep = false) 

Now, I read here that you can use the keyword argument "progress" to get updates on the remaining number of seconds to complete the run, and you can get this information with a frequency set by the argument "progress_steps":

solution=solve(problem,SOSRA(),reltol=1e-3,abstol=1e-3,save_everystep = false,progress=true,progress_steps=1000) 

However, I would be interested in getting more detailed updates from the solver, like current chosen $dt$ (for adaptive algorithm), current time $t$, and current maximum value of the solution $u_{max}$. I read here that this should be possible with "progress_message" at least for ODE's. However I don't know the precise syntax to make it work. Also, I would like to possibly print these updates into a .txt file rather than having them in the terminal. Is there a way to do that? Thanks!

I've tried

solution=solve(problem,SOSRA(),reltol=1e-3,abstol=1e-3,save_everystep = false, progress=true,progress_message=true) 

But it gives an error


Solution

  • You likely want to use the lower level init and step! interface.

    Specifically,

    integrator = init(problem,SOSRA(),reltol=1e-3,abstol=1e-3)
    step!(integrator) # takes 1 timestep
    step!(integrator, .4) # steps until t==0.4