I have the following function that I want to implement in scipy.integrate.odeint

def numericSolver(rv_,t,alpha=1.,gamma=1.):
    BVal = B_f(alpha,gamma,t) #this function returns a vector
    BdotVal = Bdot_f(alpha,gamma,t) #this function returns a vector
    matDynamics = np.array([[0.,1.,float(BdotVal[2]),0.,0.,0.],
    derivatives = matDynamics.dot(rv_) 
    return derivatives

In order to implement this function I call odeint as

solution = odeint(numericSolver,IC,t=t,args=(alpha,gamma))

where IC is the initial condition vector, t is the time vector of interest, and alpha and gamma are inputs for numericSolver.

For a more clear explanation, derivatives is the solution, $\dot{\vec{X}}$, to the equation

$ \dot{\vec{X}} = M \vec{X}, $

where $M$ is matDynamics and rv_ is $\vec{X}$.

Is there a way that I can get odeint to return the values of derivatives at each value in t? Or is it best to calculate the derivatives values manually using the values returned in solution?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.