MAT6669: Heat and Materials with Application Magnus Anderson
2D modelling
In this example we are interested in testing the numerical scheme to solve the following partial differential equation
𝜕𝑇 − 𝛼 𝜕2𝑇 − 𝛼 𝜕2𝑇 = 0 1 𝜕𝑡 𝜕𝑥2 𝜕𝑦2
To test the implementation, we will use the Gaussian analytical solution which has the following form
1 𝑇=𝑇+ 𝑒𝑥𝑝(−
0
4𝛼𝑡
) 2 shift the centre of the Gaussian profile.
(𝑥−𝑥0)2 +(𝑦−𝑦0)2 4𝛼𝑡
Where 𝑇 000
is the base temperature, and 𝑥 and 𝑦
We will use Equation 2 to determine the initial temperature field, and compare the numerically
evolved temperature field with the analytical solution.
We can apply finite difference with the following one sided forward fist derivative for the temporal derivative
𝜕𝑇 𝑇𝑛+1−𝑇𝑛 =𝑖𝑖
𝜕𝑡 Δ𝑡
3
4 5
6
And the following implicit three point, two sided finite difference term for the second spatial derivative
𝜕2𝑇 𝜕𝑥2
𝜕2𝑇 𝜕𝑦2
𝑇𝑛+1 − 2𝑇𝑛+1 + 𝑇𝑛+1 = 𝑖+1,𝑗 𝑖,𝑗 𝑖−1,𝑗
Δ𝑥2
𝑇𝑛+1 − 2𝑇𝑛+1 + 𝑇𝑛+1
= 𝑖,𝑗+1 𝑖,𝑗 Δ𝑦2
𝑖,𝑗−1
Substituting Equations 3, 4, and 5 into Equation 1
𝑇𝑛+1 − 𝑇𝑛 𝑇𝑛+1 − 2𝑇𝑛+1 + 𝑇𝑛+1
Δ𝑡 Δ𝑥2 Δ𝑦2
𝑇𝑛+1 − 2𝑇𝑛+1 + 𝑇𝑛+1
𝑖 𝑖 −𝛼 𝑖+1,𝑗 𝑖,𝑗 𝑖−1,𝑗 −𝛼 𝑖,𝑗+1 𝑖,𝑗 𝑖,𝑗−1 =0
We can now rearrange the knowns and the unknowns
𝑇𝑛+1 −Δ𝑡𝛼(𝑇𝑛+1 −2𝑇𝑛+1 +𝑇𝑛+1)−Δ𝑡𝛼(𝑇𝑛+1 −2𝑇𝑛+1 +𝑇𝑛+1)=𝑇𝑛 7
𝑖 Δ𝑥2 𝑖+1,𝑗 𝑖,𝑗 𝑖−1,𝑗 Δ𝑦2 𝑖,𝑗+1 𝑖,𝑗 𝑖,𝑗−1 𝑖
We can assume that the grid spacing is the same in the x and y directions, and introduce the Fourier number,𝐹 =Δ𝑡𝛼
𝑇𝑛+1 −𝐹(𝑇𝑛+1 −2𝑇𝑛+1 +𝑇𝑛+1)−𝐹(𝑇𝑛+1 −2𝑇𝑛+1 +𝑇𝑛+1)=𝑇𝑛 8 𝑖 𝑜 𝑖+1,𝑗 𝑖,𝑗 𝑖−1,𝑗 𝑜 𝑖,𝑗+1 𝑖,𝑗 𝑖,𝑗−1 𝑖
𝑜 Δ𝑥2
With some rearrangement and grouping of terms we arrive at
(1+4𝐹)𝑇𝑛+1−𝐹𝑇𝑛+1 −𝐹𝑇𝑛+1 −𝐹𝑇𝑛+1 −𝐹𝑇𝑛+1 =𝑇𝑛 𝑜 𝑖,𝑗 𝑜 𝑖+1,𝑗 𝑜 𝑖−1,𝑗 𝑜 𝑖,𝑗+1 𝑜 𝑖,𝑗−1 𝑖
9
MAT6669: Heat and Materials with Application Magnus Anderson
Boundary conditions
We need to determine how to deal with the boundary conditions of the problem. We are simulating the diffusion of the Gaussian profile described by Equation 2.
One approach is to ensure that the solution remains within the discretized space such that the temperature of the boundaries remains at a value of 𝑇 . The finite difference scheme may be
altered at the boundaries so that they are forward or backward and do not index locations that are outside of the discretized space. This is the method used in the Matlab script “ex_matlab_implicit_2D.m”.
Another approach is to use ghost points. A larger grid is used that includes an additional point on each side of the boundary. The temperature at these locations can be extrapolated from the temperature field data. The finite difference is then applied to the internal points on the larger grid, simplifying the FD scheme employed. This approach is described in the Matlab script “ex2_Gauss_Seidel_implicit_2D.m” file.
0