What is the proper way to handle a discontinuity in Differential Equations?

Hello all,

I have a system of two differential equations that I am able to solve using Rosenbrock23().

I now would like to model this system with one modification, where at time t I manually change the value of one of the differential equation results, causing a discontinuity.

I thought that simply passing t to d_discontinuties would handle this, but I run out of iterations, or the solver produces very unusual results. I currently have it manually set up to solve from 0 to t-1 then from t to f starting with values from t-1, but that does not seem like an elegant solution and I get the following error:

┌ Warning: dt(-1.6e-9) <= dtmin(1.862645149230957e-9) at t=1.059225e7. Aborting. There is either an error in your model specification or the true solution is unstable.

Any tips for the proper way to handle this? My equations are stiff.

See DiscreteCallback example. Event Handling and Callback Functions · DifferentialEquations.jl

Can you share your code? It seems like a very standard PresetTimeCallback use case?