I am trying to use solve_ivp()
function to solve for an ODE with state-dependent args. The idea is to update the ODE at each time instants given the current state of the trajectory.
Given the ODE model as the following:
def model(t, y, arg1, arg2):
'''
Some Dynamics model that includes arg1 and arg 2
'''
return dy_dt
The arg1
and arg2
are calculated using some other function:
def gen_args(y):
'''
Calculate arg1 and arg2 based on the state y
'''
return arg1, arg2
Then I want to integrate over the ODE model:
scipy.integrate.solve_ivp(model, t_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, vectorized=False)
What would be a nice way to implement this?
I have checked similar questions like here and here, But all the args are external constants.