# Printing progress and updates messages SDE problem

**URL:** <https://discourse.julialang.org/t/printing-progress-and-updates-messages-sde-problem/112277>\
**Category:** General Usage\
**Tags:** sde\
**Created:** [March 29, 2024, 10:17am UTC](https://discourse.julialang.org/t/printing-progress-and-updates-messages-sde-problem/112277 "2024-03-29T10:17:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt1](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@matt1](https://discourse.julialang.org/u/matt1)\
**Post date:** [March 29, 2024, 10:17am UTC](https://discourse.julialang.org/t/printing-progress-and-updates-messages-sde-problem/112277/1 "2024-03-29T10:17:08Z")

</div>

Hello,  
I’m solving a system of stochastic differential equations:

```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](https://docs.sciml.ai/DiffEqDocs/stable/features/progress_bar/) 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”:

```julia
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](https://www.juliabloggers.com/6-months-of-differentialequations-jl-where-we-are-and-where-we-are-going/) 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!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 6, 2024, 3:37pm UTC](https://discourse.julialang.org/t/printing-progress-and-updates-messages-sde-problem/112277/2 "2024-04-06T15:37:26Z")

</div>

> [@matt1](#):
>
> I read [here](https://www.juliabloggers.com/6-months-of-differentialequations-jl-where-we-are-and-where-we-are-going/) 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.

> **[Common Solver Options (Solve Keyword Arguments) · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)**
>
> Documentation for DifferentialEquations.jl.

```julia
function prog_message(dt, u, p, t)
    "Print a message here for the progress bar"
end
solution=solve(problem,SOSRA(),reltol=1e-3,abstol=1e-3,save_everystep = false,progress_true,progress_steps=1000, progress_message = prog_message) 

```

> [@matt1](#):
>
> 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?

You can use a DiscreteCallback with `condition=true` so it launches after each step and just write any function into the `affect!` to perform the logging. See:

> **[Event Handling and Callback Functions · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)**
>
> Documentation for DifferentialEquations.jl.
