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

Complex inner product

0 votes

Dear folks!

In a complex problem, the inner product becomes something along the line of
$$ \left\langle u, v \right\rangle = \int\limits_\Omega u \cdot v^* \, dx, $$
right?

If I express this in terms of the real and imaginary parts of u and v $u_r, u_i, ...$, I end up with this:
$$ \left\langle u_r+j u_i, \; v_r + j v_i \right\rangle = \int\limits_\Omega u_r \cdot v_r\, dx + \int\limits_\Omega u_i \cdot v_i \, dx + j \int\limits_\Omega u_i v_r - u_r v_i \, dx. $$
where $j = \sqrt{-1}$.

Now, I'm trying to keep my UFL forms readible, so I defined a function

def dot_c(u_r, u_i, v_r, v_i):
r_r = dot( u_r, v_r ) + dot( u_i, v_i )
r_i = dot( u_i, v_r ) - dot( u_r, v_i )
return ???

How do I return the result? I need to make sure the imaginary part is associated with the function spaces that represent imaginary parts...
return r_r + r_i

or rather
return as_vector( [r_r, r_i] )

or rather something completely different?
asked Jan 28, 2016 by cweickhmann FEniCS Novice (550 points)

1 Answer

+1 vote

Use return r_r + r_i. The components already have function spaces associated with the.

Native support for complex numbers in FEniCS is on the roadmap.

answered Feb 23, 2016 by Garth N. Wells FEniCS Expert (35,930 points)

Thanks, I started to suspect that ;-)

...