nichollsh/AGNI

Code optimisations

Closed this issue · 3 comments

The current state of the code is not very well optimised. I am certain there are several memory allocations and loops that can be removed or reworked.

It would also be worth considering some of the Julia optimisation macros (e.g. @simd) to enhance performance.

Testing various numerical methods for the nonlinear solver. See this article (https://arxiv.org/pdf/1201.5885.pdf) for information on advanced methods with acceleration and reliability improvements.

One thing that could be worth trying...

Rather than calculating the full jacobian at each step, we could instead calculate a sub-jacobian for all the levels which are not yet converged. This would provide deltaX for each of those levels, while converged levels would not be adjusted.

It would significantly increase model performance since removing each row/column from the jacobian means 1 less RT calculation.

Similarly to the jacobian thing...

It would not be too tricky to include adaptive mesh refinement for the pressure-grid in AGNI. Layer properties (e.g. height, gravity) are recalculated when requested anyway, so it would simply be a case of inserting/removing values in the pressure array. Alternatively, we could keep the same number of levels but stretch/squeeze them to increase the resolution in certain parts of the grid, which would require zero extra memory allocations.

This would improve model stability in convective regions, since the convective flux can be quite discontinuous at the bottom/top of these regions.