# Modified Green's function

**URL:** <https://bempp.discourse.group/t/modified-greens-function/140>\
**Category:** Bempp\
**Created:** [10 June 2022 12:13 UTC](https://bempp.discourse.group/t/modified-greens-function/140 "2022-06-10T12:13:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jan](https://bempp.discourse.group/u/jan)\
**Post date:** [10 June 2022 12:13 UTC](https://bempp.discourse.group/t/modified-greens-function/140/1 "2022-06-10T12:13:04Z")

</div>

Hi Matthew and Timo,

there is a new problem for me to solve and so a new question for you 🙂

I would like to consider an integral operator which is not implemented yet, so e.g. something like

(K\phi)(x) = \int\_\varGamma k(x,y)\phi(y) d(y)

with k(x,y)= \sin(|x-y|)/|x-y| or even more complicated

(K\phi)(x)=\int\_\varGamma k(x,y, \phi(y)) d(y)

with k(x,y,\phi)= \sin(|x-y|)/|x-y| ((x-y)\cdot \phi )\phi.  
Do you know a possibility to implement sth like that? For a start the easier version would be ok.  
Probably an efficient way to implement this would be to define my own integral operator, how would that work?  
I already tried sth inefficient like

```auto
phi=bempp.api.GridFunction(rwg_space, fun=phi_fun, dual_space=rwg_space) 
mass = bempp.api.operators.boundary.sparse.identity(rwg_space, rwg_space, rwg_space).weak_form()

@bempp.api.complex_callable
def operator_fun(x, n, domain_index, result):
    
    @bempp.api.complex_callable
    def kernel_fun(xx,n,domain_index,result):
        result[:]= np.array([np.sin(np.abs(x-xx))/np.abs(x-xx),0,0])
    
    kernel=bempp.api.GridFunction(rwg_space, fun=kernel_function, dual_space=rwg_space)
    res=kernel.coefficients.dot(mass*phi.coefficients)
    
    result[:] = np.array([res,0,0])
operator_applied = bempp.api.GridFunction(rwg_space, fun=operator_fun, dual_space=rwg_space) 

```

But it throws the error

```auto
TypingError: Failed in nopython mode pipeline (step: convert make_function into JIT functions)
TypingError: Failed in nopython mode pipeline (step: convert make_function into JIT functions)
Cannot capture the non-constant value associated with variable 'x' in a function that will escape.

File "<ipython-input-67-74e0f7e2f0e4>", line 4:
def operator_fun(x, n, domain_index, result):
    <source elided>
    
    @bempp.api.complex_callable
    ^
 

```

and if I replace xx by x only in line 4

```auto
def kernel_fun(x,n,domain_index,result): 

```

it throws

```auto
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'rwg_space': cannot determine Numba type of <class 'bempp.api.space.space.FunctionSpace'>

```

Am I not allowed to use bempp commands inside a bempp.api.complex\_callable ?

Thank you very much for some hints and help,  
Jan

---

<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:** [4 July 2022 13:40 UTC](https://bempp.discourse.group/t/modified-greens-function/140/2 "2022-07-04T13:40:58Z")

</div>

Hi Jan,

definining operators is very different from the grid function mechanics. Operators are hard coded in Bempp-cl in the sense that we have files with dictionaries of operator identifiers that link to the corresponding function implementations. The only way to change this at the moment is to dive into this and modify the Bempp-cl source code itself.

Best wishes

Timo
