3

I have a program that simulates the paths of particles using the Differential Equations package of Julia. The simulation allows for particles to hit devices - to prevent the continued simulation of such particles, I use the unstable_check of the solver (specifically of the EulerHeun solver). However, this leads to warnings like the following:

┌ Warning: Instability detected. Aborting
└ @ SciMLBase <path>\.julia\packages\SciMLBase\0s9uL\src\integrator_interface.jl:351

As I simulate thousands of particles, this can be quite annoying (and slow).

Can I suppress this warning? And if not, is there another (better) way to abort the simulation of some particles?

I don't think a code sample makes sense / is necessary here; let me know though if you think otherwise.

MetaColon
  • 2,895
  • 3
  • 16
  • 38

2 Answers2

3

There is Suppressor.jl, although I don't know whether this reduces the overhead you get from the warnings being created, so a DiffEq-specific setting might be the better way to go here (I don't know much about DiffEq though, sorry!)

Here's an example from the readme:

julia> using Suppressor

julia> @suppress begin
           println("This string doesn't get printed!")
           @warn("This warning is ignored.")
       end

for just suppressing warnings you want @suppress_err

Nils Gudat
  • 13,222
  • 3
  • 39
  • 60
3

https://diffeq.sciml.ai/stable/basics/common_solver_opts/#Miscellaneous

verbose: Toggles whether warnings are thrown when the solver exits early. Defaults to true.

Thus to turn off the warnings, you simply do solve(prob,alg;verbose=false).

The simulation allows for particles to hit devices - to prevent the continued simulation of such particles, I use the unstable_check of the solver

Using a DiscreteCallback or ContinuousCallback with affect!(integrator) = terminate!(integrator) is a much better way to do this.

Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81