# Integratror interface skips timesteps in DifferentialEquations.jl?

**URL:** <https://discourse.julialang.org/t/integratror-interface-skips-timesteps-in-differentialequations-jl/114789>\
**Category:** General Usage\
**Tags:** question, sciml, differentialequation\
**Created:** [May 27, 2024, 3:11pm UTC](https://discourse.julialang.org/t/integratror-interface-skips-timesteps-in-differentialequations-jl/114789 "2024-05-27T15:11:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flmuk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/flmuk/32/204871_2.png) [@flmuk](https://discourse.julialang.org/u/flmuk)\
**Post date:** [May 27, 2024, 3:11pm UTC](https://discourse.julialang.org/t/integratror-interface-skips-timesteps-in-differentialequations-jl/114789/1 "2024-05-27T15:11:33Z")

</div>

Hello,  
I have a question about the [integrator interface of the DifferentialEquations](https://docs.sciml.ai/DiffEqDocs/stable/basics/integrator/) package. I want to step through the solution process of a set of coupled ODEs (to wich I want to add a nonlinearity that I can’t use a callback for).  
My issue is the following: the documentation gives the possibility of solving the integration problem step by step via

```julia
for i in integrator
end

```

**However, it only exposes every second integration step.** Why is this? How can I get access to every integration step?

Here is some sample code to demonstrate this:

```julia
using DifferentialEquations
#using CairoMakie for plotting

function dynamics!(du,u,p,t)
    du[1] = 1. 
end

begin
    u0 = [0.]
    t = 1.
    dt = 0.1
    tspan = (0., t)

    prob = ODEProblem(dynamics!, u0, tspan, dt = dt);
    integrator = init(prob, Euler(), save_everystep=true)

    for i in integrator #simulation loop
        @show i, integrator.iter
        step!(integrator)  
    end
    usol = [x[1] for x in integrator.sol.u]
end

""" #for plotting
begin
    f= Figure()
    ax = Axis(f[1,1])
    lines!(integrator.sol.t,usol, label = "u")
    axislegend(ax)
    display(f)
end
"""

```

The output of the above code is the following:

```julia
(i, integrator.iter) = (t: 0.1; u: [0.1], 1)
(i, integrator.iter) = (t: 0.30000000000000004; u: [0.30000000000000004], 3)
(i, integrator.iter) = (t: 0.5; u: [0.5], 5)
(i, integrator.iter) = (t: 0.7; u: [0.7], 7)
(i, integrator.iter) = (t: 0.8999999999999999; u: [0.8999999999999999], 9)

```

As one can see, the integrator only exposes uneven integration steps. Why only uneven steps? Is there an option to expose all integration steps?

---

<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:** [May 27, 2024, 4:14pm UTC](https://discourse.julialang.org/t/integratror-interface-skips-timesteps-in-differentialequations-jl/114789/2 "2024-05-27T16:14:33Z")

</div>

`step!(integrator)` is advancing the integrator by a step. Remove that line and everything will work.
