Complex PDE in 3 dimensions

Asked by Martin Springer

Hi!

I try to solve Maxwell's equations in three dimensions. The purpose is to investigate the IP effect and I would therefore like to solve the equations in frequency domain. This results into a set of three complex equations which I can rewrite into a set of 6 equations for real and imaginary part. I then define the Aijkl by

A=Data(value=np.zeros((6,6,6,6)), what=ContinuousFunction(emdomain))

and initialize A according to the equations. The ijkl run from 0-5. Unfortunately the setValue fails, i.e.

empde=LinearPDE(emdomain, numEquations=6)
empde.setValue(A=A)

gives the error message

IllegalCoefficientValue: Illegal shape (6L, 6L, 6L, 6L) of coefficient A

If I skip the imaginary part so that I only have a set of 3 equations the setValue works fine. Does this mean that this problem can not be solved?

Regards
Martin Springer

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Lutz Gross
Solved:
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :
#1

the shape of A should be (6,3,6,3). A convenient way to create a initialized coefficient of right shape and FunctionSpace is to use the createCoefficient() method of LinearPDE. In your case this would look like:

empde=LinearPDE(emdomain, numEquations=6)
empde.createCoefficient("A")
<work on A>
empde.setValue(A=A)

see http://esys.esscc.uq.edu.au/esys13/nightly/epydoc/esys.escript.linearPDEs.LinearProblem-class.html#createCoefficient for details.

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

My comment was in fact a proposed answer. In summary:

use the createCoefficient() method of LinearPDE.

Revision history for this message
Martin Springer (mspringer64) said :
#3

Thanks very much for the tip. This solved the problem. I should have been aware of the dimensions of the A, 6 components but only 3 spacial dimensions.

I have made progress with my python script but I encountered some more problems and questions:

1.) To start with I want to use Dirichlet boundary conditions for all components at the outer boundary of the domain. I thought I can do this using
x=emdomain.getX()
gamma = whereZero(x[0]-sup(x[0])) +whereZero(x[0]-inf(x[0]))\
                 +whereZero(x[1]-sup(x[1])) +whereZero(x[1]-inf(x[1]))\
                 +whereZero(x[2]-sup(x[2])) +whereZero(x[2]-inf(x[2]))
empde.setValue(q=np.ones(6)*gamma, r=np.zeros(6))

But this triggers the message:
AttributeError: 'Data' object has no attribute '__float__'
WARNING: Failure executing file: <C:/Users/marspr/escript/em_script/em_script.py>

2.) It is also not clear to me how I specify different boundary conditions for the different components and regions. In the examples it seems to me that boundary conditions are specified for scalar fields. The problem I want to solve is a electric dipole submersed into the sea. In this case I can apply the boundary condition that Ez is zero at the sea surface. Ex and Ey will have different boundary conditions. How would I specify only the Ez=0 boundary condition at the sea surface (which can be defined by whereZero(x[2]))?

3.) I encountered the problem that it matters in which order the coefficients are initialized in the PDE. For instance in example09a I interchanged the order of initializing the coefficient D and the source term, i.e.

mypde.setValue(y=source[0]*yx*src_dir*stop) #set the source as a function on the boundary
mypde.setValue(D=rho*kmat) #set the general form value D

This triggered an error.
-> 2409 if self.__numSolutions==None: raise UndefinedPDEError,"unidentified number of solutions"

I had the same problem in my script but solved it by initializing in the same order as in example09a.

Regards
Martin Springer

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

1) At some occasions there are problems with the interplay of escript and numpy. In this case it is "q=np.ones(6)*gamma". Try "q=gamma*np.ones(6)". Rule: escript objects come first in binary operations.

2) You need set a in a different way. Eg. to set Ex, Ey, Ez=0 on left/right , front/back, top/bottom faces respectively, you could do

   q = ( whereZero(x[0]-sup(x[0])) +whereZero(x[0]-inf(x[0]) ) * [1,0,0,1,0,0]
                 +whereZero(x[1]-sup(x[1])) +whereZero(x[1]-inf(x[1])) ) * [0,1,0,0,1,0]
                 +whereZero(x[2]-sup(x[2])) +whereZero(x[2]-inf(x[2]))) * [0,0,1,0,0,1]

3) It matters if you don't specify the number of equations and solutions when the pde is created. If unknown the PDE class tray to work this out from the coefficients but this does not always work.

Revision history for this message
Martin Springer (mspringer64) said :
#5

Thank you, this solved the problem.

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

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