# Solving diffusion PDE using finite differences

I need some hints on how to solve this diffusion equation ($\alpha, k_1,k_2$ and $k_3$ are constants):

$${\partial P \over \partial y} + k_1 {\partial P \over \partial t} + \alpha P = {1 \over k_2} {1 \over x}{\partial \over \partial x} \left(x k_3 {\partial P \over \partial x}\right)$$

With boundary conditions:
$P(x=1,y,t)=0$
$k_3 {\partial P \over \partial x}|_{x=0}=0$
$P(x,0,t)=p(x)$

I've been told that DuFort-Frankel is a proper method for this example, so I tried (not sure if it is correct):

$${P_{i,j+1}^n-P_{i,j-1}^n \over 2 \Delta y}+k_1{P_{i,j}^{n+1}-P_{i,j}^{n-1} \over 2 \Delta t}+\alpha P_{i,j}^n = {k_3 \over k_2x}\left({P_{i+1,j}^n-P_{i-1,j}^n \over 2 \Delta x}+x{P_{i+1,j}^n-(P_{i,j}^{n+1}+P_{i,j}^{n-1})+P_{i-1,j}^n \over \Delta x^2}\right)$$

But I don't know how tie this with boundary conditions so I can solve it using recursive functions... It is supposed to be pretty easy, am I missing something? DuFort-Frankel is not necessary, if You know how to solve it using Taylor, Leapfrog, Richardson or any other method, I would be very grateful for any hints...

-

## migrated from math.stackexchange.comJan 23 '13 at 0:06

This question came from our site for people studying math at any level and professionals in related fields.

You may want to express $x$ in terms of $i$ (I assume that $i$ is a horizontal, while $j$ is a vertical lattice point). – rlgordonma Jan 10 '13 at 21:48
You mean I should use $i \Delta x$ instead of $x$? Still cannot figure out how to make use of the boundary conditions... – apm Jan 10 '13 at 23:18
Yes, that's what I mean. – rlgordonma Jan 10 '13 at 23:31