# Saving a period of ODE solutions

**URL:** <https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278>\
**Category:** General Usage\
**Tags:** question, diffeq\
**Created:** [January 27, 2022, 9:55am UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278 "2022-01-27T09:55:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xspeng](https://avatars.discourse-cdn.com/v4/letter/x/90ced4/32.png) [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Post date:** [January 27, 2022, 9:55am UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278/1 "2022-01-27T09:55:23Z")

</div>

Hi, if I only want to save part of the solutions, how to realize it, for example,

```julia
function test(dy, y, p, t)
    a, b, c = p
    dy[1] = a * y[1] + b * y[2] + c
    dy[2] = b * y[2] + c * y[3] + a
    dy[3] = c * y[3] + a * y[1] + b
end

using DifferentialEquations, LinearAlgebra

tstart = 0.0
tend = 10
tspan = (tstart, tend)
u0 = [0.0, 0.0, 1.0]
a = 1.0
b = 2.0
c = 3.0
p = [a, b, c]

prob = ODEProblem(test, u0, tspan, p)
y = solve(prob, Tsit5())

```

for this simple ODEs, I only want the result from `t=5.0 to t=10..0`, saveat can save the output in a specific time, but I want a period of time, because I only need part of the solutions to do the post processing. Thanks in advance

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [January 27, 2022, 11:45am UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278/2 "2022-01-27T11:45:57Z")

</div>

Have a look at the output options [Common Solver Options (Solve Keyword Arguments) · DifferentialEquations.jl](https://diffeq.sciml.ai/latest/basics/common_solver_opts/#Output-Control)

---

<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:** [January 27, 2022, 12:16pm UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278/3 "2022-01-27T12:16:52Z")

</div>

> [@xspeng](#):
>
> for this simple ODEs, I only want the result from `t=5.0 to t=10..0` , saveat can save the output in a specific time, but I want a period of time, because I only need part of the solutions to do the post

If `saveat` is an `AbstractArray` then it will only save the values in that array. So `[5.0,6.0,7.0,8.0,9.0,10.0]` will save at those points in that period. Likewise, so will `5:1:10` etc.

---

<div class="post-metadata">

**Author:** ![xspeng](https://avatars.discourse-cdn.com/v4/letter/x/90ced4/32.png) [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Post date:** [January 27, 2022, 12:29pm UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278/4 "2022-01-27T12:29:09Z")

</div>

Thanks for reply, but that’s not what I want. Because in my real program, the time step is decided by the program and not equal, I just want the output of a period of time, since I initially I let the program to run for a certain time and reach to qusi-stady state and then use the solution in steady state to calculate the final result.  
Maybe I can run the OBEs twice, first period of time without save data, second time with save data

---

<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:** [January 27, 2022, 1:45pm UTC](https://discourse.julialang.org/t/saving-a-period-of-ode-solutions/75278/5 "2022-01-27T13:45:07Z")

</div>

> [@xspeng](#):
>
> Maybe I can run the OBEs twice, first period of time without save data, second time with save data

That might make sense.
