Computational Physics - Department of Physics

(Axel Boer) #1

10.3 Laplace’s and Poisson’s Equations 315


10.2.5Explict scheme for the diffusion equation in two dimensions


We end this section by setting up an explicit scheme for the diffusion equation in two spatial
coordinates. Here we assume that we are dealing with dimensionless quantities. The implict
scheme is discussed in section 10.3. The 2 + 1 -dimensional diffusion equation, with the diffu-
sion constantD= 1 , is given by
∂u
∂t


=

(

∂^2 u
∂x^2

+∂

(^2) u
∂y^2


)

,

where we haveu=u(x,y,t). We assume that we have a square lattice of lengthLwith equally
many mesh points in thexandydirections.
We discretize again position and time using now


uxx≈
u(x+h,y,t)− 2 u(x,y,t)+u(x−h,y,t)
h^2 ,

which we rewrite as, in its discretized version,


uxx≈

uli+ 1 ,j− 2 uli,j+uli− 1 ,j
h^2 ,

wherexi=x 0 +ih,yj=y 0 +jhandtl=t 0 +l∆t, withh=L/(n+ 1 )and∆tthe time step. We have
defined our domain to startx(y) = 0 and end atX(y) =L. The second derivative with respect
toyreads


uyy≈

uli,j+ 1 − 2 uli,j+uli,j− 1
h^2
We use again the so-called forward-going Euler formula for the first derivative in time. In its
discretized form we have


ut≈

uil+,j^1 −uli,j
∆t

,

resulting in
uli+,j^1 =uli,j+α


[

uli+ 1 ,j+uli− 1 ,j+uli,j+ 1 +uli,j− 1 − 4 uli,j

]

,

where the left hand side, with the solution at the new time step, is the only unknown term,
since starting witht=t 0 , the right hand side is entirely determined by the boundary and initial
conditions. We haveα=∆t/h^2. This scheme can be implemented using essentially the same
approach as we used in Eq. (10.7). To find the constraints on∆tandhis left as an exercise.


10.3 Laplace’s and Poisson’s Equations


Laplace’s equation reads
∇^2 u(x) =uxx+uyy= 0.


with possible boundary conditions u(x,y) =g(x,y) on the borderδ Ω. There is no time-
dependence. We seek a solution in the regionΩand we choose a quadratic mesh with equally
many steps in both directions. We could choose the grid to be rectangular or following polar
coordinatesr,θas well. Here we choose equal steps lengths in thexand theydirections. We
set
h=∆x=∆y=


L

n+ 1 ,
whereLis the length of the sides and we haven+ 1 points in both directions.
The discretized version reads

Free download pdf