Model description
AGNI is a 1D radiative-convective atmosphere model designed to simulate the climates of rocky exoplanets under extreme conditions [1, 2].
It models a planetary atmosphere as a single column split into $N$ pressure levels (cell-centres) bounded by $N+1$ cell-edge interfaces. Levels are distributed logarithmically in pressure between the surface and the top of the atmosphere. The atmosphere is assumed to be plane-parallel.
Thermodynamic quantities (temperature, pressure, heat capacity, density, composition) are calculated at level-centres; energy fluxes are calculated at level-edges.
Physics overview
AGNI accounts for the following energy transport processes:
| Process | Symbol | Description |
|---|---|---|
| Radiative transfer | $F^\text{rad}$ | Spectral SW + LW radiation; SOCRATES correlated-k |
| Convection | $F^\text{cvt}$ | Mixing-length theory parameterisation |
| Latent heat | $F^\text{lat}$ | Condensation and evaporation of volatiles |
| Sensible heat | $F^\text{sns}$ | Turbulent surface–atmosphere exchange |
| Thermal conduction | $F^\text{cdt}$ | Molecular thermal conduction (negligible except in the thermosphere) |
| Deep heating | $F^\text{deep}$ | Advective or interior heat deposition (optional) |
The total net upward-directed energy flux at each cell edge $l$ is the sum of all contributions:
\[F_l = F^\text{sns}_l + F^\text{cvt}_l + F^\text{lat}_l + F^\text{rad}_l + F^\text{cdt}_l\]
For a detailed description of each process, see the corresponding pages in this section:
- Radiative transfer - correlated-k RT with SOCRATES, opacity sources, greenhouse physics
- Atmospheric convection - mixing-length theory, Schwarzschild criterion, convective shutdown
- Thermodynamics and EOS - equations of state, heat capacities, saturation pressures, latent heats
- Composition and chemistry - condensation scheme, ocean model, FastChem equilibrium chemistry
- Sensible heat flux - turbulent surface exchange
- Height structure - hydrostatic integration, self-gravity
- Advective heating - deep heat deposition profile
- Multicolumn and global mode - pseudo-global climate via coupled 1D columns
Obtaining a solution
AGNI is designed for modelling planetary atmospheres with high surface pressures and temperatures. Radiative timescales can differ by many orders of magnitude across the column, which makes time-stepping methods slow to converge. AGNI instead solves for the temperature structure as an optimisation problem - finding the $T(p)$ profile that exactly conserves energy at all levels simultaneously.
Solution types
The solution_type configuration variable specifies the boundary condition for the surface temperature $T_s$:
- (1) Fixed surface temperature. $T_s$ is held constant. Useful for computing the OLR for a prescribed surface temperature.
- (2) Conductive boundary layer. $T_s$ is determined by energy balance through a thin conductive boundary layer (CBL) of thickness $d_c$ and conductivity $\kappa_c$: $F^\text{atm} = \kappa_c (T_m - T_s) / d_c$, where $T_m$ is the prescribed mantle temperature. This is used when coupling AGNI to a magma ocean interior model within the PROTEUS framework [2, 3].
- (3) Free surface temperature. $T_s$ is solved for alongside the rest of the atmosphere, subject to a prescribed net flux $F^\text{atm} = \sigma T_\text{int}^4$, where $T_\text{int}$ is an internal (intrinsic) temperature representing interior heat production.
- (4) Target OLR. $T_s$ and the temperature profile are solved such that the outgoing longwave radiation at the top of the atmosphere matches a user-specified target value.
Construction
The energy flux schemes in AGNI all take cell-centre temperatures $T_l$, pressures $p_l$, geometric heights, and mixing ratios as input variables at each level. In return, they provides energy fluxes $F_l$ at all $N+1$ interfaces.
The total upward-directed energy flux $F_l$ describes the total upward-directed energy transport (units of $\text{W m}^{-2}$) from cell $l$ into cell $l-1$ above (or into space for $l=1$). For energy to be conserved throughout the column, it must be true that $F_l = F_t \text{ } \forall \text{ } l$ where $F_t$ is the total amount of energy being transported out of the planet. In global radiative equilibrium, $F_t = 0$.
Definition of residuals
We solve for the temperature profile of the atmosphere as an $N+1$-dimensional optimisation problem. This directly solves for $T(p)$ at radiative-convective equilibrium without invoking heating-rate calculations, thereby avoiding slow convergence in regions with long radiative timescales. The residuals vector (length $N+1$)
\[\bm{r} = \begin{pmatrix} r_l \\ r_{l+1} \\ \vdots \\ r_N \\ r_{N+1} \end{pmatrix} = \begin{pmatrix} F_{l+1} - F_l \\ F_{l+2} - F_{l+1} \\ \vdots \\ F_{N+1} - F_N \\ F_{N+1} - F^\text{atm} \end{pmatrix}\]
is what we minimise as our objective function, subject to the solution vector of cell-centre temperatures
\[\bm{x} = \begin{pmatrix} T_l \\ T_{l+1} \\ \vdots \\ T_N \\ T_s \end{pmatrix}\]
where $T_s$ is the surface temperature. Cell-edge temperatures in the bulk atmosphere are interpolated from cell-centres. The bottom- and top-most cell-edge temperatures are extrapolated by estimation of $dT/d\log p$. Cell properties (heat capacity, gravity, density, mean molecular weight) are consistently updated at each evaluation of $\bm{r}$. Condensation and rainout are also handled at each evaluation to avoid supersaturation.
The model converges when the cost function
\[\mathcal{C}(\bm{x}) = \left(\sum_l |r_l|^p\right)^{1/p}\]
satisfies
\[\mathcal{C}(\bm{x}) < \mathcal{C}_a + \mathcal{C}_r \cdot \underset{l}{\max}\ |F_l|\]
which represents a state where fluxes are sufficiently conserved. The quantities $\mathcal{C}_a$ and $\mathcal{C}_r$ are the absolute and relative tolerances provided by the user (parameters conv_atol and conv_rtol in solver.solve_energy!()). The order of the norm is $p=4$ by default (parameter cost_exponent), which weights the cost towards the levels furthest from energy balance. The maximum flux $\max_l |F_l|$ is taken over the four lowest cell edges.
Iterative steps
The model solves for $\bm{x}$ iteratively starting from some initial guess. The flowchart below broadly outlines the solution process.
The Jacobian matrix $\bm{J}$ represents the directional gradient of the residuals with respect to the solution vector:
\[J_{uv} = \frac{\partial r_u}{\partial x_v}\]
AGNI estimates $\bm{J}$ using a finite-difference scheme, requiring $2(N+1)$ evaluations of $\bm{r}$. Since each evaluation requires a full radiative transfer calculation, constructing the Jacobian dominates the cost of the solver. To reduce the total number of calculations, AGNI retains Jacobian columns between iterations when the local residuals are small - this assumes the second derivative of the residuals is small in converged regions.
Alternatively, the Jacobian may be updated between iterations with Broyden's method [4] (configuration option execution.broyden). After a step $\bm{s} = \bm{x}_{k+1} - \bm{x}_k$ changes the residuals by $\bm{y} = \bm{r}_{k+1} - \bm{r}_k$, the rank-one update
\[\bm{J}_{k+1} = \bm{J}_k + \frac{(\bm{y} - \bm{J}_k \bm{s})\, \bm{s}^\mathsf{T}}{\bm{s}^\mathsf{T} \bm{s}}\]
is the smallest change to $\bm{J}_k$ which satisfies $\bm{J}_{k+1} \bm{s} = \bm{y}$. Because $\bm{y}$ is evaluated after the composition has been updated, this also captures the response of condensation and chemistry to the step. The Jacobian is recalculated with finite differences on the first step, after at most 10 consecutive Broyden updates (parameter broyden_refresh), when the convective flux scale factor is increased (easy_start), when the radiative transfer scheme changes (grey_start), and when the linesearch (below) fails. This reduces the number of radiative transfer calculations at the cost of taking more, less accurate, steps. Broyden updates are intended for use with the non-monotone Armijo linesearch, whose failures trigger these recalculations.
With a Jacobian constructed, the Newton–Raphson update step is
\[\bm{d} = -\bm{J}^{-1} \bm{r}\]
Gauss-Newton and Levenberg–Marquardt [5] methods are also supported as alternatives. The Levenberg–Marquardt step solves $(\bm{J}^\mathsf{T}\bm{J} + \lambda \bm{D})\,\bm{d} = -\bm{J}^\mathsf{T}\bm{r}$, where $\bm{D}$ is the diagonal of $\bm{J}^\mathsf{T}\bm{J}$. The damping parameter $\lambda$ is increased until the step reduces $\lVert \bm{r} \rVert_2$, and then adapted according to how well the linear model predicted that reduction.
Three stabilisation strategies are applied to $\bm{d}$:
- Nudging: when the model is stuck at a local minimum ($|\bm{d}|$ is on a plateau), $\bm{d}$ is scaled up.
- Clipping: when $|\bm{d}| > d_\text{max}$, the step is scaled back by a factor $s \le 1$ to $d_\text{max} \hat{\bm{d}}$ to prevent instabilities from the non-convex solution space.
- Line search: $\bm{d}$ is scaled by a factor $\alpha$, chosen to reduce the cost. AGNI provides golden-section and backtracking searches, which are applied when the full step would not reduce the cost by enough. It also provides a non-monotone Armijo search [6], which tries the full step first and then backtracks, accepting the first $\alpha$ which satisfies
\[\mathcal{C}(\bm{x}_k + \alpha \bm{d}) \le \max_{0 \le j < M} \mathcal{C}(\bm{x}_{k-j}) - c_1\, \alpha\, s\, \mathcal{C}(\bm{x}_k)\]
with $c_1 = 10^{-4}$ and memory $M = 5$ (parameter ls_memory). Because the Newton step reduces the residuals linearly along $\bm{d}$, the final term is the decrease in cost predicted by the linear model. Comparing against the largest of the last $M$ costs, rather than the current cost, allows temporary increases in the cost, which may help the solver to move through regions where the cost changes abruptly. Unlike the backtracking search, this condition remains satisfiable when the step has been clipped, so it does not stall when $d_\text{max}$ limits the step size.
Other features
Emission spectra
AGNI can calculate emission spectra from a given $T(p)$ profile and gas volume mixing ratios. The longwave contribution function can also be computed.
Transparent atmospheres
For bare-rock planets, or to determine a planet's surface temperature in the absence of an atmosphere, AGNI supports a transparent atmosphere mode (composition.transparent = true). This sets the atmospheric pressure to a small value and disables all gas opacity and absorption in SOCRATES. Use the dedicated transparent solver in this case.
Exobase diagnostic
AGNI estimates where the exobase, the level at which the collisional mean free path equals the pressure scale height, might exist within the modelled atmosphere. It calculates this based on the $n$ is the number density, $\bar{m}$ the mean particle mass, and $\sigma = \sum_j x_j \pi \sigma_j^2$ the mole-fraction-weighted hard-sphere cross-section from the Lennard-Jones collision diameters. If none of the layers reach this criterion, the exobase variables are set equal to the TOA values.
Energy-transport timescales
After solve_energy! or solve_prescribed! has finished, AGNI estimates three timescales in each layer. These indicate how quickly radiation, convection and conduction would each act to remove a temperature perturbation. They are order-of-magnitude diagnostics which are not used by the solver, so they should be interpreted with care. They are written to the output NetCDF file. A value of NaN means that a timescale was not computed: the arrays are NaN until a solver fills them, and the transparent-atmosphere solver does not calculate them.
The radiative timescale is that of a layer of pressure thickness $\Delta p$ which is slightly out of radiative equilibrium and radiates to space as a blackbody [7],
\[\tau_\text{rad} = \frac{\Delta p}{g} \, \frac{c_p}{4 \sigma T^3}\]
The convective timescale,
\[\tau_\text{conv} = \lambda / w\]
uses the mixing length and convective velocity from Atmospheric convection. It is zero in layers which are stable against convection (where $w = 0$), which should not be read as instantaneous transport.
The conductive timescale,
\[\tau_\text{cond} = \frac{\Delta z^2}{\kappa} = \frac{\rho \, c_p \, \Delta z^2}{k}\]
is the time for heat to diffuse across a layer of geometric thickness $\Delta z$. Here, $\kappa = k / (\rho c_p)$ is the thermal diffusivity and $k$ is the thermal conductivity of the gas mixture described in Thermodynamics and EOS. It is calculated whether or not conduction is enabled in the energy balance. It is infinite where $k = 0$, and NaN where $k$ is negative or NaN. By hydrostatic balance, $\Delta p = \rho g \Delta z$, so the ratio of the two timescales within a layer is $\tau_\text{cond}/\tau_\text{rad} = 4 \sigma T^3 \Delta z / k$.
Since $\tau_\text{rad} \propto \Delta p$ and $\tau_\text{cond} \propto \Delta z^2$, both depend on the vertical resolution of the model, while $\tau_\text{conv}$ does not. Comparisons between models with different numbers of levels should account for this.
Julia and Fortran
AGNI is primarily written in Julia [8], while SOCRATES is written in Fortran. Julia's precompilation allows the SOCRATES Fortran binaries to be packaged inside the precompiled Julia code, which significantly improves startup performance.
Bibliography for this page
- [1]
- H. Nicholls, R. Pierrehumbert and T. Lichtenberg. AGNI: A radiative-convective model for lava planet atmospheres. Journal of Open Source Software 10, 7726 (2025).
- [2]
- H. Nicholls, R. T. Pierrehumbert, T. Lichtenberg, L. Soucasse and S. Smeets. Convective shutdown in the atmospheres of lava worlds. MNRAS 536, 2957–2971 (2025).
- [3]
- H. Nicholls, T. Lichtenberg, D. J. Bower and R. Pierrehumbert. Magma Ocean Evolution at Arbitrary Redox State. Journal of Geophysical Research: Planets 129, e2024JE008576 (2024).
- [4]
- C. G. Broyden. A class of methods for solving nonlinear simultaneous equations. Mathematics of Computation 19, 577–593 (1965).
- [5]
- D. W. Marquardt. An Algorithm for Least-Squares Estimation of Nonlinear Parameters. Journal of the Society for Industrial and Applied Mathematics 11, 431–441 (1963).
- [6]
- L. Grippo, F. Lampariello and S. Lucidi. A Nonmonotone Line Search Technique for Newton's Method. SIAM Journal on Numerical Analysis 23, 707–716 (1986).
- [7]
- A. P. Showman, J. Y.-K. Cho and K. Menou. Atmospheric Circulation of Exoplanets. In: Exoplanets, edited by S. Seager (University of Arizona Press, 2010); pp. 471–516.
- [8]
- J. Bezanson, A. Edelman, S. Karpinski and V. B. Shah. Julia: A fresh approach to numerical computing. SIAM Review 59, 65–98 (2017).