Cats2D Multiphysics > Developments > Timestep tests

## Trapezoid rule versus backward Euler time integration

Cats2D allows two methods of time integration, the second-order trapezoid rule and the first-order backward Euler method. I always use the trapezoid rule (TR), but it is useful to have backward Euler (BE) around for testing purposes, because it is so simple that almost nothing can go wrong with it.

Both methods are A-stable, which is a must for this kind of work. But BE requires a much smaller time step than TR to achieve good accuracy on nontrivial problems, so it loses badly on efficiency. This is mostly because of the difference in convergence order of the methods, first versus second, but BE is also dissipative whereas TR is not. This gives BE the tendency to artificially attenuate oscillations, which could mask the presence of weak physical instability.

I show here computations of unstable natural convection that I've found in a vertical Bridgman system operated with a destablizing temperature profile. RMS average velocity is plotted versus time starting at the onset of growth from a steady, but unstable, flow computed with the growth interface held fixed. After a few minutes the instability sends the flow into a limit cycle. Initially the period is 53 seconds and gradually decreases to 41.5 seconds as the system stabilizes. Both curves were computed using TR, the blue curve with a step size of 0.25 seconds and the red curve with a step size of 0.10 seconds. The agreement is so close that the blue curve is hardly distinguishable under the red curve, indicating convergence of the TR method with respect to step size:

Examining the final minutes of unstable flow shows that the period has not drifted at all between the calculations:

In this next comparison, the blue curve was computed by TR and the red curve by BE, using a step size of 0.25 seconds in both cases. The amplitude differs visibly throughout the integration, indicating that BE is far from convergence at this step size. The dissipative nature of BE is made apparent by its progressive tendency to underestimate the amplitude:

The error in period predicted by BE is not nearly as bad as amplitude, but it does drift somewhat from the TR result, as shown by this plot of the final ten minutes of decay:

Reducing the step size to 0.1 seconds for BE noticeably improves the situation, but some disagreement is still evident:

The drift in the period is only very slight, however, at this step size:

Reducing the step size to 0.025 seconds for BE achieves reasonable agreement with the TR results.

But the cost was very high. BE required ten times as many time steps as TR, and there was very little reduction in computational effort per time step to offset it.

These tests required over 300,000 time steps to complete. Was it worth it? You betcha. It gives me peace of mind to know that the limit cycle predictions shown here are robust to changes in numerical methods and parameters. Also, it is a good demonstration of the considerable advantage that TR has over BE in terms of accuracy and performance. Its non-dissipative character is particularly beneficial to the careful probing of weakly unstable flows, for example in the neighborhood of a bifurcation.