This is a wonderful tutorial. I don’t work with geology, but am simply trying to gain a practical understanding of finite differencing methods. Your explanations and code are perfect for my purposes. I’d like to point out a small bug in line 53 of your plot comparing numerical and analytical solutions. At present, it is:

V_analytic = diffusion_analytic(t,0.04,40,dy,viscosity)

Here the value for V0 is hard coded as 40, whereas the variable for V0 holds the value 10. This causes a mismatch between analytic and numerical results.

And just one more minor thing: When running this code with Python 3, I get an error for the expression V[t/dt,:], as t/dt evaluates to a float rather than the int required for indexing. This was easily fixed in this way: V[int(t/dt),:]

Many thanks again!

Thanks for providing valuable python code for heat transfer.

Recently, I was trying to compute diurnal variation of temperature at different depth. I have surface temperature variation with time for 2 consecutive day, which can be used as top boundary condition. Temperature at depth of 1 m is constant and can be used as bottom boundary condition. I have assumed a temperature with depth at t=0 as initial condition.

My problem is how to use above codes for computing diurnal temperature with time with above information. Diffusivity at different depth is known.

]]>Thanks again for the excellent blog post, even if it is almost 10 years old! ðŸ™‚

]]>Perhaps you might be interested in my post on backstripping that includes implementation of decompaction: https://zaretskiy.blog/2017/03/21/backstripping/.

I use numerical integration and Newton’s iteration which allow for an arbitrary porosity-depth relationship (including zero compaction rate) and faster convergence compared to bisection. ]]>

And this river is flowing North? Thank you! ]]>