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

**URL:** <https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154>\
**Category:** Uncategorized\
**Created:** [15 December 2022 15:12 UTC](https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154 "2022-12-15T15:12:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chris](https://bempp.discourse.group/u/chris)\
**Post date:** [15 December 2022 15:12 UTC](https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154/1 "2022-12-15T15:12:09Z")

</div>

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:

```python
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

---

<div class="post-metadata">

**Author:** ![timo](https://yyz2.discourse-cdn.com/free1/user_avatar/bempp.discourse.group/timo/32/7_2.png) [@timo](https://bempp.discourse.group/u/timo)\
**Post date:** [15 December 2022 16:11 UTC](https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154/2 "2022-12-15T16:11:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chris](https://bempp.discourse.group/u/chris)\
**Post date:** [17 December 2022 13:14 UTC](https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154/3 "2022-12-17T13:14:32Z")

</div>

Hi Timo,

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

Best regards,  
Christiaan

---

<div class="post-metadata">

**Author:** ![marc.jofre](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@marc.jofre](https://bempp.discourse.group/u/marc.jofre)\
**Post date:** [31 December 2022 13:50 UTC](https://bempp.discourse.group/t/inconsistent-results-when-using-boundary-operator-for-maxwells-equations/154/4 "2022-12-31T13:50:14Z")

</div>

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
