# Solving Non-homogeneous Neumann BVP

**URL:** <https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654>\
**Category:** General Discussion\
**Created:** [April 8, 2022, 1:51pm UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654 "2022-04-08T13:51:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![asif.omi](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@asif.omi](https://community.freefem.org/u/asif.omi)\
**Post date:** [April 8, 2022, 1:51pm UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/1 "2022-04-08T13:51:00Z")

</div>

Dear experts,  
Can you guide me how to implement this in FreeFem++ ?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/180e6ba7a9c653fec1beebdd5adc147e42e11071.png)

Many many thanks in advance.

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [April 8, 2022, 3:55pm UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/2 "2022-04-08T15:55:17Z")

</div>

The compatibility condition is

\int\_\Omega e^{x+y} + \int\_{\partial \Omega} 1/2 e^{x+y} = 0

first find \Omega  
after the it is trivial to solve problem with FreeFM.

---

<div class="post-metadata">

**Author:** ![asif.omi](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@asif.omi](https://community.freefem.org/u/asif.omi)\
**Post date:** [April 9, 2022, 8:50am UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/3 "2022-04-09T08:50:22Z")

</div>

I am proceeding as below:

 ![hw2_code](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/ceeb2b5c19d46196295b23c0fa4083343da93b6d.png)

Am I heading towards the right direction?

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [April 9, 2022, 9:40am UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/4 "2022-04-09T09:40:50Z")

</div>

No the formulation is :

```auto
macro grad(u) [dx(u),dy(u)]//

real cc = 0.1,err,eps = 1e-6 ;
err = int2d(Th)(f) + int1d(Th)(g) ;
cout << " err = " << err << endl; 
asser(err < 1e-8) ; // compatiblity condition 
solve hw2(u,v) = int2d(Th) (grad(u)'*grad(v)+ eps*u*v) 
  - int1d(Th)(g*v) - int2d(Th)(v*f);

```

and here the err = 9.34155 =\> no solution

---

<div class="post-metadata">

**Author:** ![asif.omi](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@asif.omi](https://community.freefem.org/u/asif.omi)\
**Post date:** [April 10, 2022, 12:33pm UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/5 "2022-04-10T12:33:35Z")

</div>

Thank you so much. It totally makes sense now as the compatibility is not holding true. But is there anyway to adjust the boundary conditions so that it will hold true?

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [April 11, 2022, 8:30am UTC](https://community.freefem.org/t/solving-non-homogeneous-neumann-bvp/1654/6 "2022-04-11T08:30:32Z")

</div>

They are 2 ways to solve this compatibility problem multi g buy a other constant cc

```auto
real cc = 1; 
func f = exp(x+y);
func g = cc*exp(x+y);
cc = int2d(Th)(f)/ int1d(Th)(g);

```

Other way is find a domain \Omega such \int\_\Omega (f)/ \int\_{\partial Th}(g)=1
