| 1 |
This demo illustrates how to: |
| 2 |
|
| 3 |
* Solve a linear partial differential equation |
| 4 |
* Apply non-zero Neumann boundary conditions |
| 5 |
* Define Expressions |
| 6 |
* Define a FunctionSpace |
| 7 |
* Use the Krylov solver |
| 8 |
* Solve singular problems |
| 9 |
|
| 10 |
The solution for :math:`u` in this demo will look as follows: |
| 11 |
|
| 12 |
.. image:: ../singular_u.png |
| 13 |
:scale: 75 % |
| 14 |
|
| 15 |
Equation and problem definition |
| 16 |
------------------------------- |
| 17 |
|
| 18 |
The Poisson equation is the canonical elliptic partial differential |
| 19 |
equation. For a domain :math:`\Omega \in \mathbb{R}^n` with boundary |
| 20 |
:math:`\Gamma = \partial \Omega`, the Poisson equation with pure |
| 21 |
Neumann boundary conditions reads: |
| 22 |
|
| 23 |
.. math:: |
| 24 |
|
| 25 |
-\nabla^{2} u &= f \quad {\rm in} \ \Omega \\ |
| 26 |
\nabla u \cdot n &= g \quad {\rm on} \ \Gamma \\ |
| 27 |
|
| 28 |
Since only Neumann conditions are applied, :math:`u` is only |
| 29 |
determined up to a constant by the above equations. An addition |
| 30 |
constraint is thus required, for instance |
| 31 |
|
| 32 |
.. math:: |
| 33 |
\int u \, {\rm d} x = 0 |
| 34 |
|
| 35 |
The most standard variational form of the Poisson equation reads: find |
| 36 |
:math:`u \in V` such that |
| 37 |
|
| 38 |
.. math:: |
| 39 |
a(u, v) = L(v) \quad \forall \ v \in V, |
| 40 |
|
| 41 |
where :math:`V` is a suitable function space and |
| 42 |
|
| 43 |
.. math:: |
| 44 |
a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x, \\ |
| 45 |
L(v) &= \int_{\Omega} f v \, {\rm d} x |
| 46 |
+ \int_{\Gamma} g v \, {\rm d} s. |
| 47 |
|
| 48 |
The expression :math:`a(u, v)` is the bilinear form and :math:`L(v)` |
| 49 |
is the linear form. |
| 50 |
|
| 51 |
If we make the Ansatz that :math:`u` can be expressed as a linear |
| 52 |
combination of the basis functions of :math:`V`, and discretize the |
| 53 |
equation, we can write our problem as a linear system: |
| 54 |
|
| 55 |
.. math:: |
| 56 |
AU = b, |
| 57 |
|
| 58 |
where :math:`U` gives the coefficient for the basis functions expressing :math:`u`. |
| 59 |
|
| 60 |
Since we have pure Neumann boundary conditions, the matrix :math:`A` |
| 61 |
is singular. There exists a non-trival vector :math:`e` such that |
| 62 |
|
| 63 |
.. math:: |
| 64 |
Ae=0. |
| 65 |
|
| 66 |
span :math:`\{ e \}` is the null space of A. Consequently, the matrix |
| 67 |
:math:`A` is rank deficient and the right-hand side vector :math:`b` |
| 68 |
may fail to be in the column space of :math:`A`. We therefore need |
| 69 |
to remove the components of :math:`b` that do not lie in the column |
| 70 |
space to make the system solvable. |
| 71 |
|
| 72 |
In this demo, we shall consider the following definitions of the input |
| 73 |
functions, the domain, and the boundaries: |
| 74 |
|
| 75 |
* :math:`\Omega = [0,1] \times [0,1]` (a unit square) |
| 76 |
* :math:`\Gamma = \partial \Omega` (boundary) |
| 77 |
* :math:`g = -\sin(5x)` (normal derivative) |
| 78 |
* :math:`f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)` (source term) |