title: SciPy ODE solver has problems with discrete events
body: <p>I am using the <a href="https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.integrate.ode.html" rel="nofollow noreferrer">SciPy ODE Integrator Class</a> in order to solve an ordinary differential equation system. The complete program is supposed to simulate a mechanical system and visualize it with a 3D-Animation. This works fine as long as I really just want to solve a normal differential equation. However, some of the system state variables of the mechanical system are limited in their value range. These variables are not allowed to shoot over/go below a certain limit. <br>
  My current approach to keep x_n &lt; limit_{x_n}  is to detect it and return dx_n/dt = 0. The solver doesn't seem to like it. Minimal code of the problem:</p>
  
  <pre><code>solver = scipy.integrate.ode(rhs)
  solver.set_initial_value(...) #not important
  solver.set_integrator("vode", method="adams", rtol=1e-6, atol=1e-9)
  ...
  while(True):
      state = solver.integrate(solver.t + timeStep)
      visualizeModel(state)
      ...
  
  def rhs(t, x):
      x1, x2, x3 = x
      dx1dt = x1_dot(x1, x2, x3)
      dx2dt = x2_dot(x1, x2, x3)
      dx3dt = x3_dot(x1, x2, x3)
      if numpy.abs(x1) &gt; my_limit:
          dx1dt = 0 #the solver seems to absolutely hate this line
      return [dx1dt, dx2dt, dx3dt]
  </code></pre>
  
  <p>```</p>
  
  <p>How can I prevent the solver from stalling at this point? How can I implement a limited value range for variables of the differential equation?</p>