Skip to content

Instantly share code, notes, and snippets.

@ChrisRackauckas
Created December 17, 2018 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisRackauckas/fef4ae7778320530d44b0ff1ab54713a to your computer and use it in GitHub Desktop.
Save ChrisRackauckas/fef4ae7778320530d44b0ff1ab54713a to your computer and use it in GitHub Desktop.
using Sundials, DiffEqBase
function lorenz(du,u,p,t)
du[1] = 10.0*(u[2]-u[1])
du[2] = u[1]*(28.0-u[3]) - u[2]
du[3] = u[1]*u[2] - (8/3)*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz,u0,tspan)
sol = solve(prob,CVODE_Adams(),reltol=1e-12,abstol=1e-12)
prob2 = ODEProblem(lorenz,sol[end],(100.0,0.0))
sol = solve(prob,CVODE_Adams(),reltol=1e-12,abstol=1e-12)
@show sol[end]-u0 #[-17.5445, -14.7706, 39.7985]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment