Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit Euler and @btime report Warning: Instability detected. Aborting #921

Closed
malinjlu opened this issue Jan 2, 2023 · 1 comment
Closed

Comments

@malinjlu
Copy link

malinjlu commented Jan 2, 2023

using DifferentialEquations
using Plots
using BenchmarkTools

function f1(du,u,p,t)
du[1] = u[2]
du[2] = -u[1]-0.15u[2]
du[3] = u[2]+2
u[3]
du[4] = -u[3]+0.8u[4]
du[5] = 0.3
u[4]+u[5]
du[6] = u[5]+0.8u[6]
du[7] = -u[6]+u[7]
du[8] = u[7]-u[8]
du[9] = 3
u[8]-u[9]
du[10] = u[9]-u[10]
end

function j!(J, x)
for i=1:10
for j=1:10
J[i,j]=0
end
end
J[1,2] = 1
J[2,1] = -1
J[2,2] =-0.15
J[3,2] = 1
J[3,3] = 2
J[4,3] =-1
J[4,4] =0.8
J[5,4] =0.3
J[5,5] =1
J[6,5]=1
J[6,6]=0.8
J[7,6]=-1
J[7,7]=1
J[8,7]=1
J[8,8]=-1
J[9,8]=3
J[9,9]=-1
J[10,9]=1
J[10,10]=-1
end

u0 = [1.0;0.0;0.0;1.0;0.5;-0.3;1.0;0.5;-0.3;-0.1]
tspan = (0.0,10000.0)

f=ODEFunction(f1;jac_prototype=j!)
prob=ODEProblem(f,u0,tspan)

sol= solve(prob,ImplicitEuler(autodiff=false,diff_type=Val{:central}))

print("end solve!!!!")


I use Implicit Euler to solve the ODEs, but it shows that

Warning: Instability detected. Aborting
└ @ SciMLBase C:\Users\PC.julia\packages\SciMLBase\QqtZA\src\integrator_interface.jl:525

Interpolation: 3rd order Hermite

when I use @Btime, not the implicit euler.

@ChrisRackauckas
Copy link
Member

Yes, the solution blows up to infinity in finite time. It has an analytical solution:

A = zeros(10,10)
j!(A, nothing)
t = 50
exp(A*t)*u0

so it's clearly just a property of the solution (can also just be checked by the unstable eigenvalues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants