I am trying to solve a Kramer-type SDE, simulating a particle in a double well.
I use the DifferentialEquations package and it all works well until the particle reaches the top of the barrier and start rolling down, at which point understandably Julia stops and issues the warning
┌ Warning: Interrupted. Larger maxiters is needed.
└ @ DiffEqBase C:\Users\Musto Family.julia\packages\DiffEqBase\gQwlE\src\integrator_interface.jl:319
The question is, is there a way to stop the solution after a certain condition is attained?
For example, in the simple test case I describe below, I use a double well potential
and once the position is well past the top of the barrier at approx. 0.707, the solution should be stopped.
The general problem I have in mind is more complex and the condition might be more complicated of course.
I thought about adding an artificial energy barrier, but I was wondering if there is a more elegant way. Besides, in the multi-dimensional case I am aiming at, it would be rather cumbersome.
I reproduced the problem in a minimal working example, which I copy below, if it could be of any use.
Thanks a lot, looking forward to any suggestions and hints.
using DifferentialEquations using Plots function kramer_1D(du,u,p,t) du = u du = -(2*u+4*u^3) end function σ_kramer_1D(du,u,p,t) du = 0.03 end u0 = zeros(2,1) tspan = (0.0,30000.0) prob_sde_kramer_1D = SDEProblem(kramer_1D,σ_kramer_1D,u0,tspan) sol = solve(prob_sde_kramer_1D) plot(sol,vars=(1))