# Finite element method – Poisson equation with pure Neumann boundary conditions

Dear Mathematica User,

I would like to numerically solve a Poisson equation with pure Neumann boundary conditions

$$nabla ^ 2 ( psi) = f$$
$$nabla ( psi) cdot text {n} = g$$

Is it possible?

As an example, I use the demo from the FEniCS project.

$$f = 10 text {Exp} (- ((x – 0.5) ^ 2 + (y – 0.5) ^ 2) / 0.02)$$
$$g = – text {Sin} (5x)$$

in the Mathematica

``````f = 10 * Exp[-(Power[x - 0.5, 2] + Power[y - 0.5, 2]) / 0.02]g = -Sin[5*x];
need["NDSolve`FEM`"]
bmesh = ToBoundaryMesh["Coordinates" -> {{0., 0.}, {1, 0.}, {1, 1}, {0., 1}, {0.5, 0.5}},"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,1}}]}];
mesh = ToElementMesh[bmesh, "MaxCellMeasure" -> 0.001];

m[x_, y_] =
NDSolveValue[{Laplacian[u[x, y], {x, y}]- f ==
Neumann value[g, True]
(*, DirichletCondition[u[x,y]== 0, x == 0.5 && y == 0.5]*)}, u, {x, y} [Element] mesh][x, y]

ddfdx[x_, y_] : = Evaluate[Derivative[1, 0][m][x, y]];
ddfdy[x_, y_] : = Evaluate[Derivative[0, 1][m][x, y]];
show[Contourplot[m[ContourPlot[m[Konturdiagramm[m[ContourPlot[m[x, y], {x, y} [Element] Net, PlotLegends -> Automatic, Contours -> 50], VectorPlot[{Ddfdx[{Ddfdx[{ddfdx[{ddfdx[x, y]ddfdy[x, y]}, {x, y} [Element] mesh,
VectorColorFunction -> Hue, VectorScale -> {Small, 0.6, None}]]
``````

Try to solve this in Mathematica gives a clear and understandable mistake

``````NDSolveValue :: femibcnd: No DirichletCondition or Robin-Type NeumannValue value was specified. The result can be deactivated by a constant value.
``````

The result is not so clear and understandable. The answer you want to get should look something like the following picture I tried equation elimination from this post, d. H

``````DirichletCondition[u[u[u[u[x, y] == 0, x == 0.5 && y == 0.5]
``````

to get the result. Now it looks decent if you are not interested in the sink that appears. Unfortunately, it is important to me, because I am interested in the sink gradient from $$psi$$ such an approach does not lead me anywhere.  So then the question – is it possible to solve the Poisson equation numerically with pure Neumann boundary conditions? Mathematica? Can anyone suggest some steps on how to do that?

Unfortunately, I am not a mathematician, so I lack the ability to implement routine myself. Maybe you can do something with the weak formulation, as in the example, but before I try to implement (would it actually be possible?), I would like to learn if there is another way.

Posted on Categories Articles