I'm working on a system of differential equation that I solve with scipy.integrate.solve_ivp. For each variation term of this system I combine different intermediate variables. I'm looking for a way to store those intermediate variables and not only the resulting variables.
I've thinking to use a list or some other kind of iterable to store the intermediate values directly in the func passed to solve_ivp but it doesn't seem to be the best approach and doesn't allow me to use the interpolants, when using a dense_output. I could also recompute those intermediate variables by using the results of solve_ivp, but as the computation are somehow complicated it should be way easier to store directly the values and only compute them only once.
My func function looks like that :
def dY(t, Y):
C1, C2 = Y
dC1 = A(C1, C2) + B(C1, C2)
dC2 = C(C1, C2) + B(C1, C2)
return [dC1, dC2]
I would like to store the values of A, B, C and D at each step, as are the values of C1 and C2 (for those to whom it speaks, it's a chemical engineering problem and A, B, C and D are different sink and source terms)
Thanks for any helps !