 # 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)
# print('z = ', z)

dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C
dz = complex(c, w) * z + complex(a, b) * z * (abs(z)) ** 2 + C

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