# 3D Diffusion Equation in Fourier space

I'm solving the 3D Diffusion equation $$u_t=k(u_{xx}+u_{yy}+u_{zz})$$

in MATLAB using Fourier techniques. I assume a 3D Fourier expansion $(e^{-ipx},e^{-imy},e^{-imz})$of the solution.

Physical space: $u(x,y,z,t)$. Fourier Space: $c(m,n,p,t)$.

Substitution and differentiation result in: $$c(m,n,p)^{N+1}-c(m,n,p)^{N} = -\frac{k\Delta T}{2} (p^2+m^2+n^2)(c(m,n,p)^{N+1}+c(m,n,p)^{N})$$ after applying a Crank-Nicolson scheme.

I'm using fftn() and ifftn() to forward my coefficients in time and bring them back to physical space. However I achieve universal decay from the initial condition to zero with no heat flux in any direction, for all time. Typical time step: 0.00001. Typical k=0.005.

Is the problem with my application of fftn() or the stability of my finite-difference?

Edit: I've taken an initial condition of $50 \sin(2x)$. I merely took the boundaries of that initial condition and imposed them as the boundary conditions for all time. No good I'm guessing?

Edit 2: I forgot the wavenumber squared on the rhs. Thanks James!

• What are your boundary conditions? if $u(x,y,z,t)=0$ everywhere on your boundaries, $0$ is the steady state solution. – Bill Barth Jan 22 '16 at 14:41
• Shouldn't you be multiplying c(m,n,p) by the wavenumber squared on the r.h.s. because of the second derivative? – James Jan 23 '16 at 1:51