# Inconsistent results when using boundary operator for maxwell's equations

Hello,

The results that I get when using the solver are inconsistent. I have the following two examples. I use the following code for the two examples:

``````import bempp.api
import numpy as np

# example 1: plate with four RWGs / triangles
vertices = np.array([[0, 0.004, 0.004, 0, 0.002],[0, 0, 0.004, 0.004, 0.002],[0,0,0,0,0]],dtype=np.float64)
elements = np.array([[0,1,2,3],[1,2,3,0],[4,4,4,4]],dtype=np.uint32)
grid = bempp.api.Grid(vertices, elements)

# example 2: one RWG / two triangles of the plate of example 1
#vertices = np.array(
#    [[0.0,0.004,0.004,0.002],[0.0,0.0,0.004,0.002],[0.0,0.0,0.0,0.0]],
#    dtype=np.float64)
#elements = np.array(
#    [[0,1],[1,2],[3,3]], dtype=np.uint32)
#grid = bempp.api.Grid(vertices, elements)

grid.plot()

E0 = np.array([0.0, 1.0, 0.0]) # polarization of electric field
kv = np.array([0.0, 0, -314.1593]) # wave vector
k = np.linalg.norm(kv) # wave number

div_space = bempp.api.function_space(grid, "RWG", 0)
curl_space = bempp.api.function_space(grid, "SNC", 0)

def incident_field(x):
return E0*np.exp(1j*np.dot(kv,x))

@bempp.api.complex_callable
def tangential_trace(x, n, domain_index, result):
incident_field = E0*np.exp(1j*np.dot(kv,x))
result[:] = np.cross(incident_field, n)

trace_fun = bempp.api.GridFunction(div_space, fun=tangential_trace, dual_space=curl_space)

from bempp.api.operators.boundary import maxwell
elec = maxwell.electric_field(div_space, div_space, curl_space, k)

print(trace_fun._projections) # values of incident field term
z = elec.weak_form()
print(z._impl) # impedance matrix
``````

Example 1 contains a plate of 4 triangles / RWGs. This gives a 4x4 BEM matrix. Example 2 contains one RWG of the plate of example 1. The diagonal elements of the 4x4 BEM matrix in example 1 have the value:
1.44531462e-07+2.71073075e-06j
The single element BEM matrix in example 2 has the value:
1.60467455e-07+1.40209657e-05j
These values are not the same. I think the values of the diagonal elements of the BEM matrix in example 1 should be the same as the value of the single element of the BEM matrix in example 2.

Best regards,
Christiaan

Hi,

thanks for your message. You may have run into a bug that we recently discovered that appeared when integrating over meshes that consist of so few triangles that not all possible singularity configurations for the integrator occur (usually these are artificial cases).

Can you download the current main branch from Github and try again? The issue is fixed there.

Best wishes

Timo

Hi Timo,

Thank you very much for your quick reply. I am getting consistent results now.

Best regards,
Christiaan

Hi,

It also worked for me now.

Make sure to delete the previous bempp installation in

…/site-packages

and install:

pip install git+https://github.com/bempp/bempp-cl.git --quiet

Also for Google Colab (re-start the session):

!pip install git+https://github.com/bempp/bempp-cl.git --quiet