Using the model

Follow the Getting started instructions. Only read on once you have confirmed that the model runs on your machine. Otherwise, see the Troubleshooting guide.

Input data files

The minimal input data required to run the model will have been downloaded automatically from Zenodo. If you require more data, such as additional stellar spectra or opacities, then these can also be easily obtained using the get_data script in the AGNI root directory. To see how to use this script, run it without arguments like so:

./src/get_data.sh

Opacities are contained within "spectral files". Use the table within res/spectral_files/reference.pdf to decide which spectral files are best for you.

For example, if you wanted to get the spectral file "Honeyside48" you would run:

./src/get_data.sh anyspec Honeyside 48

Tutorials

There are Jupyter notebooks containing tutorials in the tutorials/ directory of the repository.

General execution

The environment variable RAD_DIR must point to the SOCRATES installation directory. This is required for AGNI to find the SOCRATES libraries. The best way to do this is to add RAD_DIR=path/to/socrates/folder/ to your shell rc file (e.g. ~/.bashrc).

Then to use the model, simply run

./agni.jl [cfg]

where [cfg] is the path to the desired configuration file. If [cfg] is not passed, then the default configuration file will be used.

You should see the following output:

[ INFO  ] Using configuration 'Default'
[ INFO  ] Setting-up a new atmosphere struct
[ INFO  ] Loading thermodyamic data
[ INFO  ] Inserting stellar spectrum and Rayleigh coefficients
[ INFO  ] Allocating atmosphere with composition:
[ INFO  ]       1 H2O     1.00e+00 (EOS_AQUA)
[ INFO  ] Setting T(p): dry, sat
[ INFO  ] Solving with 'none'
[ INFO  ]     done
[ INFO  ] Total RT evalulations: 2
[ INFO  ] Writing results
[ INFO  ] Plotting results
[ INFO  ] Deallocating memory
[ INFO  ] Model runtime: 16.60 seconds

The line following "Allocating atmosphere with composition" is a table of gases, their volume mixing ratios, and flags. In this case there is only one gas.

Potential flags for each species are:

  • EOS_[XX] - using the [XX] equation of state (e.g. ideal gas, AQUA)
  • NO_OPACITY - no opacity data available, but can contribute to the thermodynamics
  • NO_THERMO - no thermodynamic data available, so will be treated as a diatomic ideal gas
  • COND - this gas is allowed to condense

Configuration

AGNI configuration files are formatted using TOML. There are examples in res/config/. The default configuration file contains comments explaining the purpose of each parameter, although some are explained in greater detail below. Take care to format the variables in the TOML file correctly. There are no 'default values'. Not all parameters are required in all cases, but the model will return an error naming any parameters which are both necessary and absent.

The configuration files are broken up into four sections (or "tables"), each containing a number of parameters. These tables of parameters are described below.

[planet]

General properties of the planet.

ParameterDescription
tmp_surfTemperature of the surface [kelvin].
instellationStellar flux at planet's orbital distance [W m-2].
albedo_bA pseudo bond-albedo which downscales the stellar flux by 1-albedo_b.
s0_factStellar flux scale factor which accounts for planetary rotation (c.f. Cronin+13).
zenith_angleCharacteristic zenith angle for incoming stellar radiation [degrees].
surface_materialSurface material (can be "greybody" or path to data file in res/).
albedo_sSpectrally-grey surface albedo used when material=greybody. Optional otherwise.
radiusRadius of the planet's surface [m].
gravityGravitational acceleration at the surface [m s-2]. Incompatible with mass option.
massTotal mass of material below the atmosphere [kg]. Incompatible with gravity option.
skin_dThickness of the conductive boundary layer [m]. Used when solution_type=2.
skin_kConductivity of the conductive boundary layer [W m-1 K-1]. Used when solution_type=2.
tmp_magmaTemperature of the topmost layer of the planet's mantle [K]. Used when solution_type=2.
flux_intInternal flux [W m-2] to be solved-for when solution_type=3.
turb_coeffTurbulent exchange coefficient for sensible heat transport.
wind_speedEffective wind speed for sensible heat transport [m s-1].

[files]

Input/output files and other paths.

ParameterDescription
input_sfPath to the desired spectral file ending in .sf, in res/spectral_files/.
input_starPath to stellar spectrum file. Spectrum assumed to be inside spectral file if this is left blank.
output_dirPath to the output directory.
rfm_parfilePath to .par linelist file, for running line-by-line calculations with the RFM.

[composition]

Atmospheric composition and chemistry.

ParameterDescription
p_topTotal top-of-atmosphere pressure [bar].
p_dictDictionary of gas partial surface pressures [bar]. Summed to obtain p_surf.
p_surfTotal surface pressure [bar]. Incompatible with p_dict.
vmr_dictGas volume mixing ratios (=mole fractions) at the surface. Must be set alongside p_surf.
vmr_filePath to a file containing mixing ratio profiles. Replaces vmr_dict.
chemistryType of chemistry to be used (see below).
condensatesList of volatiles which are allowed to condense. Incompatible with chemistry > 0.
transparentMake the atmosphere transparent (see below). Replaces all of the above parameters in this table.

[execution]

Parameters that tell the model what to do.

ParameterDescription
clean_outputClean old files from the output folder at model startup (true/false).
verbosityLogging verbosity (0: quiet, 1: normal, 2: extra logging)
max_stepsMaximum number of steps the solver should take before giving up (typically <200).
max_runtimeMaximum wall-clock runtime [s] before giving up.
num_levelsNumber of model levels. Typically ~50, and ideally less than 150.
continuaInclude collisional/continuum absorption in radiative transfer (true/false)
rayleighInclude Rayleigh scattering in radiative transfer (true/false)
cloudInclude cloud scattering and opacity in radiative transfer (true/false)
overlap_methodMethod for treating overlapping gas opacities within a given spectral band (see below)
real_gasUse real-gas equation(s) of state where possible (true/false)
thermo_functUse temperature-dependent thermodynamic properties (true/false)
sensible_heatInclude sensible heat transport at the surface (true/false)
latent_heatInclude vertical heat transport from condensation and precipitation (true/false)
convectionInclude vertical heat transport associated with convection (true/false)
rainoutEnable compositional rainout of condensable species. If disabled, phase change does not impact composition.
initial_stateOrdered list of requests describing the initial state of the atmosphere (see below).
solution_typeSolution type (see below).
solverSolver to use (see below).
dx_maxMaximum step size [kelvin] allowed to be taken by the solver during each step.
linesearchLinesearch method to be used (0: None, 1: Golden section, 2: Backtracking)
easy_startInitially down-scale convective/condensation fluxes, if initial guess is poor/unknown. Enable if the model is struggling.
converge_atolConvergence criterion, absolute amount of energy flux lost [W m-2].
converge_rtolConvergence criterion, relative amount of energy flux lost [dimensionless].
rfm_wn_minLine-by-line RFM radiative transfer, minimum wavenumber [cm-1]
rfm_wn_maxLine-by-line RFM radiative transfer, maximum wavenumber [cm-1]

[plots]

Configure plotting routines all of these should be true or false.

ParameterDescription
at_runtimeMake some plots at runtime?
temperaturePlot temperature-pressure profile?
fluxesPlot energy flux profiles?
contributionPlot spectral contribution function?
emissionPlot outgoing emission spectrum?
albedoPlot spectral albedo? This is the ratio of upward:downward SW fluxes
mixing_ratiosPlot mixing ratio profiles?
heightPlot radius-pressure profile?
animateMake an animation of the solver obtaining its solution?

Details on specific parameters

  • composition.transparent configures the atmosphere to be transparent. This works by setting the pressure to be small, and turning off the gas opacity. With this provided, the rest of the parameters in [configuration] are redundant. With this enabled, make sure to use the appropriate solver in the [execution] table.

  • execution.solution_type tells the model which state to solve for. The allowed values (integers) are...

    • 1 : zero flux divergence at fixed tmp_surf
    • 2 : zero flux divergence such that the conductive skin (CBL) conserves energy flux with fixed tmp_magma
    • 3 : the net flux (up minus down) at each layer is equal to flux_int

    See the Model description page for an explanation of these solution types.

  • execution.solver tells the model which solver to use. Allowed solvers are...

    • [empty string] : no solving takes place, so the model just calculates fluxes using the initial state
    • newton : the Newton-Raphson algorithm is used
    • gauss : the Gauss-Newton algorithm is used
    • levenberg : the Levenberg–Marquardt algorithm is used
    • transparent : solver to be used when composition.transparent=true.
  • execution.initial_state describes the initial temperature profile applied to the atmosphere. This is a list of strings which are applied in the given order, which allows the user to describe a specific state as required. The descriptors are listed below, some of which take a single argument that needs to immediately follow the descriptor in the list order.

    • dry : integrate the dry adiabatic lapse rate from the surface upwards
    • str, arg : apply an isothermal stratosphere at arg kelvin
    • iso, arg : set the whole atmosphere to be isothermal at arg kelvin
    • csv, arg : set the temperature profile using the CSV file at the file path arg
    • sat, arg : apply Clausius-Clapeyron saturation curve for the gas arg
    • ncdf, arg : load profile from the NetCDF file located at arg
    • loglin, arg : log-linear profile between tmp_surf at the bottom and arg at the top
    • ana : use the Guillot (2010) analytical temperature solution

    For example, setting initial_state = ["dry", "sat", "H2O", "str", "180"] will set T(p) to follow the dry adiabat from the surface, the water condensation curve above that, and then to be isothermal at 180 K until the top of the model.

  • composition.chemistry describes the type of chemistry to implement within the model. This is handled externally by FastChem, so you must set the environment variable FC_DIR to point to the FastChem directory. The allowed values (integers) are...

    • 0 : Disabled
    • 1 : Equilibrium, gas phase only
    • 2 : Equilibrium, with condensation (condensates retained)
    • 3 : Equilibrium, with condensation (condensates rained out)

    More information on the chemistry is available on the Equilibrium chemistry page

  • execution.overlap_method tells SOCRATES which algorithm to use to combine gas opacities. The spectral files contain k-tables for pure gases, and combining these coefficients can be done in several ways. See Amundsen+2017 for a nice comparison of overlap methods. Allowed options are...

    • "ee" : equivalent extinction (fastest)
    • "rorr" : random overlap, with resorting and re-binning
    • "ro" : random overlap (most accurate, slowest)

Accessing AGNI from Python

It is possible to interact with AGNI from Python. This is best done with the juliacall package from PythonCall.jl.

Coupling with Python is done via juliacall within the modular PROTEUS framework, which couples AGNI self-consistently to models of planetary interior evolution and volatile outgassing. You can see this implemented in agni.py within the PROTEUS source code.

A skeleton example is given below:

# Import juliacall
from juliacall import Main as jl

# Import AGNI
jl.seval("using Pkg")
jl.Pkg.activate(AGNI_ROOT_DIR)  # <---- set AGNI_ROOT_DIR to your installation path
jl.seval("import AGNI")
jl.AGNI.setup_logging("out.log", 1)

# Setup atmosphere
atmos = jl.AGNI.atmosphere.Atmos_t()
jl.AGNI.atmosphere.setup_b(atmos, ...)   # <--- complete function arguments as per docstring in `AGNI.atmosphere.setup!()`

# Allocate atmosphere
jl.AGNI.atmosphere.allocate_b(atmos, STAR_SPECTRUM_FILE)   # <-- provide path to spectrum

# Solve T(p)
jl.AGNI.solver.solve_energy_b(atmos)

# Write results to a file
jl.AGNI.save.write_ncdf(atmos, "out.nc")

Line-by-line radiative transfer

Performed using the Reference Forward Model. You must provide a HITRAN-formatted .par file, setting the path via files.rfm_parfile. This parfile can contain absorption from multiple species, and can be obtained from hitran.org. Alternatively, get the parfiles stored on Zenodo using: ./src/get_data.sh parfiles.

Then, you must also set the variables execution.rfm_wn_min and execution.rfm_wn_max. These two parameters specify the wavenumber [cm-1] range over which to perform the LbL calculations. The wavenumber resolution is set to 1 cm-1.

Results are saved to the NetCDF file, alongside all the usual data, as rfm_wn and rfm_fl arrays.