179 | | Also if $\kappa$ is a constant, then we have |
| 187 | |
| 188 | And our equation becomes |
| 189 | |
| 190 | $T_0 + \Delta t \displaystyle \sum_{\parallel, \perp} AC \left [ \alpha_0 T^{\lambda+1}_0 + \displaystyle \sum_{\pm j} \alpha_{\pm j} T^{\lambda+1}_{\pm \hat{j}} \right ] = $ |
| 191 | $T'_0 - \Delta t \displaystyle \sum_{\parallel, \perp} AD \left [ \alpha_0 T^{\lambda}_0T'_0 + \displaystyle \sum_{\pm j} \alpha_{\pm j} T^{\lambda}_{\pm \hat{j}} T'_{\pm \hat{j}} \right ]$ |
| 192 | |
| 193 | |
| 194 | Now in the code, |
| 195 | || $A = A$ || |
| 196 | || $C = \frac{\Delta t A C}{\Delta x^2}$ || |
| 197 | || $D = \frac{\Delta t A D}{\Delta x^2}$ || |
| 198 | || $\mbox{Tlambda} = T_{\pm \hat{j}}^\lambda$ || |
| 199 | || $\mbox{T} = T_{\pm \hat{j}}$ || |
| 200 | || $\mbox{T0} = T $ || |
| 201 | || $\mbox{T0lambda} = T^{\lambda}$ || |
| 202 | |
| 203 | And stencil(0) has the coefficient of $T_0'$, and stencil(1:2*ndim) has the coefficients of $T_{\pm \hat{j}}'$ and source has everything else. |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | Now if $\kappa$ is a constant, then we have |