# Discretizing elliptical PDEs

1. May 11, 2015

### ognik

1. The problem statement, all variables and given/known data
Hi - looking at 'discretizing elliptical PDEs'.
I understand the normal lattice approach, but this approach uses the variational principle. I have a couple of questions please. The text says:
$$\: Given\: E=\int_{0}^{1} \,dx\int_{0}^{1} \,dy\left[\frac{1}{2}\left(\nabla \phi\right)^{2} - S\phi \right]$$
"It is easy to show that E is stationary under all variations $\delta \phi$ that respect the Dirichlet boundary conditions imposed. Indeed the variation is $$\delta E=\int_{0}^{1} \,dx\int_{0}^{1} \,dy\left[\nabla \phi .\nabla \delta \phi - S \delta \phi \right]$$
..which upon integrating the the second derivative by parts becomes...
$$\delta E=\int_{C} \,dl\: \delta \phi \vec{n} . \nabla \phi + \int_{0}^{1} \,dx \: \int_{0}^{1} \,dy\: \delta \phi \: \left[-\nabla^2 \phi - S \right]$$
... where the line integral is over the boundary of the region of interest (C) and n is the unit vector to the boundary."

Sadly, while I recognize all the words and symbols, I cannot follow it at all; I also have no idea where they get the starting equation or what it means. (The sometimes problem with computational physics is that it assumes certain background knowledge). I am hoping someone can expand enough (or provide links) so that I can follow all the above steps in detail?

The second question follows a short bit later in the text, apparently the above 'easily' leads to the following equation:
$$E= \frac{1}{2} \sum_{i=1}^{n}\sum_{j=1}^{n}\left[\left({\phi}_{ij} - {\phi}_{i-1,j}\right)^2 + \left({\phi}_{ij} - {\phi}_{i,j-1}\right)^2 -{h}^{2}\sum_{i=1}^{n}\sum_{j=1}^{n}{S}_{ij}{\phi}_{ij}\right]$$

I probably don't need to understand how they get to the above equation - I'd just prefer to understand as much as I can, so again please help me to follow it.

What I really MUST do is now take a differential of the above w.r.t. $${\phi}_{ij} ,\: IE\: \frac{\partial{E}}{{\partial{\phi}_{ij}}}$$

2. Relevant equations
$$E= \frac{1}{2} \sum_{i=1}^{n}\sum_{j=1}^{n}\left[\left({\phi}_{ij} - {\phi}_{i-1,j}\right)^2 + \left({\phi}_{ij} - {\phi}_{i,j-1}\right)^2 -{h}^{2}\sum_{i=1}^{n}\sum_{j=1}^{n}{S}_{ij}{\phi}_{ij}\right]$$

3. The attempt at a solution
I don't even know where to start in terms of the text above, but I should be able to do the partial derivative of the relevant eqn - with a little help help on the following 2 queries first please:
I think that I can just differentiate inside the summations, is that right?
What do I do with the i-1 and j-1 terms when differentiating w.r.t. ∅ij?
------------------

2. May 12, 2015

### Orodruin

Staff Emeritus
Do you understand the concept of discretisation? Can you briefly describe what you think it means?

3. Jun 2, 2015

### ognik

Sorry Orodruin, for some reason I didn't get a notification that you'd replied. In the meantime I have made progress with the 2nd part on the actual discretisation (using a regular lattice with spacing h to approximate the derivatives, in this case using the 2-point difference formula).

But I am stuck again at a later stage in the book. We are given an energy functional using cylindrical coords:
$$E=\int_{0}^{\infty} r.dr\left[\frac{1}{2}\left(\frac{d{\phi}}{{dr}}\right)^2 - S.\phi\right]$$
First we are asked to discretize using an ri = (i - 1/2)h lattice. I correctly get:
$$E=\frac{1}{2h}\sum_{i=1}^{n}{r}_{i-\frac{1}{2}}\left({\phi}_{i} - {\phi}_{i-1}\right)^2 - h\sum_{i=1}^{n}{r}_{i}{S}_{i}{\phi}_{i}$$
$$Then \: setting\: \frac{\partial{E}}{{\partial{\phi}_{i}}}=0 \:I \: get:$$
$$2{r}_{i}{\phi}_{i} - {r}_{i-\frac{1}{2}}{\phi}_{i-1} - {r}_{i+\frac{1}{2}}{\phi}_{i+1} = {h}^{2}{r}_{i}{S}_{i}$$
Which is all good - just the background for where I get stuck.
-------------
Now I am asked to do the same as above, but for a ri=ih lattice, and I should end with the same equation as the last above, but I don't and can't quite figure out what to do differently. My workings follow, discretising for the ri=ih lattice:
$$E=\frac{1}{2h}\sum_{i=1}^{n}{r}_{i}\left({\phi}_{i} - {\phi}_{i-1}\right)^2 - h\sum_{i=1}^{n}{r}_{i}{S}_{i}{\phi}_{i}$$
$$\frac{\partial E}{\partial{\phi}}=\frac{1}{2h} \frac{\partial }{\partial{\phi}}[\sum_{i=1}^{n}{r}_{i}\left({\phi}_{i} - {\phi}_{i-1}\right)^2 - h\sum_{i=1}^{n}{r}_{i}{S}_{i}{\phi}_{i}] =0$$
$$\therefore \frac{1}{2h} \frac{\partial }{\partial{\phi}}[{r}_{1}\left({\phi}_{1} - {\phi}_{0}\right)^2...+{r}_{i}\left({\phi}_{i} - {\phi}_{i-1}\right)^2 + {r}_{i+1}\left({\phi}_{i+1} - {\phi}_{i}\right)^2 ...+{r}_{n}\left({\phi}_{n} - {\phi}_{n-1}\right)^2] = h {r}_{i}{S}_{i}$$
$$\therefore \frac{1}{2h} [2{r}_{i}\left({\phi}_{i} - {\phi}_{i-1}\right) + 2{r}_{i+1}\left({\phi}_{i+1} - {\phi}_{i}\right)(-1) ] = h {r}_{i}{S}_{i}$$
$$\therefore \left({r}_{i}+{r}_{i+1}\right){\phi}_{i}-{r}_{i}{\phi}_{i-1}-{r}_{i+1}{\phi}_{i+1}={h}^{2}{r}_{i}{S}_{i}$$
$$Now \: \frac{1}{2}\left({r}_{i}+{r}_{i+1}\right)={r}_{i+\frac{1}{2}}$$
$$\therefore 2{r}_{i+\frac{1}{2}}.{\phi}_{i}-{r}_{i}{\phi}_{i-1}-{r}_{i+1}{\phi}_{i+1}={h}^{2}{r}_{i}{S}_{i}$$
As you can see I've ended up shifted half a lattice. I think I haven't understood the difference between the (i - 1/2)h and ih lattices?

4. Jun 18, 2015

### ognik

Final, desperate call - assignment is due tomorrow, so will appreciate anyone who can help me quickly ....I think I have the method right, there is probably just some piece of the puzzle I don't know ....if you need more info. please just ask.