I am trying to solve a large system of differential equations using solve_ivp.
from scipy import integrate
sol = integrate.solve_ivp(func_system, (0,100), initial_value_array, t_eval)
The func_system is a system of differential equations, which has to be inferred from a CSV file, a sample of which looks like this:
From,To,Rate
Blood,Other_3,3.0000E+02
Blood,Blood_5,7.0000E+02
Blood_5,Liver_1,4.6200E-01
Blood_5,C-bone-S,8.7780E-02
Blood_5,C-bone-V,4.6200E-03
Blood_5,T-bone-S,1.2474E-01
Blood_5,T-bone-V,1.3860E-02
Blood_5,UB-cont,1.5400E-02
Blood_5,Kidneys_1,7.7000E-03
Blood_5,Kidneys_2,3.8500E-04
Blood_5,RC-cont,1.1550E-02
Blood_5,Testes,2.6950E-04
Blood_5,Ovaries,8.4700E-05
Blood_5,Other_4,1.8511E-02
Blood_5,Other_5,2.3100E-02
Other_3,Blood_5,9.9000E-02
Blood_4,UB-cont,3.5000E+00
Blood_4,Blood_5,6.7550E+01
Blood_4,Other_3,2.8950E+01
Kidneys_1,UB-cont,1.7329E-02
Kidneys_2,Blood_4,1.2660E-04
Other_4,Blood_4,1.3860E-03
Other_5,Blood_4,1.2660E-04
Liver_1,SI-cont,9.2420E-04
Liver_1,Liver_2,4.5286E-02
[...]
The differential equation, for example for compartment Liver_1, would be:
dLiver_1/dt = 0.462*Blood_5 - 0.000924*Liver_1 - 0.045286*Liver_1
which has to be written within func_system as something like
dLiver_1_dt = 0.462*Blood_5 - 0.000924*Liver_1 - 0.045286*Liver_1
where 0.462 is the rate from Blood_5 to Liver_1 and 0.000924 and 0.045286 are the rates away from Liver_1.
Is there a way to create all of these equations (I will have more than 150 altogether) without actually writing them? I can use a matrix approach, but I will also have another system of non-linear differential equations that need to be added.