nichollsh / AGNI

A 1D radiative-convective model for the atmospheres of hot terrestrial planets.
https://nichollsh.github.io/AGNI/
1 stars 1 forks source link

Code optimisations #15

Open nichollsh opened 6 months ago

nichollsh commented 6 months ago

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.

nichollsh commented 5 months ago

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.

nichollsh commented 3 months ago

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.

nichollsh commented 3 months ago

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.