HEAD | PREVIOUS |

Partial Differential Equations

$\nabla =(\frac{\partial}{\partial x},\frac{\partial}{\partial y},\frac{\partial}{\partial z}),$ | $(4.1)$ |

Figure 4.1: The elementary volume of fluid crossing a surface element
$\mathit{dA}$ in time element $\mathit{dt}$ is $\mathit{dt}\mathit{v}.\hat{\mathit{n}}\mathit{dA}=\mathit{dt}\mathit{v}.\mathit{dA}$. So the mass per unit time is $\mathit{\rho}\mathit{v}.\mathit{dA}$.

Mass conservation is then described by
considering some control volume $V$ whose surface is $\partial V$. For
any such volume, the rate of increase of the total amount of substance
within the volume must be equal to the total source density within the
volume plus the amount flowing in across its surface:
$\frac{\partial}{\partial t}{\int}_{V}\mathit{\rho}{d}^{3}x={\int}_{V}S{d}^{3}x-{\int}_{\partial V}\mathit{\rho}\mathit{v}.\mathit{dA}.$ | $(4.2)$ |

${\int}_{V}\nabla .\mathit{u}\mathrm{\hspace{0.5em}\hspace{0.5em}}{d}^{3}x={\int}_{\partial V}\mathit{u}.\mathit{dA},$ | $(4.3)$ |

${\int}_{V}(\frac{\partial \mathit{\rho}}{\partial t}+\nabla .(\mathit{\rho}\mathit{v})-S){d}^{3}x=0.$ | $(4.4)$ |

$\frac{\partial \mathit{\rho}}{\partial t}+\nabla .(\mathit{\rho}\mathit{v})-S=0.$ | $(4.5)$ |

$\nabla .(\mathit{\rho}\mathit{v})=\mathit{v}.\nabla \mathit{\rho}+\mathit{\rho}\nabla .\mathit{v}={v}_{x}\frac{\partial \mathit{\rho}}{\partial x}+{v}_{y}\frac{\partial \mathit{\rho}}{\partial y}+{v}_{z}\frac{\partial \mathit{\rho}}{\partial z}+G(\mathit{x})\mathit{\rho}=S,$ | $(4.6)$ |

Figure 4.3: The advection equation with prescribed velocity $\mathit{v}$
amounts to integration along the streamlines. Conditions
("initial" conditions) can be applied along the solution region
boundaries A and B, but not then along C and D.

From the point of view of solving for $\mathit{\rho}$ as a function of space,
this is a linear first-order partial differential equation in three
dimensions, with variable (i.e. non-uniform) coefficients ${v}_{x}$,
${v}_{y}$, ${v}_{z}$, and $G$. It is $\mathit{\rho}\mathit{v}=-D\nabla \mathit{\rho},$ | $(4.7)$ |

$\frac{\partial \mathit{\rho}}{\partial t}-\nabla .(D\nabla \mathit{\rho})-S=0.$ | $(4.8)$ |

$\frac{{\partial}^{2}\mathit{\psi}}{\partial {t}^{2}}={c}_{s}^{2}\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}},$ | $(4.9)$ |

$\begin{array}{cccc}\multicolumn{1}{c}{}& \hfill & \nabla .\mathit{E}={\mathit{\rho}}_{q}/{\mathit{\epsilon}}_{0}\hfill & \hfill \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}(4.10)\\ \multicolumn{1}{c}{}& \hfill & \nabla \times \mathit{E}=-\frac{\partial \mathit{B}}{\partial t}\hfill \\ \multicolumn{1}{c}{}& \hfill & \nabla .\mathit{B}=0\hfill \\ \multicolumn{1}{c}{}& \hfill & \nabla \times \mathit{B}={\mathit{\mu}}_{0}\mathit{j}+{\mathit{\mu}}_{0}{\mathit{\epsilon}}_{0}\frac{\partial \mathit{E}}{\partial t}\hfill \end{array}$ |

where ${\mathit{\epsilon}}_{0}=8.85\times {10}^{-12}$ F/m is the permittivity of free space, ${\mathit{\mu}}_{0}=4\mathit{\pi}\times {10}^{-7}$ H/m is the permeability of free space. These fundamental constants satisfy ${\mathit{\mu}}_{0}{\mathit{\epsilon}}_{0}=1/{c}^{2}$, where $c$ is the speed of light. These are a system of partial differential equations. There appear to be eight in all because the curl equations are vector equations (three equations in one) and the divergence equations are single equations. However, there's some built-in redundancy in the equations that reduces there effective number to six (equal to the number of dependent variables in the components of the electric and magnetic fields). Only rarely does one solve the full set of equations numerically. More usually one is interested in simplified special cases. For example, if time dependence can be ignored, then $\nabla \times \mathit{E}=0$, which is a sufficient condition to allow the electric field to be expressed as the gradient of a scalar potential $\mathit{E}=-\nabla \mathit{\phi}$. In that case, the potential satisfies

$-\nabla .\mathit{E}=-\nabla .(-\nabla \mathit{\phi})={\nabla}^{2}\mathit{\phi}=\frac{{\partial}^{2}\mathit{\phi}}{\partial {x}^{2}}+\frac{{\partial}^{2}\mathit{\phi}}{\partial {y}^{2}}+\frac{{\partial}^{2}\mathit{\phi}}{\partial {z}^{2}}=-{\mathit{\rho}}_{q}/{\mathit{\epsilon}}_{0},$ | $(4.11)$ |

$\sum _{i,j}{c}_{\mathit{ij}}\frac{\partial}{\partial {x}_{i}}\frac{\partial}{\partial {x}_{j}}\mathit{\psi}+\sum _{i}{c}_{i}\frac{\partial}{\partial {x}_{i}}\mathit{\psi}+c\mathit{\psi}=\mathit{const}.$ | $(4.12)$ |

$A\frac{{\partial}^{2}}{\partial {x}^{2}}\mathit{\psi}+2B\frac{{\partial}^{2}}{\partial x\partial y}\mathit{\psi}+C\frac{{\partial}^{2}}{\partial {y}^{2}}\mathit{\psi}=0.$ | $(4.13)$ |

$\sum _{i,j}{c}_{\mathit{ij}}{x}_{i}{x}_{j}+\sum _{i}{c}_{i}{x}_{i}=\mathit{const}.$ | $(4.14)$ |

${\mathit{Ax}}^{2}+2B\mathit{xy}+{\mathit{Cy}}^{2}=\mathit{const}.$ | $(4.15)$ |

**Hyperbolic**- if ${B}^{2}-\mathit{AC}>0$; for example $B=0$, $C=-A$, ${x}^{2}-{y}^{2}=\mathit{const}.$
**Parabolic**- if ${B}^{2}-\mathit{AC}=0$; for example $B=C=0$, ${x}^{2}-y=\mathit{const}.$
**Elliptic**- if ${B}^{2}-\mathit{AC}<0$; for example $B=0$, $C=A$, ${x}^{2}+{y}^{2}=\mathit{const}.$

Figure 4.4: An elliptic equation, such as Laplace's equation has
boundary conditions applied round an entire closed surface. In
this case, the potential is prescribed everywhere on the square
domain boundary, and contours of potential are plotted.

Alternatively, are the conditions applied on the boundary of a closed
domain (as illustrated in Fig. 4.4)? If so (elliptic
equations) then the solution everywhere depends upon all the boundary
information, it is called a $\mathit{\psi}=\sum _{i,j}{a}_{\mathit{ij}}\mathrm{sin}(\mathit{\pi}ix/{L}_{x})\mathrm{sin}(\mathit{\pi}jy/{L}_{y}),$ | $(4.16)$ |

Figure 4.6: A region of an unstructured mesh. Such meshes are
designed to give greater resolution in areas of more rapid
variation, often close to boundaries of complicated or subtle
shapes. This example uses a triangular mesh but other choices are
possible.

We'll stick to structured meshes here.
Just as in one dimension we use a representation
${\frac{d\mathit{\psi}}{\mathit{dx}}|}_{n+1/2}=\frac{{\mathit{\psi}}_{n+1}-{\mathit{\psi}}_{n}}{{x}_{n+1}-{x}_{n}},$ | $(4.17)$ |

${\frac{\partial \mathit{\psi}}{\partial x}|}_{n+1/2,m}=\frac{{\mathit{\psi}}_{n+1,m}-{\mathit{\psi}}_{n,m}}{{x}_{n+1}-{x}_{n}},\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}}{\frac{\partial \mathit{\psi}}{\partial y}|}_{n,m+1/2}=\frac{{\mathit{\psi}}_{n,m+1}-{\mathit{\psi}}_{n,m}}{{y}_{m+1}-{y}_{m}},$ | $(4.18)$ |

$\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}|}_{n,m}=\frac{({\frac{\partial \mathit{\psi}}{\partial x}|}_{n+1/2,m}-{\frac{\partial \mathit{\psi}}{\partial x}|}_{n-1/2,m})}{{x}_{n+1/2}-{x}_{n-1/2}$ | $(4.19)$ |

$\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}|}_{n,m}=\frac{({\frac{\partial \mathit{\psi}}{\partial y}|}_{n,m+1/2}-{\frac{\partial \mathit{\psi}}{\partial y}|}_{n,m-1/2})}{{y}_{m+1/2}-{y}_{m-1/2}$ | $(4.20)$ |

${\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}|}_{n,m}+{\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}|}_{n,m}=\sum _{i=\mathit{adjacent}}{a}_{i}({\mathit{\psi}}_{i}-{\mathit{\psi}}_{n,m})={\mathit{\rho}}_{n,m},$ | $(4.21)$ |

$\begin{array}{c}\multicolumn{1}{c}{\frac{1}{\mathit{\Delta}{x}^{2}}({\mathit{\psi}}_{n+1,m}+{\mathit{\psi}}_{n-1,m})+\frac{1}{\mathit{\Delta}{y}^{2}}({\mathit{\psi}}_{n,m+1}+{\mathit{\psi}}_{n,m-1})-(\frac{2}{\mathit{\Delta}{x}^{2}}+\frac{2}{\mathit{\Delta}{y}^{2}}){\mathit{\psi}}_{n,m}}\\ \multicolumn{1}{c}{={\mathit{\rho}}_{n,m}.}& \hfill \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}(4.22)\end{array}$ |

This form naturally generalizes immediately to higher dimensions. It has a standard structure represented by eq. (4.21), namely that the second order differential operator is represented by the sum over all the adjacent nodes of coefficients times the adjacent values, minus the sum of all the coefficients times the central value. This sum is called a "stencil", representing the differential. The sum of all its coefficients (including the coefficient of the central value) is zero, because if $\mathit{\psi}$ is uniform, ${\nabla}^{2}\mathit{\psi}$ is zero. Written out geometrically for two dimensions the coefficients form a cross pattern which for the uniform-mesh Laplacian is:

$\begin{array}{cccc}\hfill m+1\hfill & \hfill .\hfill & \hfill 1/\mathit{\Delta}{y}^{2}\hfill & \hfill .\hfill \\ \hfill m\hfill & \hfill 1/\mathit{\Delta}{x}^{2}\hfill & \hfill -(2/\mathit{\Delta}{x}^{2}+2/\mathit{\Delta}{y}^{2})\hfill & \hfill 1/\mathit{\Delta}{x}^{2}\hfill \\ \hfill m-1\hfill & \hfill .\hfill & \hfill 1/\mathit{\Delta}{y}^{2}\hfill & \hfill .\hfill \\ \hfill \hfill & \hfill n-1\hfill & \hfill n\hfill & \hfill n+1\hfill \end{array}$ | $(4.23)$ |

${\nabla}^{2}\mathit{\psi}\equiv \frac{1}{r}\frac{\partial}{\partial r}\left(r\frac{\partial \mathit{\psi}}{\partial r}\right)+\frac{1}{{r}^{2}}\frac{{\partial}^{2}\mathit{\psi}}{\partial {\mathit{\theta}}^{2}}=-{k}^{2}\mathit{\psi}.$ | $(4.24)$ |

The quadratic form in $x$ and $y$ arising from the coefficients for the derivatives with respect to $r$ and $\mathit{\theta}$ is

${x}^{2}+\frac{1}{{r}^{2}}{y}^{2}+\frac{1}{r}x=\mathit{const}.$ | $(4.25)$ |

${\frac{\partial \mathit{\psi}}{\partial r}|}_{n+1/2,m}=\frac{{\mathit{\psi}}_{n+1,m}-{\mathit{\psi}}_{n,m}}{{r}_{n+1}-{r}_{n}},\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}}{\frac{\partial \mathit{\psi}}{r\partial \mathit{\theta}}|}_{n,m+1/2}=\frac{{\mathit{\psi}}_{n,m+1}-{\mathit{\psi}}_{n,m}}{{r}_{n}({\mathit{\theta}}_{m+1}-{\mathit{\theta}}_{m})}.$ | $(4.26)$ |

$\begin{array}{ccc}\multicolumn{1}{c}{\frac{1}{r}\frac{\partial}{\partial r}}& {\left(r\frac{\partial \mathit{\psi}}{\partial r}\right)}_{n,m}\hfill & =\frac{1}{{r}_{n}}({r}_{n+1/2}\frac{{\mathit{\psi}}_{n+1,m}-{\mathit{\psi}}_{n,m}}{{r}_{n+1}-{r}_{n}}-{r}_{n-1/2}\frac{{\mathit{\psi}}_{n,m}-{\mathit{\psi}}_{n-1,m}}{{r}_{n}-{r}_{n-1}})\frac{1}{{r}_{n+1/2}-{r}_{n-1/2}}\hfill \\ \multicolumn{1}{c}{}& =\hfill & [(1+\frac{1}{2n})({\mathit{\psi}}_{n+1,m}-{\mathit{\psi}}_{n,m})-(1-\frac{1}{2n})({\mathit{\psi}}_{n,m}-{\mathit{\psi}}_{n-1,m})]\frac{1}{\mathit{\Delta}{r}^{2}}\hfill \\ \multicolumn{1}{c}{}& =\hfill & [(1+\frac{1}{2n}){\mathit{\psi}}_{n+1,m}-2{\mathit{\psi}}_{n,m}+(1-\frac{1}{2n}){\mathit{\psi}}_{n-1,m}]\frac{1}{\mathit{\Delta}{r}^{2}}.\hfill & \hfill \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}(4.27)\end{array}$ |

and

$\begin{array}{ccc}\multicolumn{1}{c}{{\frac{1}{{r}^{2}}\frac{{\partial}^{2}\mathit{\psi}}{\partial {\mathit{\theta}}^{2}}|}_{n,m}}& =\hfill & \frac{1}{{r}_{n}^{2}}(\frac{{\mathit{\psi}}_{n,m+1}-{\mathit{\psi}}_{n,m}}{{\mathit{\theta}}_{m+1}-{\mathit{\theta}}_{m}}-\frac{{\mathit{\psi}}_{n,m}-{\mathit{\psi}}_{n,m-1}}{{\mathit{\theta}}_{m}-{\mathit{\theta}}_{m-1}})\frac{1}{{\mathit{\theta}}_{m+1/2}-{\mathit{\theta}}_{m-1/2}}\hfill \\ \multicolumn{1}{c}{}& =\hfill & ({\mathit{\psi}}_{n,m+1}-2{\mathit{\psi}}_{n,m}+{\mathit{\psi}}_{n,m-1})\frac{1}{{r}_{n}^{2}\mathit{\Delta}{\mathit{\theta}}^{2}}.\hfill & \hfill \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}(4.28)\end{array}$ |

Then we see that the required stencil for the differential operator is

$\begin{array}{cccc}\hfill m+1\hfill & \hfill .\hfill & \hfill 1/({r}_{n}\mathit{\Delta}\mathit{\theta}{)}^{2}\hfill & \hfill .\hfill \\ \hfill m\hfill & \hfill (1-\frac{1}{2n})/\mathit{\Delta}{r}^{2}\hfill & \hfill -2[1/\mathit{\Delta}{r}^{2}+1/({r}_{n}\mathit{\Delta}\mathit{\theta}{)}^{2}]\hfill & \hfill (1+\frac{1}{2n})/\mathit{\Delta}{r}^{2}\hfill \\ \hfill m-1\hfill & \hfill .\hfill & \hfill 1/({r}_{n}\mathit{\Delta}\mathit{\theta}{)}^{2}\hfill & \hfill .\hfill \\ \hfill \hfill & \hfill n-1\hfill & \hfill n\hfill & \hfill n+1\hfill \end{array}.$ | $(4.29)$ |

1. Determine whether the following partial differential equations, in which $p$ and $q$ are arbitrary real constants, are elliptic, parabolic, or hyperbolic. (a) ${p}^{2}\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}+{q}^{2}\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}=0$ (b) ${p}^{2}\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}-{q}^{2}\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}=\mathit{\psi}$ (c) $\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}+4\frac{{\partial}^{2}\mathit{\psi}}{\partial x\partial y}+\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}=0$ (d) $\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}+2\frac{{\partial}^{2}\mathit{\psi}}{\partial x\partial y}+\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}=0$ (e) $\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}+p\frac{\partial \mathit{\psi}}{\partial y}=\mathit{\psi}$ (f) $\frac{{\partial}^{2}\mathit{\psi}}{\partial {x}^{2}}+\frac{{\partial}^{2}\mathit{\psi}}{\partial {y}^{2}}+\frac{{\partial}^{2}\mathit{\psi}}{\partial {z}^{2}}=0$ (g) $p\frac{\partial \mathit{\psi}}{\partial x}+\mathit{qy}\frac{\partial \mathit{\psi}}{\partial y}=1$

2. Write a computer code function${}^{26}$ to evaluate the difference stencil in two dimensions for the anisotropic partial differential operator, $L=\frac{{\partial}^{2}}{\partial {x}^{2}}+2\frac{{\partial}^{2}}{\partial {y}^{2}}$. The code function is to operate on a quantity $f(x,y)={f}_{\mathit{ij}}$, represented as a matrix of the values at discrete points on a structured, equally-spaced, 2-D mesh with ${N}_{x}$ and ${N}_{y}$ nodes in the $x$ and $y$ directions, spanning the intervals $0\le x\le {L}_{x}$, $0\le y\le {L}_{y}$. The function should accept parameters ${N}_{x},{N}_{y},{L}_{x},{L}_{y},i,j,f$ and return the corresponding finite-difference expression for ${g}_{\mathit{ij}}=Lf$ at mesh point $i,j$. Write also a test program to construct $f(x,y)=({x}^{2}+{y}^{2}/2)$ on the mesh nodes, giving ${f}_{\mathit{ij}}$, and call your stencil function, with $f$ and the corresponding ${N}_{x},{N}_{y},{L}_{x},{L}_{y}$ as arguments, to evaluate ${g}_{\mathit{ij}}$ and print it. Submit the following as your solution:

- Your code in a computer format that is capable of being executed, citing the language it is written in.
- A brief answer to the following. Will your function work at the boundaries, $x=0,{L}_{x}$, or $y=0,{L}_{y}$? If not, what is needed to make it work there?
- The values of ${g}_{\mathit{ij}}$ for four different nodes corresponding to two different interior $i$ and two different interior $j$, when ${N}_{x}={N}_{y}=10$, ${L}_{x}={L}_{y}=10$.
- Brief answer to: Are there inefficiencies in using a code like this to evaluate $Lf$ everywhere on the mesh? If so, how might those inefficiencies be avoided?

HEAD | NEXT |