# Finite elements/Weak form of Poisson equation
## The Equivalent Variational Problem

So far, we have seen mathematical models in PDE form. That is not the only way of developing a model even though it is commonly used.
Many finite element models are based on an alternative form called the variational problem. The problem is formulated as one where the goal is to minimize a functional.
The variational form and the partial differential equation form are equivalent for the same problem. Each can be derived from the other.
Let us look at a simplified problem - the Poisson equation. Simplify it further by assuming that the temperature is prescribed to be zero on the entire boundary.

### Functional

The first stage is to find a functional that applies to the problem.This is the most difficult part of the process. One way of finding the right functional is to try out a number of different forms and see if they correspond to known differential equations. This process is relatively easy for linear problems but not for nonlinear problems.
Recall that a functional converts a function ($v(\mathbf {x} )$) to a real number.
For the Poisson equation, we can find a functional by thinking in terms of the membrane problem. In that problem, the total potential energy is stored energy of the membrane minus the work done by the force. The functional can be written in the form
    ${\text{(18)}}\qquad I(v)={\frac {1}{2}}\int _{\Omega }|{\boldsymbol {\nabla }}v|^{2}~dV-\int _{\Omega }f~v~dV~.$
where $v\equiv v(\mathbf {x} )$. The functional in equation (18) represents the total potential energy of the membrane. The first term of the functional represents the stored energy and the second term represents the work done by the applied forces. For the membrane the solution is the one that minimizes potential energy.
Since the same functional also works for the heat conduction problem (same PDE), we can minimize the functional to get at the temperature field that we seek.

### Minimization problem

The Poisson equation for the heat conduction problem can then be written as
    ${\text{Find a function}}~T~{\text{such that}}~I(T)\leq I(v)~{\text{for all admissible}}~v.$
What are admissible functions? In brief, these are functions that satisfy the following requirements (in this particular case)
* They are continuously differentiable on ${\bar {\Omega }}$ where ${\bar {\Omega }}:=\Omega \cup \Gamma$.
* They satisfy the boundary condition $v=0$ on $\Gamma _{T}$.
To summarize, the minimization problem is:

### Finding a minimum

Let us take a simple function of one variable, say $h(x)$. See Figure 1(a). If a minimum exists, we can find it by checking where the slope $h^{'}(x)=0$.
A similar idea is used when we try to minimize a functional. See Figure 1(b).
For our problem, we have to find a minimizing function $T(\mathbf {x} )$ from the space of all admissible functions $v(\mathbf {x} )$.
The process of finding this minimizing function has the following steps:
* Assume that a minimizing function exists.
* Let this minimizing function be $T(\mathbf {x} )$.
* Choose an arbitrary function $v(\mathbf {x} )\in {\mathcal {X}}$.
* Form a new function $T(\mathbf {x} )+\epsilon v(\mathbf {x} )$.
* If we consider only the dependence of $\epsilon$, we can treat the functional $I(T+\epsilon v)$ as a function only of $\epsilon$, that is, $I(T+\epsilon v)\equiv F(\epsilon )$.
* Now, the minimum is achieved when $\epsilon =0$. Hence,
    ${\text{(19)}}\qquad \left.{\cfrac {d}{d\epsilon }}F(\epsilon )\right|_{\epsilon =0}=0~~~~\Leftrightarrow ~~~~\left.{\cfrac {d}{d\epsilon }}I(T+\epsilon v)\right|_{\epsilon =0}=0$
* Recall that the functional to be minimized is
    ${\text{(20)}}\qquad I(v)={\frac {1}{2}}\int _{\Omega }|{\boldsymbol {\nabla }}v|^{2}~dV-\int _{\Omega }f~v~dV$
    Plug (20) into (19) and you will get
    ${\text{(21)}}\qquad {\int _{\Omega }{\boldsymbol {\nabla }}T\bullet {\boldsymbol {\nabla }}v~dV=\int _{\Omega }f~v~dV}$
    (Show that this is true.)
* Equation (21) can be solved for $T(\mathbf {x} )$ and is called the variational boundary value problem.
The variational boundary value problem for the Poisson's equation form of the heat equation is
* Figure 1(a). Minimizing a function.
* Figure 1(b). Minimizing a functional.

### Do I NEED to know the functional?

If the PDE form of the BVP is known, then we can derive the variational form directly from the PDE!
This process has the following steps:
* Start with the PDE BVP. Let's look at the Poisson equation for heat conduction as an example. The PDE is
    ${\text{(23)}}\qquad -k\nabla ^{2}T=Q~~{\text{or,}}~~~-\nabla ^{2}T=f$
    where $f:=Q/k$.
* Choose an arbitrary function $v(\mathbf {x} )\in {\mathcal {X}}$.
* Multiply (23) by $v$ and integrate over $\Omega$. We get
    ${\text{(24)}}\qquad -\int _{\Omega }(\nabla ^{2}T)~v~dV=\int _{\Omega }f~v~dV~~~{\text{or,}}~~~-\int _{\Omega }[{\boldsymbol {\nabla }}\bullet ({\boldsymbol {\nabla T}})]~v~dV=\int _{\Omega }f~v~dV~.$
* The left hand side of the equation has second derivatives. We want simplify things so that only first derivatives are involved. To do this, we use the identity
    ${\boldsymbol {\nabla }}\bullet (a\mathbf {b} )=({\boldsymbol {\nabla }}a)\bullet \mathbf {b} +a({\boldsymbol {\nabla }}\bullet b)$
    where $a$ is a scalar valued function ($v$ in our case), and $\mathbf {b}$ is a vector valued function (like ${\boldsymbol {\nabla T}}$). Apply this identity to the first term in equation (24). We get
    $-\int _{\Omega }[{\boldsymbol {\nabla }}\bullet (v{\boldsymbol {\nabla T)}}-({\boldsymbol {\nabla }}v)\bullet ({\boldsymbol {\nabla }}T)]~dV=\int _{\Omega }f~v~dV~.$
    Rearrange to get
    ${\text{(25)}}\qquad -\int _{\Omega }{\boldsymbol {\nabla }}\bullet (v{\boldsymbol {\nabla T)}}~dV+\int _{\Omega }({\boldsymbol {\nabla }}T)\bullet ({\boldsymbol {\nabla }}v)~dV=\int _{\Omega }f~v~dV~.$
* The first term is (25) still has second derivatives. Apply the Gauss divergence theorem
    $\int _{\Omega }{\boldsymbol {\nabla }}\bullet \mathbf {b} ~dV=\int _{\Gamma }\mathbf {n} \bullet \mathbf {b} ~dA$
    where $\mathbf {b}$ is a vector valued function and $\mathbf {n}$ is the normal to the boundary $\Gamma$. The first term of (25) becomes
    $\int _{\Omega }{\boldsymbol {\nabla }}\bullet (v{\boldsymbol {\nabla T)}}~dV=\int _{\Gamma }\mathbf {n} \bullet (v{\boldsymbol {\nabla }}T)~dA=\int _{\Gamma }v({\boldsymbol {\nabla }}T)\bullet \mathbf {n} ~dA=\int _{\Gamma }v{\frac {\partial T}{\partial n}}~dA~.$
* The final form of (25) is called the Weak Form of the PDE and is written as
    ${\text{(26)}}\qquad {-\int _{\Gamma }v{\frac {\partial T}{\partial n}}~dA+\int _{\Omega }({\boldsymbol {\nabla }}T)\bullet ({\boldsymbol {\nabla }}v)~dV=\int _{\Omega }f~v~dV~.}$
At this point, we can break the integral over the boundary into two parts - an integral over $\Gamma _{T}$ and another over $\Gamma _{q}$, that is
    $-\int _{\Gamma }v{\frac {\partial T}{\partial n}}~dA=-\int _{\Gamma _{T}}v{\frac {\partial T}{\partial n}}~dA-\int _{\Gamma _{q}}v{\frac {\partial T}{\partial n}}~dA~.$
Recall that the function $v\in {\mathcal {X}}$ has to meet the requirement that $v=0$ on $\Gamma _{T}$. Therefore,
    $\int _{\Gamma _{T}}v{\frac {\partial T}{\partial n}}~dA=0~.$
We also have the boundary condition that the boundary is insulated ($\partial T/\partial n=0$) on $\Gamma _{q}$. This implies that
    $\int _{\Gamma _{q}}v{\frac {\partial T}{\partial n}}~dA=0~.$
Then, the weak form becomes
    ${\text{(27)}}\qquad {\int _{\Omega }({\boldsymbol {\nabla }}T)\bullet ({\boldsymbol {\nabla }}v)~dV=\int _{\Omega }f~v~dV~.}$
which is the same as the variational boundary value problem (21). We have arrived at the variational BVP without knowing the functional to be minimized!

##### Remarks

* Note that the variational BVP implicitly contains the flux boundary condition and we do not have to apply it separately when solving the BVP. This type of BC is called a natural boundary condition.
* The prescribed boundary condition is not satisfied by the variational BVP and has to be applied explicitly when solving the BVP. This type of BC is called an essential boundary condition.
You will often see the variational BVP (27) written in the form
    ${a(T,v)=\langle f,v\rangle }$
where
    ${\begin{aligned}a(T,v)&=\int _{\Omega }({\boldsymbol {\nabla }}T)\bullet ({\boldsymbol {\nabla }}v)~dV\\\langle f,v\rangle &=\int _{\Omega }f~v~dV~.\end{aligned}}$
Here $\langle f,v\rangle$ is a linear functional $f$ acting on $v$ and $a(.,.)$ is an example of a symmetric bilinear form. A bilinear form is an operator that maps a pair of elements to the real numbers, and which is linear in each of its slots. Let $c_{1}$ and $c_{2}$ be constants, and let $u$, $v$, and $w$ be functions. Then a bilinear form has the properties that
    ${\begin{aligned}a(c_{1}~u+c_{2}~v,w)&=c_{1}~a(u,w)+c_{2}~a(v,w)\\(c_{1}~u+c_{2}~v,w)&=c_{1}~(u,w)+c_{2}~(v,w)\end{aligned}}$
A symmetric bilinear form has the additional property that
    $a(u,v)=a(v,u)~;~~~~(u,v)=(v,u)$
(Show that equation (27) is actually a symmetric bilinear form.)