Multiplying complex number to matrix

Dear sir/ma’am
I am not able to multiply the complex number to the matrix as scalar multiplication.

from dolfin import*

import matplotlib.pyplot as plt

mesh = UnitCubeMesh(1, 1, 1)

V=FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 2)

u=TrialFunction(V)
v=TestFunction(V)


mu0 = 3.14159*4*1e-7                   
c0 = 299792458                          
eps0 = 10**7/4/3.14159/c0/c0            
Z0 = mu0*c0   
freq=1e9                           
k_0 = 2*3.1415*freq/c0        
eps_r = 1;
mu_r = 1;
freq = 1e9;
n=FacetNormal(mesh)
m = eps_r*inner(v, u)*dx                # Mass form
s = (1/mu_r)*dot(curl(v), curl(u))*dx   # Stiffness form
s_0 = inner(cross(n, v), cross(n, u))*ds
import numpy as N
M=assemble(m)
S=assemble(s)
S_0=assemble(s_0)
#print("M", M.array(), M.size(0))
#print("S", S.array(), S.size(0))
#print("S_0", S_0.array(), S_0.size(0))
C=M+S+1j*S_0

error is

    C=M+S+1j*S_0
TypeError: unsupported operand type(s) for *: 'complex' and 'dolfin.cpp.la.Matrix'

For complex number support see dolfinx, e.g. the 2D Helmholtz demo.

1 Like