# Output automatic time steps taken by solvers while specifying \`saveat\`

**URL:** https://discourse.julialang.org/t/output-automatic-time-steps-taken-by-solvers-while-specifying-saveat/104578
**Category:** Numerics
**Tags:** differentialequation, ordinarydiffeq
**Created:** [October 4, 2023, 4:07pm UTC](https://discourse.julialang.org/t/output-automatic-time-steps-taken-by-solvers-while-specifying-saveat/104578 "2023-10-04T16:07:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yhchang96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yhchang96/32/36499_2.png) [@yhchang96](https://discourse.julialang.org/u/yhchang96)
#### Post date: [October 4, 2023, 4:07pm UTC](https://discourse.julialang.org/t/output-automatic-time-steps-taken-by-solvers-while-specifying-saveat/104578/1 "2023-10-04T16:07:25Z")

</div>

Many solvers in `OrdinaryDiffEq.jl` for solving stiff ODEs use automatic time-stepping. From what I understand, if I specify `saveat`, then `sol.t` is the time steps I specify in `saveat`, and if I leave `saveat` untouched, then `sol.t` is the time steps taken by the solver. Is there a way save the automatic time steps chosen by the solver, and output the solutions for only the specified time (given through `saveat`)? A slightly question is what’s the way to do solution handling (e.g. computing the maximum and minimum) during the computation at the automatic time steps chosen by the solver.

For example, suppose the solver automatically chooses some time steps (let’s call them `t_auto`). I want to know `t_auto`, and preferably `maximum(u)`, `minimum(u)`, `f(t,u,par)` (for some user-defined function `f`) at `t_auto`, but I don’t need the full solution `u` at `t_auto` (because of memory issue for instance). However, I do want to know the full solution `u` at the user-specified times given through `saveat`. What’s the appropriate way to handle this?

---

<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: [October 4, 2023, 6:26pm UTC](https://discourse.julialang.org/t/output-automatic-time-steps-taken-by-solvers-while-specifying-saveat/104578/2 "2023-10-04T18:26:06Z")

</div>

> [@yhchang96](#):
>
> Is there a way save the automatic time steps chosen by the solver, and output the solutions for only the specified time (given through `saveat`)?

`save_everystep=true, saveat = x`

> [@yhchang96](#):
>
> A slightly question is what’s the way to do solution handling (e.g. computing the maximum and minimum) during the computation at the automatic time steps chosen by the solver.

Use a discrete callback where the condition is always true.

> [@yhchang96](#):
>
> For example, suppose the solver automatically chooses some time steps (let’s call them `t_auto`). I want to know `t_auto`, and preferably `maximum(u)`, `minimum(u)`, `f(t,u,par)` (for some user-defined function `f`) at `t_auto`, but I don’t need the full solution `u` at `t_auto` (because of memory issue for instance).

FunctionCallingCallback, SavingCallback.
