Also called the tridiagonal matrix algorithm, or TDMA. It solves systems where each equation only involves an unknown and its two neighbours:

Discretizing a second derivative in 1D gives you this shape, so implicit schemes for diffusion produce one (Crank-Nicolson does), and so does fitting a cubic spline.

Gaussian elimination on a general matrix is , but here almost every entry is already zero and eliminating the sub-diagonal doesn’t create new ones. What’s left is two sweeps. Forward, starting from and :

Backward, starting from :

So rather than , and the matrix never gets stored, only the four vectors. scipy.linalg.solve_banded will do it.

There’s no pivoting, and every division is by , which nothing stops from being very small. It’s safe if the matrix is diagonally dominant, , which discretized diffusion gives us for free. Adding advection eats into that margin.

On Mars

Both modes of the solver in the escape model end in a Thomas sweep. The time-dependent one is Crank-Nicolson and needs one per timestep. The steady-state one sets and needs a single solve for the whole equilibrium profile, with the GCM density and the escape velocity at the exobase going into the first and last rows.

One sweep per atmospheric column, about 2048 columns per output time, over two Martian years.