1.9. Treatment of Partial Differential Equations: a start#
Partial Differential Equations (PDEs) are characterized by having more than one independent variable. They can be classified as the ODEs, in linearity or non linearity, first order, second order or higher. See the following widely used PDEs:
As you can see, there are PDEs that depend only on space variables (e.g. poisson equation) and those that depend on time and space (e.g. diffusion equation). We will now mainly treat the latter using the method of lines. Let’s look at a new notation. Consider the variable \(u\) at the location \(x=i\) and time \(t=j\). It can be written as:
Method of Lines#
This method transforms the PDE into a system of ordinary differential equations by replacing the spatial derivatives with a numerical approximation. Let’s see this transformation in the diffusion equation using the dependent variable temperature \(T\) and the independent variable \(x\) for space:
Clearly \(T(x,t)\) varies in time and space. Due to the first derivative, an initial condition is needed: the initial temperature defined in the whole space of interest. Due to the second derivative, two boundary conditions are needed. The spatial second derivative can be approximated with any method, in this example a central difference is used:
The counter of that equation does not start at i=0 and it does not end at \(n\) due to the BC. For constant Dirichlet conditions, \(T^t_{0/n}=T_{left/right}\) at all times. Let’s consider a problem with a grid of 5 points with only three unknowns (again due to the BC), the system of ODEs becomes:
Solution with Forward Euler for the time discretization#
Then, the time derivative is approximated, with any method, here we use the explicit method Forward Euler:
To approximate the temperature for \(t=1\), the system of equations starts at \(j=0\), as it is an explicit method, we can already solve for the next time step:
The solution for \(T^1_{1,2,3}\) is directly found because \(T^0_{1,2,3}\) are known thanks to the initial condition.
Solution with Backward Euler for the time discretization#
If instead of an explicit Forward Euler, we use an implicit scheme like Backward Euler, the system of ODEs becomes:
Separating the unknowns:
This can be written as \(Ay=b\) and can be solved in a similar way as the second order ODE of the previous chapter:
For the \(T*2_{1,2,3}\) the solution can be found in the same way given that now \(T*1_{1,2,3}\) are known.
Procedure Summary#
Some of the following steps can be re ordered without affecting the solution. The following structure is proposed:
Discretization of the spatial derivative with a numerical approximation
Discretization of the time derivative with a numerical approximation
Parameter definition
Grid creation
Define Initial conditions
Define Boundary conditions
Building a system of equations according to the discretization
Solve the system
Go back to 7 until the final time step, \(m\), is reached.