This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

The assembled matrix is not symmetric

+1 vote

Hi,

I am trying to solve a generalized eigenvalue problem with periodic boundary condition in linear elasticity. However, I noticed that after defining the weak form and assembling the matrices, the left hand side matrix is not symmetric. As the operator is self adjoint, the assembled matrices should be symmetric. For example consider the following simple form (it is just a part of the total weak form):

 k=as_vector([kx,ky,kz])

 def F2(u,w):
     f2=-(inner(mu*grad(u)*k,w))
     return f2

var=F2(uR,wR)*dx 
assemble(var,tensor=A) 
temp=A.array()

if we define the operator L(u)=i*mu*grad(u)*k we have : <w*,L(u)>=<u*,L(w)>*

which means that the assembled matrix A should be symmetric but it is not. Does any body know how should I fix this issue?

my mesh and function spaces are:

mesh = BoxMesh(Point(-a/2, -a/2, -a/2),Point(a/2, a/2, a/2),10,10,10)

V = VectorElement("Lagrange", mesh.ufl_cell(), 1)
W = MixedElement([V, V])
Vcomplex = FunctionSpace(mesh, W, constrained_domain=PeriodicBoundary())

###Variational Problem
uR, uI = TrialFunctions(Vcomplex)
wR, wI = TestFunctions(Vcomplex)
asked Jul 4, 2017 by Ashkan FEniCS Novice (300 points)
edited Jul 6, 2017 by Ashkan

1 Answer

+1 vote

I tried to decode what you want, but I might have missundersood the question.
I assume that $k$ is a constant real vector, $\mu$ a real constant, and $u$ a complex scalar field. Then the operator
$$L(u) = \mu \mathrm{grad}(u)\cdot k$$
satisfies
$$\langle w, L(u) \rangle = \langle w, \mu \mathrm{div}(k u) \rangle = -\langle L(w),u \rangle$$
so is anti-symmetric! Here $\langle \cdot,\cdot\rangle$ denotes the canonical complex inner product.
Remark: a first order operator is expected to be anti-symmetric.

Finally, your variational form don't reflect the operator $L$: the imaginary parts of the complex fields $u$ and $w$ have to appear.

answered Jul 5, 2017 by neliju FEniCS Novice (210 points)

Thanks Neliju. I forgot to write that the mentioned operator is a part of the imaginary part of the total weak form. In other words it is like this: L(u)=i*mu*grad(u)*k
u is a complex vector field. k is a constant real vector (wave vector). mu is a real constant. I should note that in the assembled matrix A, I have none of the following:
aij=aji or aij=-aji

Hi, if you add an $i$ in the definition of your operator, then it is symmetric of course.
However, when you split it into real and imaginary parts, you get
$$L(u_{R},u_{I})=\begin{pmatrix}0 & -\mu k\cdot\mathrm{grad}\
\mu k\cdot\mathrm{grad} & 0
\end{pmatrix}\begin{pmatrix}u_{R}\
u_{I}
\end{pmatrix}$$ so the weak formulation should be something like
$$\mu w_{R}k\cdot\mathrm{grad}(u_{I})+\mu w_{I}k\cdot\mathrm{grad}(u_{R})$$ no? Write everything by splitting the real and imaginary parts and you should get what you want, I think...

...