title: Using adaptive step sizes with scipy.integrate.ode
body: <p>The (brief) documentation for <code>scipy.integrate.ode</code> says that two methods (<code>dopri5</code> and <code>dop853</code>) have stepsize control and dense output.  Looking at the examples and the code itself, I can only see a very simple way to get output from an integrator.  Namely, it looks like you just step the integrator forward by some fixed dt, get the function value(s) at that time, and repeat.</p>
  
  <p>My problem has pretty variable timescales, so I'd like to just get the values at whatever time steps it needs to evaluate to achieve the required tolerances.  That is, early on, things are changing slowly, so the output time steps can be big.  But as things get interesting, the output time steps have to be smaller.  I don't actually want dense output at equal intervals, I just want the time steps the adaptive function uses.</p>
  
  <h1>EDIT: Dense output</h1>
  
  <p>A related notion (almost the opposite) is "dense output", whereby the steps taken are as large as the stepper cares to take, but the values of the function are interpolated (usually with accuracy comparable to the accuracy of the stepper) to whatever you want.  The fortran underlying <code>scipy.integrate.ode</code> is apparently capable of this, but <code>ode</code> does not have the interface.  <code>odeint</code>, on the other hand, is based on a different code, and does evidently do dense output.  (You can output every time your right-hand-side is called to see when that happens, and see that it has nothing to do with the output times.)</p>
  
  <p>So I could still take advantage of adaptivity, as long as I could decide on the output time steps I want ahead of time.  Unfortunately, for my favorite system, I don't even know what the approximate timescales are as functions of time, until I run the integration.  So I'll have to combine the idea of taking one integrator step with this notion of dense output.</p>
  
  <h1>EDIT 2: Dense output again</h1>
  
  <p>Apparently, scipy 1.0.0 introduced support for dense output through a new interface.  In particular, they recommend moving away from <code>scipy.integrate.odeint</code> and towards <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html" rel="noreferrer"><code>scipy.integrate.solve_ivp</code></a>, which as a keyword <code>dense_output</code>.  If set to <code>True</code>, the returned object has an attribute <code>sol</code> that you can call with an array of times, which then returns the integrated functions values at those times.  That still doesn't solve the problem for this question, but it is useful in many cases.</p>