I’m pissed off. The f*ing Crank-Nicolson scheme for numerically solving diffusion equations isn’t stable. All of the textbooks state that it’s unconditionally stable. Liars. The fine print on this stability claim is that this unconditionality is for a constant diffusion coefficient. Large gradients in the diffusion coefficient can cause oscillations in the solution. Another issue is that there is a time and space step criterion on its stability. If the time step is too large relative to the spatial step, then oscillations appear. Another problem is that if the diffusion coefficient is too big, then the scheme tries to rearrange the result too much and again introduces oscillations. The net result is that the solution gives negative and/or very large values and the code crashes. I am now in search of another numerical scheme that can handle my large, spatially varying diffusion coefficients and nonuniform spatial grid. I have wasted nearly a week only to discover that my code was working perfectly and doing exactly what I was telling it to do: oscillate until it blows up.
Ode to Bureaucracy
2 years ago