# Maximum timestep in DIfferential solver

**URL:** <https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135>\
**Category:** Numerics\
**Tags:** differentialequation\
**Created:** [June 10, 2023, 11:04am UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135 "2023-06-10T11:04:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarthak\_Choudhury](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarthak_choudhury/32/18593_2.png) [@Sarthak\_Choudhury](https://discourse.julialang.org/u/Sarthak_Choudhury)\
**Post date:** [June 10, 2023, 11:04am UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135/1 "2023-06-10T11:04:52Z")

</div>

Hi,

I am currently solving an ODE in DifferentialEquations.jl which has explicit time dependence. I arrive at a solution for a larger time t\_{max} with the solution saved at 1000 time points in between. Now I want to zoom in the time evolution between t\_1 and t\_2 where 0\<t\_1\<t\_2\<t\_{max}. Now since I have saved the solution at t\_1 using `saveat` option, I start the ode at t\_1 and run it to t\_2 with a 1000 timepoints to see what is happening in between. The solution at t\_2 differs from the longer run. I think it is a consequence of the time dependence of the problem and I think the integrator is taking timesteps which does not give it a stable solution in one of the cases.

My solution is to make the integrator take smaller steps such that this might not happen. The easiest way to do this would be to increase relative and absolute tolerance but this increases the runtime by quite a lot. Going up to `abstol=reltol`=10^{-7} the problem did not resolve itself. I was wondering if one could force the integrator to take smaller timesteps than dt\_{cont} for both runs on top of the adaptive timestep. If anyone could help me either with the timestep implementation on top of the adaptive timestep or anything that I am missing in my problem I would be very grateful.

Thanks,

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [June 10, 2023, 2:14pm UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135/2 "2023-06-10T14:14:13Z")

</div>

integrators store an interpolation, so you can see the value between samples.

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [June 10, 2023, 2:27pm UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135/4 "2023-06-10T14:27:24Z")

</div>

> [@Sarthak\_Choudhury](#):
>
> The solution at t\_2t2t\_2 differs from the longer run. I think it is a consequence of the time dependence of the problem

I am not sure I understand the issue here. Numerical algorithms for ODEs return approximations of the true solution. The quality of such approximations is determined by the parameters of the algorithm, the sizes of the time steps belonging to these parameters. That the solutions for different parameters do not agree is not a consequence of the properties of the problem but rather the (parameters of the) method.

If you want to impose an upper bound on the size of the steps for an algorithm with an adaptive step-size control, there is the `dtmax` keyword. See the section “Basic stepsize control” at [Common Solver Options (Solve Keyword Arguments) · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/).

---

<div class="post-metadata">

**Author:** ![Sarthak\_Choudhury](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarthak_choudhury/32/18593_2.png) [@Sarthak\_Choudhury](https://discourse.julialang.org/u/Sarthak_Choudhury)\
**Post date:** [June 10, 2023, 4:51pm UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135/5 "2023-06-10T16:51:16Z")

</div>

True. But my gridsize and time evolution is pretty large so I have turned off the interpolation since the system runs out of memory in that case. Thanks for the suggestion.

---

<div class="post-metadata">

**Author:** ![Sarthak\_Choudhury](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarthak_choudhury/32/18593_2.png) [@Sarthak\_Choudhury](https://discourse.julialang.org/u/Sarthak_Choudhury)\
**Post date:** [June 10, 2023, 5:11pm UTC](https://discourse.julialang.org/t/maximum-timestep-in-differential-solver/100135/6 "2023-06-10T17:11:19Z")

</div>

Thanks for the `dtmax` keyword. I had missed it completely while looking through the excellent documentation. Have to see if this solves the problem.

I agree that the parameters of the method are essential for the solution. My ode function depends on the instanteneous time at which the function is being evaluated. So if I run the time evolution from 0 to t\_{max} then ideally it should go through the times t\_1, t\_2 and converge to a solution. Ideally I should get the same solution if I only time evolve from t\_1 to t\_2 where 0\<t\_1\<t\_2\<t\_{max}.
