I have a need to pass internal calculations from a call to odeint. I normally recalculate the values again after I am finished with the integration, but I would prefer to do all of the calculations in the called function for odeint.
My problems are not computationally heavy, so taking a little extra performance hit in doing calculations inside of the ode solver is acceptable.
from scipy.integrate import odeint
import numpy as np
def eom(y, t):
internal_calc = y/(t+1)
xdot = y
return xdot, internal_calc
if __name__ == '__main__':
t = np.linspace(0, 5, 100)
y0 = 1.0 # the initial condition
output, internal_calc = odeint(eom, y0, t)
This code doesn't run, but hopefully shows what I am after. I want to get the 'internal_calc' value out of the eom function for each pass through the integrator.
I've looked around for options, but one of the best python programmers I know told me to write my own integrator so I can do what I want.
Before I did that, I thought I would ask if anyone else has a method for getting values out of the odeint solver.