Saving a period of ODE solutions

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

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

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

Have a look at the output options Common Solver Options · DifferentialEquations.jl

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.

1 Like

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

That might make sense.