| 1 |
This demo illustrates how to: |
| 2 |
|
| 3 |
* Solve a linear partial differential equation with Neumann boundary conditions |
| 4 |
* Use mixed finite element spaces |
| 5 |
|
| 6 |
The solution for :math:`u` in this demo will look as follows: |
| 7 |
|
| 8 |
.. image:: ../neumann-poisson_u.png |
| 9 |
:scale: 75 % |
| 10 |
|
| 11 |
Equation and problem definition: |
| 12 |
-------------------------------------- |
| 13 |
|
| 14 |
|
| 15 |
The Poisson equation is the canonical elliptic partial differential |
| 16 |
equation. For a domain :math:`\Omega \subset \mathbb{R}^n` with |
| 17 |
boundary :math:`\partial \Omega`, the Poisson equation with particular |
| 18 |
boundary conditions reads: |
| 19 |
|
| 20 |
.. math:: |
| 21 |
|
| 22 |
- \nabla^{2} u &= f \quad {\rm in} \ \Omega, \\ |
| 23 |
\nabla u \cdot n &= g \quad {\rm on} \ \partial \Omega. |
| 24 |
|
| 25 |
Here, :math:`f` and :math:`g` are input data and :math:`n` denotes the |
| 26 |
outward directed boundary normal. Since only Neumann conditions are |
| 27 |
applied, :math:`u` is only determined up to a constant :math:`c` by |
| 28 |
the above equations. An additional constraint is thus required, for |
| 29 |
instance: |
| 30 |
|
| 31 |
.. math:: |
| 32 |
|
| 33 |
\int_{\Omega} u \, {\rm d} x = 0. |
| 34 |
|
| 35 |
This can be accomplished by introducing the constant :math:`c` as an |
| 36 |
additional unknown (to be sought in :math:`\mathbb{R}`) and the above |
| 37 |
constraint expressed via a Lagrange multiplier. |
| 38 |
|
| 39 |
We further note that a necessary condition for the existence of a |
| 40 |
solution to the Neumann problem is that the right-hand side :math:`f` |
| 41 |
satisfies |
| 42 |
|
| 43 |
.. math:: |
| 44 |
|
| 45 |
\int_{\Omega} f \, {\rm d} x = - \int_{\partial\Omega} g \, {\rm d} s. |
| 46 |
|
| 47 |
This can be seen by multiplying by :math:`1` and integrating by |
| 48 |
parts: |
| 49 |
|
| 50 |
.. math:: |
| 51 |
|
| 52 |
\int_{\Omega} f \, {\rm d} x = - \int_{\Omega} 1 \cdot \nabla^{2} u \, {\rm d} x |
| 53 |
= - \int_{\partial\Omega} 1 \cdot \partial_n u \, {\rm d} s |
| 54 |
+ \int_{\Omega} \nabla 1 \cdot \nabla u \, {\rm d} x |
| 55 |
= - \int_{\partial\Omega} g \, {\rm d} s. |
| 56 |
|
| 57 |
This condition is not satisfied by the specific right-hand side chosen |
| 58 |
for this test problem, which means that the partial differential |
| 59 |
equation is not well-posed. However, the variational problem expressed |
| 60 |
below is well-posed as the Lagrange multiplier introduced to satisfy |
| 61 |
the condition :math:`\int_{\Omega} u \, {\rm d} x = 0` *effectively |
| 62 |
redefines the right-hand side such that it safisfies the necessary |
| 63 |
condition* :math:`\int_{\Omega} f \, {\rm d} x = - |
| 64 |
\int_{\partial\Omega} g \, {\rm d} s`. |
| 65 |
|
| 66 |
Our variational form reads: Find :math:`(u, c) \in V \times R` such |
| 67 |
that |
| 68 |
|
| 69 |
.. math:: |
| 70 |
|
| 71 |
|
| 72 |
a((u, c), (v, d)) = L((v, d)) \quad \forall \ (v, d) \in V \times R, |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
.. math:: |
| 77 |
|
| 78 |
a((u, c), (v, d)) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x |
| 79 |
+ \int_{\Omega} cv \, {\rm d} x |
| 80 |
+ \int_{\Omega} ud \, {\rm d} x, \\ |
| 81 |
L(v) &= \int_{\Omega} f v \, {\rm d} x |
| 82 |
+ \int_{\partial\Omega} g v \, {\rm d} s. |
| 83 |
|
| 84 |
:math:`V` is a suitable function space containing :math:`u` and |
| 85 |
:math:`v`, and :math:`R` is the space of real numbers. |
| 86 |
|
| 87 |
The expression :math:`a(\cdot, \cdot)` is the bilinear form and |
| 88 |
:math:`L(\cdot)` is the linear form. |
| 89 |
|
| 90 |
Note that the above variational problem may alternatively be expressed |
| 91 |
in terms of the modified (and consistent) right-hand side |
| 92 |
:math:`\tilde{f} = f - c`. |
| 93 |
|
| 94 |
In this demo we shall consider the following definitions of the domain |
| 95 |
and input functions: |
| 96 |
|
| 97 |
* :math:`\Omega = [0, 1] \times [0, 1]` (a unit square) |
| 98 |
* :math:`g = - \sin(5x)` (normal derivative) |
| 99 |
* :math:`f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)` (source term) |