# Heat diffusion

- toc:false
- branch: master
- badges: true
- comments: false
- categories: [mathematics, numerical recipes]
- hide: true

-----
Questions:
- How can I describe heat diffusion using a PDE?
- What is the Laplacian operator?
- What are boundary conditions?

Objectives:


-----

### Partial differential equations have multiple inputs

In the previous section of the course we studied <bold>ordinary differential equations</bold>. ODEs have a single input (also known as dependent variable) - for example, time. 

Partial differential equations (PDEs) have multiple inputs (dependent variables). For example, think about a sheet of metal that has been heated unevenly across the surface. Over time, heat will diffuse through the 2-dimensional sheet. The temperature depends on both time *and* position - there are two inputs.

> Youtube: https://www.youtube.com/watch?v=twBcpxrWm5E

Because PDEs have multiple inputs they are generally much more difficult to solve analytically than ODEs. However, there are a range of numerical methods that can be used to find approximate solutions.

### PDEs have application across a wide variety of topics

The same type of PDE often appears in different contexts. For example, the <bold>diffusion equation</bold> takes the form:

\begin{equation}
\nabla^2T = \alpha \frac{\partial T}{\partial t}
\end{equation}

When used to describe heat diffusion, this PDE is known as the heat equation. This same PDE however can be used to model other seemingly unrelated processes such as brownian motion, or used in financial modelling via the Black-Sholes equation. 

Another type of PDE is known as <bold>Poisson's equation</bold>:

\begin{equation}
\nabla^2\phi = f(x,y,z)
\end{equation}

Poisson's equation can be used to describe electrostatic forces, where $\phi$ is the electric potential. It can also be applied to mechanics (where $\phi$ is the gravitational potential) or thermodynamics (where $\phi$ is the temperature). When $f(x,y,z)=0$ this equation is known as <bold>Laplace's equation</bold>. 

The third common type of PDE is the <bold>wave equation</bold>:

\begin{equation}
\nabla^2r = \alpha \frac{\partial^2 r}{\partial t^2}
\end{equation}

This describes mechanical processes such as the vibration of a string or the motion of a pendulum. It can also be used in electrodynamics to describe the exchange of energy between the electric and magnetic fields. 

In this course we will focus on only the heat equation, but many of the topics we will discuss - such as boundary conditions, and finite difference methods - can be transferred to PDEs more generally. 

### The Laplacian operator corresponds to an average rate of change

*But what is the operator $\nabla^2$?*. This is the <bold>Laplacian operator</bold>. When applied to $\phi$ and written in full for a three dimensional cartesian coordinate system with dependent variables $x$, $y$ and $z$ it takes the following form:

\begin{equation}
\nabla^2\phi = \frac{\partial^2\phi}{\partial x^2} + \frac{\partial^2\phi}{\partial y^2} + \frac{\partial^2\phi}{\partial z^2}.
\end{equation}

We can think of the laplacian as encoding an average rate of change. To better develop an intuition for how the laplacian can be interpreted physically, we need to understand two related operators - div and curl. We will not explore these operators further in this lesson, but a related video is below:

> Youtube: https://youtu.be/EW08rD-GFh0

### PDEs can have boundary values and initial values
In the previous section of the course we learnt that ODEs have either initial values or boundary values.

PDEs can also be separated in a similar manner. <bold>Boundary value problems</bold> describe the behaviour of a variable in a space and we are given some constraints on the variable around the boundary of that space. For example, consider a box with one wall at voltage $V$ and all others at voltage zero.



The sprecification that one wall is at voltage $V$ and all others are at voltage zero are the boundary conditions. We could then calculate the electrostatic potential $\phi$ at all points within the box using Poisson's equation:

\begin{equation}
\nabla^2\phi = 0
\end{equation}

<bold>Initial value problems</bold> are where the field - or other variable of interest - is varying in both space and time. We now require boundary conditions *and* initial values. For example, consider heat diffusion in a box. Here we could specify that there is no heat flow in or out of the box - this is the boundary condition. 



We could also specify that at time $t=0$ the centre of the box is at temperature $T_1$, whilst surrounding areas are at temperature  $T_1$. This is the initial condition. It differs from a boundary condition in that we are told what the temperature is at the start of our time grid (at $t=0$) but not at the end of our time grid (when the simulation finishes).



---

Keypoints:

- Partial differential equations have multiple inputs
- 

---

Do [the quick-test](https://nu-cem.github.io/CompPhys/2021/08/02/Heat-Diffusion-Qs.html).

Back to [Modelling with Partial Differential Equations](https://nu-cem.github.io/CompPhys/2021/08/02/PDEs.html).

---


```python

```

fccc80053536cb66b897cf629d0871e4061afe81
ipynb
Jupyter Notebook
_notebooks/2021-08-02-Heat-Diffusion.ipynb
charlo66609/CompPhys
a28ad04f44e314adf238d4ea9dc8d73af4bce2ce
CC-BY-4.0
_notebooks/2021-08-02-Heat-Diffusion.ipynb
charlo66609/CompPhys
a28ad04f44e314adf238d4ea9dc8d73af4bce2ce
CC-BY-4.0
_notebooks/2021-08-02-Heat-Diffusion.ipynb
charlo66609/CompPhys
a28ad04f44e314adf238d4ea9dc8d73af4bce2ce
CC-BY-4.0
Qwen/Qwen-72B
1. YES
2. YES