Changing the default solving loop condition in DifferentialEquations.jl

I think you want to use a ContinuousCallback, the condition function can be something like u[1]-desired_value and your affect should call the terminate! function.

Integrator Interface · DifferentialEquations.jl!

https://diffeq.sciml.ai/stable/features/callback_functions/#ContinuousCallback

1 Like