Diffeqpy complex ODE

I am using diffeqpy package for solving my problem which is a system of complex ODEs.
problem here is that it seems like the function ODEProblem is not working on complex equations and I got the error below:

can anyone help?

def Dz(dz, z, p, t):

  C = np.zeros(8)

  for i in range(n):
    for j in range(n):
      C[i] = C[i] + (1/n) * W[i,j] * z[j]
      # print('C =', C[7])
      # print('z = ', z[7])



  dz[0] = complex(c, w) * z[0] + complex(a, b) * z[0] * (abs(z[0])) ** 2 + C[0]
  dz[1] = complex(c, w) * z[1] + complex(a, b) * z[1] * (abs(z[1])) ** 2 + C[1]
  dz[2] = complex(c, w) * z[2] + complex(a, b) * z[2] * (abs(z[2])) ** 2 + C[2]
  dz[3] = complex(c, w) * z[3] + complex(a, b) * z[3] * (abs(z[3])) ** 2 + C[3]
  dz[4] = complex(c, w) * z[4] + complex(a, b) * z[4] * (abs(z[4])) ** 2 + C[4]
  dz[5] = complex(c, w) * z[5] + complex(a, b) * z[5] * (abs(z[5])) ** 2 + C[5]
  dz[6] = complex(c, w) * z[6] + complex(a, b) * z[6] * (abs(z[6])) ** 2 + C[6]
  dz[7] = complex(c, w) * z[7] + complex(a, b) * z[7] * (abs(z[7])) ** 2 + C[7]

  return dz

z0 = [1, 1, 0, 0, 0, 0, 1, 1]
tspan = (0.0, 100.0)

numba_Dz = numba.jit(Dz)

prob = de.ODEProblem(numba_Dz, z0, tspan)
sol = de.solve(prob)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-30c2b7c6185d> in <module>()
      5 
      6 prob = de.ODEProblem(numba_Dz, z0, tspan)
----> 7 sol = de.solve(prob)

TypeError: can't convert complex to float

I’m not sure whether pyjulia handles this case. This might be a case that’s easier to do directly from Julia for right now.

1 Like