Search code examples
pythonscipyintegrator

Does scipy's solve_ivp have a similar method to ode's set_f_params?


For scipy's ode method there exists the set_f_params function to update any args provided: Use solve_ivp with varying parameters. This is something I'm looking for with the solve_ivp method, but have been unable to find reproduce, does anyone know how to do so?

Essentially, I am propagating a state vector y, and I want to calculate a change in additional args I supply to solve_ivp, I then want to basically supply these changed args again to solve_ivp. For anyone interested, it refers to the propagation of two natural satellites and I want to update the gravity field coefficients during the propagation, but I am having quite a hard time doing so.

To be more specific, the exact set of equations I am trying to implement is as follows:

Set of coupled differential equations

I can implement Eq. 5.20, 5.21 and the second equation of 5.22 fine in the state y. I can then call solve_ivp and it will simply return me the solution. What I fail to understand however, is how, based on the resulting $\Delta Z^\nu {l,m}$ for each integration step, I can update $\Delta Z{l,m}$ accordingly using the left equation in 5.22. This new delta $Z_{l,m}$ will be used in the right hand side of equations 5.20 and 5.21, and hence it's important that I do all of this concurrently.

I would appreciate any help


Solution

  • To answer my own question, I went about it the wrong way. The gravity field coefficients should not be updated every integration step. Since it does not explicitly depend on time, the first equation in 5.22 might be of similar magnitude regardless of the step size my variable step size integrator takes, thus producing a result that is not physically accurate.

    As of right now, it seems that overwriting the gravity field coefficients at every integration step with its constant value and this added pertubation does the trick in providing a physically realistic solution. Hence, there is no need for me to figure out how to vary the input args of the solve_ivp function.