# Explicit Finite Difference Scheme for 3D diffusion with variable conductivity

I'm having trouble in formulating the Finite-Difference Scheme for the 3D Heat-Diffusion equation. I think there's an error in reasoning regarding the mixed derivatives. If you are familiar with Finite-Differences I guess you can easily find my mistake(s). I'm new to numerics and tried my best, but after a couple of hours I have to admit that I need help.

This is what I've come up with.

$$\rho C_p \partial T/\partial t= \nabla (\kappa \nabla T)\\ \rho C_p \partial T/\partial t=\partial \kappa/\partial x\cdot \partial^2T/\partial x^2+\partial\kappa/\partial x\cdot \partial^2T/\partial y\partial x +\partial\kappa/\partial x\cdot \partial^2T/\partial z\partial x\\ +\partial\kappa/\partial y\cdot \partial^2 T/\partial y^2 +\partial \kappa/\partial y\cdot \partial^2 T/\partial x\partial y+\partial\kappa/\partial y\cdot \partial^2 T/\partial z\partial y\\ +\partial\kappa/\partial z\cdot \partial^2T/\partial z^2+\partial\kappa/\partial z\cdot \partial^2 T/\partial y\partial z+ \partial\kappa/\partial z\cdot \partial^2 T/\partial x\partial z$$

explicit Finite-difference scheme (I ommited $C_p$ and $\rho$ here): $$T_{i,j,k}^{n+1}=T_{i,j,k}^n+\frac{\Delta t}{(\Delta x)^2}\left[\kappa_{i+1/2,j,k}(T_{i+1,j,k}^n-T_{i,k,k}^n)-\kappa_{i-1/2,j,k}(T_{i,j,k}^n-T_{i-1,j,k}^n) \right]\\ +\frac{\Delta t}{\Delta x\Delta y}\left[\kappa_{i+1/2,j,k}(T_{i+1,j+1,k}^n-T_{i-1,j+1,k}^n)/4-\kappa_{i-1/2,j,k}(T_{i+1,j-1,k}^n-T_{i-1,j-1,k}^n)/4\right]\\ +\frac{\Delta t}{\Delta x \Delta y}\left[\kappa_{i+1/2,j,k}(T_{i+1,j,k+1}^n-T_{i-1,j,k+1}^n)/4-\kappa_{i-1/2,j,k}(T_{i+1,j,k-1}^n-T_{i-1,j,k-1}^n)/4\right]\\ +\frac{\Delta t}{(\Delta y)^2}\left[\kappa_{i,j+1/2,k}(T_{i,j+1,k}^n-T_{i,j,k}^n)-\kappa_{i,j-1/2,j,k}(T_{i,j,k}^n-T_{i,j-1,k}^n)\right]\\ +\frac{\Delta t}{\Delta y \Delta x}\left[\kappa_{i,j+1/2,k}(T_{i+1,j+1,k}^n-T_{i+1,j-1,k}^n)/4-\kappa_{i,j-1/2,k}(T_{i-1,j+1,k}^n-T_{i-1,j-1,k}^n)/4\right]\\ +\frac{\Delta t}{\Delta z \Delta y}\left[\kappa_{i,j+1/2,k}(T_{i,j+1,k+1}^n-T_{i,j-1,k+1}^n)/4-\kappa_{i,j-1/2,k}(T_{i,j+1,k-1}^n-T_{i,j-1,k-1}^n)/4\right]\\ +\frac{\Delta t}{(\Delta z)^2}\left[\kappa_{i,j,k+1/2}(T_{i,j,k+1}^n-T_{i,j,k})-\kappa_{i,j,k-1/2}(T_{i,j,k}^n-T_{i,j,k-1}^n) \right]\\ +\frac{\Delta t}{\Delta x \Delta z}\left[ \kappa_{i,j,k+1/2}(T_{i+1,j,k+1}^n-T_{i+1,j,k-1}^n)/4-\kappa_{i,j,k-1/2}(T_{i-1,j,k+1}^n-T_{i-1,j,k-1}^n)/4\right]\\ +\frac{\Delta t}{\Delta y \Delta z}\left[\kappa_{i,j,k+1/2}(T_{i,j+1,k+1}^n-T_{i,j+1,k-1})/4-\kappa_{i,j,k-1/2}(T_{i,j-1,k+1}^n-T_{i,j-1,k-1}^n)/4\right]$$

• For the simplest approximation there should be no mixed derivative terms. Just get rid of those. I suggest that you've confused the first $\nabla$ (which is $\operatorname{div}$ operator) with $\operatorname{grad}$ operator – uranix Oct 7 '16 at 20:47

$$\rho C_p \partial T/\partial t= \vec{\nabla}. (\kappa \vec{\nabla} T) = \kappa \nabla^2 T + \vec{\nabla}\kappa .\vec{\nabla} T$$
$$\rho C_p \partial T/\partial t= (\frac{\partial}{\partial x}, \frac{\partial}{\partial y}, \frac{\partial}{\partial z}).(\kappa \frac{\partial T}{\partial x}, \kappa \frac{\partial T}{\partial y}, \kappa \frac{\partial T}{\partial z})\\ = \kappa \left[\frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2}+ \frac{\partial^2 T}{\partial z^2}\right] + \frac{\partial \kappa}{\partial x}\frac{\partial T}{\partial x} + \frac{\partial \kappa}{\partial y}\frac{\partial T}{\partial y} + \frac{\partial \kappa}{\partial z}\frac{\partial T}{\partial z}$$