I'm trying to solve complex coupled differential equations as follows.
import numpy as np
from scipy.integrate import complex_ode
def cae(z, A, params):
A1, A2, A3 = A
alpha, gamma, dbeta = params
dA = [
-0.5*alpha*A1 + 1j*gamma*(np.abs(A1)**2 + 2*np.abs(A2)**2 + 2*np.abs(A3)**2)*A1 + 2j*gamma*A2*A3*np.conjugate(A1)*np.exp(1j*dbeta*z),
-0.5*alpha*A2 + 1j*gamma*(2*np.abs(A1)**2 + np.abs(A2)**2 + 2*np.abs(A3)**2)*A2 + 1j*gamma*A1**2*np.conjugate(A3)*np.exp(-1j*dbeta*z),
-0.5*alpha*A3 + 1j*gamma*(2*np.abs(A1)**2 + 2*np.abs(A2)**2 + np.abs(A3)**2)*A3 + 1j*gamma*A1**2*np.conjugate(A2)*np.exp(-1j*dbeta*z),
]
return dA
A0 = [1, 1e-3, 0])
z0 = 0
params = [0, 2, 0]
L = 2.5
dz = 0.01
sol = complex_ode(cae).set_integrator("dopri5")
sol.set_initial_value(A0, z0).set_f_params(params)
while sol.successful() and sol.t < L:
sol.integrate(sol.t+dz)
But, this code gives the following error.
File "C:\Python27\lib\site-packages\scipy\integrate\_ode.py", line 472, in _wrap
f = self.cf(*((t, y[::2] + 1j * y[1::2]) + f_args))
TypeError: can't multiply sequence by non-int of type 'complex'
Can anyone explain why this is happening and how to fix it?