Yes this is something that will be very numerically sensitive and using some kind of callback is generally a good idea. The isoutofdomain
solver option and PositiveDomain
callback in the DiffEqCallbacks.jl library were designed for this kind of application. The one that you have there introduces error so I would recommend the two standard approaches over that.
1 Like