complex numbers in escript

Asked by Antoine Lefebvre

I am trying to solve the Helmholtz equation for frequency domain acoustics. There is only one variable, the acoustic pressure.
This pressure is a complex quantity and the parameters of the boundary conditions are often complex numbers too.

First question: should I be able to make that work with escript?

As an example, I try to set a complex value to a boundary condition with:
bc = Scalar(0., FunctionOnBoundary(mydomain))
bc.setTaggedValue(1, 1.j*wavenumber)

but it seems the Scalar object does not support the complex data type...

Thanks for your help.

Question information

English Edit question
esys-escript Edit question
No assignee Edit question
Solved by:
Lutz Gross
Last query:
Last reply:
Revision history for this message
Joel Fenwick (j-fenwick1) said :

You are correct, internally escript only supports scalars, vectors, ... over R.
Would it be possible to reform your equation into a system of equations separating real and imaginary parts?

Revision history for this message
Best Lutz Gross (l-gross) said :

As Joel pointed out, escript does not support complex numbers. To solve your problem you need to represent your PDE solution as a vector u with two component where u[0] represents the real and u[1] represents the imaginary part. The Helmholtz equation is then a system of two PDEs of the form

   - u[0]_{,ii} + w_r * u[0] - w_i * u[1] = 0
   - u[1]_{,ii} + w_i * u[0] + w_r * u[1] = 0

In escript this would look like:

myode=LinearPDE(domain, numEquation=2)
for i in range(domain.getDim()):
myode.setValue(A=A, D=D)

Revision history for this message
Antoine Lefebvre (antoine-lefebvre2) said :

Thanks Lutz Gross, that solved my question.

Revision history for this message
Antoine Lefebvre (antoine-lefebvre2) said :

Thanks. It works. I am now working on a a validation test case for Acoustics.

Revision history for this message
Lutz Gross (l-gross) said :

version 5 provides now some support for complex data. This is still is still in beta testing.