title: Solving differential equation for table in python
body: <p>So, I have a list of cells and I need to solve DE for each of them. Problem is, that equations depend on each other, because for diff_u and diff_s functions I need to check 6 neighbours values.</p>
  <pre><code>da_idt = 1/tau_a*(P_a*np.heaviside(a[i] - a_a, 1) - lambda_a*a[i] + G*np.heaviside(h(i,t, array) - h_1, 1)*(1 - np.heaviside(u[i] - u_1, 1)) + S*np.heaviside(s[i] - s_1, 1))*(1 - np.heaviside(u[i] - u_1, 1))
  
  du_idt = 1/tau_u*(P_u*np.heaviside(a[i] - a_u, 1) - lambda_u*u[i] + D_u*diff_u(u, neighbour, i))
  
  ds_idt = 1/tau_s*(P_s*np.heaviside(a[i] - a_a, 1) - lambda_s*s[i] + D_s*diff_s(s, neighbour, i))
  
  def diff_u(u: list, neighbour: list, i: int) -&gt; float:
      return 6/len(neighbour[i])*D_u*sum(u[neigh] - u[i] for neigh in neighbour[i])
  
  </code></pre>
  <p>I have this code in Wolfram Mathematica. There u can simply enter table of equations and give it to NDSolve</p>
  <pre><code>sol=First@NDSolve[eqs~Join~incond/.parval,Flatten@Table[{a[i][t],u[i][t],s[i][t]},{i,Length@cells}],{t,0,300}]
  </code></pre>
  <p>But in odeint or solve_ivp I need to create a function, that gives back [da_idt, du_idt, ds_idt] and if I do that, its solves for each i cell from 0 to 300 seconds and that way neighbours still remain zero values for whole time, before I reach neighbour cell in cycle.</p>
  <p>How can I solve this? If there are more convenient functions than odeint and solve_ivp I'm open to change it.</p>
  <p>Ty in advance</p>