Software manual

Contributing

If you are interested in contributing to the model, please see the contributing page

Code reference (API)

Atmosphere initialisation and variables

Functions from atmosphere.jl.

AGNI.atmosphereModule

Main atmosphere module for storing model data

This module primarily contains the Atmos_t struct which does most of the heavy lifting in AGNI. There are also functions for setting up and configuring the struct.

Also includes hydrostatic integrator and ways to estimate observable quantities.

source
AGNI.atmosphere.allocate!Method

Allocate atmosphere arrays, prepare spectral files, and final steps.

Will not modify spectral file if stellar_spectrum is an empty string. Will treat star as blackbody with photospheric effective temperature of stellar_Teff if the parameter stellar_spectrum has value of "blackbody".

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • stellar_spectrum::String path to stellar spectrum csv file
  • stellar_Teff::Float64 star effective temperature if blackbody
  • check_safe_gas::Bool require that there be at least one 'safe' gas in the mix
source
AGNI.atmosphere.calc_layer_props!Method

Calculate properties within each layer of the atmosphere (e.g. density, mmw).

Function will return false if hydrostatic calculcation fails. This is usually when the atmosphere becomes unbound.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

Returns: - ok::Bool function result is ok

source
AGNI.atmosphere.calc_observed_rho!Method

Calculate observed radius and bulk density.

This is done at the layer probed in transmission, which is set to a fixed pressure.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

Returns: - transspec_rho::Float64 the bulk density observed in transmission

source
AGNI.atmosphere.calc_profile_cpkc!Method

Calculate specific heat capacity and thermal conductivity for all layers.

Specific heat per unit mass: J K-1 kg-1. Thermal conductivity: W m-1 K-1.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

source
AGNI.atmosphere.calc_profile_density!Method

Calculate the mass-density for all layers.

Requires temperature, pressure, mmw to be already have been set.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

source
AGNI.atmosphere.calc_profile_radius!Method

Calculate radii, gravities, and masses for all layers.

Performs hydrostatic integration from the ground upwards. Requires density, temperature, pressure to have already been set.

Does not account for surface ocean height.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.

Returns:

  • bound::Bool atmosphere is strongly bound by gravity
source
AGNI.atmosphere.calc_single_cpkc!Method

Calculate specific heat capacity and thermal conductivity of a single layer.

Specific heat per unit mass: J K-1 kg-1. Thermal conductivity: W m-1 K-1.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used. - idx::Int index of the layer

source
AGNI.atmosphere.calc_single_density!Method

Calculate the mass-density of a single layer.

Requires temperature, pressure, mmw to be already have been set.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • idx::Int index of the layer
source
AGNI.atmosphere.estimate_Ra!Method

Estimate a diagnostic Rayleigh number in each layer.

Assuming that the Rayleigh number scales like Ra ~ (wλ/κ)^(1/β) Where κ is the thermal diffusivity and β is the convective beta parameter.

This quantity must be taken lightly.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.atmosphere.estimate_convective_zoneMethod

Get pressure at top and bottom of convective zone

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

Returns: - p_top::Float64 pressure [Pa] at top of convective zone - p_bot::Float64 pressure [Pa] at bottom of convective zone

source
AGNI.atmosphere.estimate_photosphere!Method

Estimate photosphere.

Estimates the location of the photosphere by finding the median of the contribution function in each band (0.2 um to 150 um), and then finding the pressure level at which these median values are maximised.

Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.

Returns: - p_ref::Float64 pressure level of photosphere [Pa]

source
AGNI.atmosphere.generate_pgrid!Method

Generate pressure grid.

Almost equally log-spaced between pboa and pboa. The near-boundary layers are smaller than they would be on an equally log-spaced grid, to avoid numerics.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.atmosphere.get_interleaved_ptrMethod

Get interleaved cell-centre and cell-edge PTR grid.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.

Returns:

  • arr_P::Array pressure array [Pa]
  • arr_T::Array temperature array [K]
  • arr_R::Array radius array [m]
source
AGNI.atmosphere.integ_hydrogravMethod

Integrate hydrostatic and gravity equations across a pressure interval.

Uses the classic fourth-order Runge-Kutta method.

Arguments:

  • r0::Float64 radius at start of interval [m]
  • g0::Float64 gravity at start of interval [m s-2]
  • m0::Float64 mass enc at start of interval [kg]
  • p0::Float64 pressure at start of interval [Pa]
  • p1::Float64 pressure at end of interval [Pa]
  • rho::Float64 density throughout interval, constant [kg m-3]
  • n::Int number of steps for integration (n >= 2)

Returns:

  • rj::Float64 radius at end of interval [m]
  • gj::Float64 gravity at end of interval [kg]
  • mj::Float64 mass enc at end of interval [kg]
source
AGNI.atmosphere.make_transparent!Method

Set atmosphere properties such that it is effectively transparent.

This will modify the surface pressure and disable gas opacity in SOCRATES. These changes cannot be reversed directly. To undo them, it is best to create and allocate a new atmosphere struct.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.atmosphere.set_tmpl_from_tmp!Method

Set cell-edge temperatures from cell-centre values.

Uses interpolation within the bulk of the column and extrapolation for the topmost edge.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.atmosphere.setup!Method

Set parameters of the atmosphere.

This is used to set up the struct immediately after creation. It must be done before allocate!() is called, and before any RT calculcations are performed.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • ROOT_DIR::String AGNI root directory.
  • OUT_DIR::String Output directory.
  • spfile::String path to spectral file ('grey' => use grey gas)
  • instellation::Float64 bolometric solar flux at the top of the atmosphere [W m-2]
  • s0_fact::Float64 scale factor to account for planetary rotation (i.e. S0^*/S0 in Cronin+14)
  • albedo_b::Float64 bond albedo scale factor applied to instellation in order to imitate shortwave reflection
  • zenith_degrees::Float64 angle of radiation from the star, relative to the zenith [degrees].
  • tmp_surf::Float64 effective surface temperature to provide upward longwave flux at the bottom of the atmosphere [K].
  • gravity::Float64 gravitational acceleration at the surface [m s-2].
  • radius::Float64 planet radius at the surface [m].
  • nlev_centre::Int number of model levels.
  • p_surf::Float64 total surface pressure [bar].
  • p_top::Float64 total top of atmosphere pressure [bar].
  • mf_dict::Dict dictionary of VMRs in the format (key,value)=(gas,mf).
  • mf_path::String path to file containing VMRs at each level.

Optional arguments:

  • IO_DIR::String directory used for fast file operations.
  • condensates list of condensates (gas names).
  • metallicities::Dict dictionary of elemental metallicities (mass ratio rel to hydrogen)
  • surface_material::String surface material (default is "greybody", but can point to file instead).
  • albedo_s::Float64 grey surface albedo used when surface_material="greybody".
  • tmp_floor::Float64 temperature floor [K].
  • surf_roughness::Float64 surface roughness length scale [m]
  • surf_windspeed::Float64 surface wind speed [m s-1].
  • Kzz_floor::Float64 min eddy diffusion coefficient, cgs units [cm2 s-1]
  • mlt_asymptotic::Bool mixing length scales asymptotically, but ~0 near ground
  • mlt_criterion::Char MLT stability criterion. Options: (s)chwarzschild, (l)edoux.
  • tmp_magma::Float64 mantle temperature [K] for sol_type==2.
  • skin_d::Float64 skin thickness [m].
  • skin_k::Float64 skin thermal conductivity [W m-1 K-1].
  • overlap_method::String gaseous overlap scheme (ro: rand overlap, ee: equiv extinct, rorr: ro+resort+rebin).
  • target_olr::Float64 target OLR [W m-2] for sol_type==4.
  • flux_int::Float64 planet's internal flux for sol_type==3.
  • all_channels::Bool use all channels available for RT?
  • flag_rayleigh::Bool include rayleigh scattering?
  • flag_gcontinuum::Bool include generalised continuum absorption?
  • flag_continuum::Bool include continuum absorption?
  • flag_aerosol::Bool include aersols?
  • flag_cloud::Bool include clouds?
  • phs_timescale::Float64 phase change timescale [s]
  • evap_efficiency::Float64 re-evaporatione efficiency compared to saturating amount
  • real_gas::Bool use real gas EOS where possible
  • thermo_functions::Bool use temperature-dependent thermodynamic properties
  • use_all_gases::Bool store information on all supported gases, incl those not provided in cfg
  • check_integrity::Bool confirm integrity of thermo files using their checksum
  • κ_grey_lw::Float64 gas opacity when using grey-gas RT scheme, longwave
  • κ_grey_sw::Float64 gas opacity when using grey-gas RT scheme, shortwave
  • fastchem_work::String working directory for fastchem
  • fastchem_floor::Float64 temperature floor on profile provided to fastchem
  • fastchem_maxiter_chem::Float64 maximum chemical iterations allowed by fastchem
  • fastchem_maxiter_solv:Float64 maximum solver iterations allowed by fastchem
  • fastchem_xtol_chem::Float64 solution tolerance required of fastchem (chemical)
  • fastchem_xtol_elem::Float64 solution tolerance required of fastchem (elemental)
  • rfm_parfile::String path to HITRAN-formatted .par file provided to RFM

Returns: Nothing

source

Energy flux calculations

Functions from energy.jl.

AGNI.energy._radtrans_greygas!Method

Solve RT using double grey-gas formulation

Simple two-stream double grey RT solver which integrates fluxes from the TOA and BOA.

Uses two opacity values to represent the LW and SW components of the flux field.

Loosely following this tutorial, which is based on Pierrehumbert (2010). https://brian-rose.github.io/ClimateLaboratoryBook/courseware/radiative-transfer/

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.energy._radtrans_socrates!Method

Solve radiative transfer using SOCRATES

Imports SOCRATES wrapper from the atmosphere module, rather than loading it twice.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • lw::Bool True: longwave calculation. False: shortwave calculation.

Optional arguments:

  • calc_cf::Bool also calculate contribution function?
  • gauss_ir::Bool using gaussian angular integration in IR, otherwise uses two-stream approximation
  • rescale_pf::Bool perform rescaling on phase function
source
AGNI.energy.calc_fluxes!Method

Calculate energy flux at each level.

Calculates flux components (radtrans, convection, etc.) and sums them to get total flux. Also updates thermodynamic properties (heat capacity, density, etc.) at each layer.

Assumes that chemistry functions have already been called, if wanted. Does not call fastchem here.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.

Optional arguments:

  • radiative::Bool include radiation fluxes
  • latent_heat::Bool include condensation flux
  • convective::Bool include MLT convection flux
  • sens_heat::Bool include TKE sensible heat flux
  • conductive::Bool include conductive heat flux
  • advective::Bool include advective heat flux
  • convect_sf::Float64 scale factor applied to convection fluxes
  • latent_sf::Float64 scale factor applied to phase change fluxes
  • calc_cf::Bool calculate LW contribution function?

Returns:

  • ok::Bool calculation performed ok?
source
AGNI.energy.calc_hrates!Method

Calculate heating rates at cell-centres from the total flux.

Requires the total flux to have already been set (atmos.flux_tot). Heating rates are calculated in units of kelvin per day.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.energy.conduct!Method

Calculate conductive heat fluxes using Fourier's law

Updates array of atmos.flux_cdct at each layer of the atmosphere.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used
source
AGNI.energy.convection!Method

Calculate dry convective fluxes using mixing length theory.

Convective energy transport fluxes are calculated at every level edge, just like the radiative fluxes. This is not compatible with moist convection. By using MLT to parameterise convection, we can also calculate Kzz directly.

Uses the mixing length formulation outlined by Joyce & Tayar (2023), which was also implemented in Lee et al. (2024), and also partially outlined in the review by Robinson & Marley (2014). https://arxiv.org/abs/2303.09596 https://doi.org/10.1093/mnras/stae537 https://ui.adsabs.harvard.edu/abs/1962JGR....67.3095B/abstract

The adiabatic lapse rate is formulated as: ∇_ad = dln(T)/dln(P) = (P/T)*(dT/dP) = (P/T)*(1/[ρ c_p]) for an ideal gas, this becomes: ∇_ad = R / (μ c_p)

The mixing length is set to asymptotically approach H (for z>>H) or z (for z<H) as per Blackadar (1962). Alternatively, it can be set equal to H. https://doi.org/10.1029/JZ067i008p03095

The scale height is formulated as: Hp = P / (ρ g) Where ρ is obtained from the equation of state.

To account for convective stability due to compositional gradients, we can use the Ledoux criterion rather than the Schwarzschild criterion. This is described nicely in Gabriel et al. (2014), as well as Salaris & Cassisi (2017). http://dx.doi.org/10.1051/0004-6361/201423442 https://doi.org/10.1098/rsos.170192

In the ideal gas regime, the Ledoux criterion can be simply written as: ∇_ld = ∇_ad + dln(μ)/dln(P) Using Equation (10) of Gabriel+14. Taking β=Pg/P=1 means the gas pressure equals the total pressure, neglecting pressure contributions from ions and electrons.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.energy.eval_exchange_coeffMethod

Calculate turbulent kinetic energy (TKE) exchange coefficient.

Based on Monin–Obukhov similarity theory, from roughness length scale. See eq 9 in Nicholson & Benn (2009). Added small epsilon-factor to avoid function blowing-up around regime where height ≈ roughness.

Arguments:

  • height::Float64 Height above surface [m]
  • roughness::Float64 Roughness length scale [m]

Returns:

  • C_d::Float64 TKE exchange coefficient [dimensionless]
source
AGNI.energy.fill_Kzz!Method

Fill Kzz values for the entire profile.

This function is called after the convection scheme has been run.

The Kzz value in the convective region (and below) are set equal to the maximum value in the convective region, as calculated by MLT. The value increases with power-law scaling with pressure in the stratosphere.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.energy.latent!Method

Analytical diffusion scheme for condensation and evaporation energy.

Updates fluxes. Requires chemistry.rainout_and_evaporate to be called first.

Integrates from bottom of model upwards. Based on the amount of phase change at each level, a phase change flux is calculated by assuming a fixed condensation timescale.

If evaporation is enabled, then integrates from top downwards to determine flux from re-evaporation of droplets. Any droplets which reach the ground go towards forming an ocean.

Should ideally perform a microphysical treatment; e.g. by following this paper: https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/2020JE006653

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.energy.make_finite!Method

Set non-finite values in an array equal to a given fill value.

Arguments:

  • arr array potentially containing non-finite values
  • fill replacement value to fill with
source
AGNI.energy.radtrans!Method

Calculate radiative fluxes using the desired scheme.

Uses the configuration inside the atmos struct. Can either do LW or SW calculation, set by lw function argument.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • lw::Bool longwave calculation? Else: shortwave
  • calc_cf::Bool=false also calculate contribution function?
source
AGNI.energy.sensible!Method

Calculate sensible heat flux from turbulent kinetic energy (TKE)

Updates the values of atmos.C_d and atmos.flux_sens.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used
source

Chemistry and phase-change calculations

Functions from chemistry.jl.

AGNI.chemistryModule

This module handles chemistry, condensation, and evaporation.

Note the important distinctions between the variables which store atmospheric composition.

  • gas_ovmr stores VMRs inputted by the user, which are usually constant in height.
  • gas_vmr stores the runtime gas volume mixing ratios, after all calculations are performed.
source
AGNI.chemistry._chem_gas!Method

Calculate gas-phase composition at dry thermochemical equilibrium.

Uses FastChem to calculate the gas composition at each level of the atmosphere. Volatiles are converted to bulk elemental abundances, which are then provided to FastChem alongside the temperature/pressure profile. FastChem is currently called as an executable, which is not optimal.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • write_cfg::Bool write config and elements

Returns:

  • state::Int fastchem state (0: success, 1: criticalfail, 2: elemfail, 3: convfail, 4: bothfail)
source
AGNI.chemistry._sat_aloft!Method

Handle sub/super-saturation aloft; required for latent heat flux calcaulation

Adjust gas VMRs according to saturation and cold-trap requirements.

Volatiles which are allowed to condense are rained-out at condensing levels until the gas is exactly saturated, not supersaturated. If evaporation is enabled here, it will lead to enhanced mixing ratios at deeper levels as rain is converted back into gas from a liquid state.

Any rain that reaches the surface without being evaporated leads to ocean formation. Disabling evaporation will lead to unclosed energy budget when calculation of latent heat fluxes is performed.

This function can be called after the fastchem calculation.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
source
AGNI.chemistry._sat_surf!Method

Handle sub/super-saturation at the surface, forming oceans.

NOTE: this function does not reset to atmos to its original state before operating.

If a condensable is supersaturated at the surface, its partial surface pressure is reduced to exactly saturation. The condensed mass is added to the ocean reservoir. If a condensable is subsaturated at the surface, its partial pressure is increased to exactly saturation, subject to the amount of ocean available. Reduces or increases the total surface pressure accordingly.

Accounts for mmw ratio when converting from partial pressures to masses: mi = (pi/g) * (mui / mutot) where mi has units [kg/m^2] and mutot is the total mixture MMW.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.

Returns:

  • any_changed::Bool did any component condense or evaporate?
source
AGNI.chemistry.calc_composition!Method

Run condensation and chemistry schemes as required.

This function is designed as a wrapper for appropriately handling these three schemes together in the correct order, so that variables are appropriately updated. Steps:

  1. call _sat_surf! to handle saturation at the surface, and adjust the pressure grid
  2. call _chem_gas! to handle gas-phase chemistry in the column
  3. call _sat_aloft! to handle saturation aloft, above the surface.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • do_surf::Bool do saturation cond/evap at surface
  • do_chem::Bool do thermochemistry in the column
  • do_aloft::Bool do saturation cond/evap aloft

Returns:

  • state::Int fastchem state (0: success, 1: criticalfail, 2: elemfail, 3: convfail, 4: bothfail)
source
AGNI.chemistry.normalise_vmrs!Method

Normalise gas VMRs, keeping condensates unchanged

Only acts on a single model level.

Parameters:

  • atmos::atmosphere.Atmos_t atmosphere structure
  • i::Int level index to normalise
source

Numerical solvers

Functions from solver.jl.

AGNI.solver.gs_searchMethod

Golden section search algorithm

Minimises a function f between the bounds a and b. The function f must return a positive scalar.

Arguments:

  • f Function to be minimised
  • a Initial bracket, lower value
  • b Initial bracket, upper valuie
  • dxtol Convergence: exit when bracket is smaller than this size
  • atol Convergence: absolute tolerance on minimum
  • max_steps Maximum number of iterations
  • warnings Print warning if search does not converge before max_steps` are taken.

Returns:

  • sol Best solution found by search.
  • succ Did search converge?
source
AGNI.solver.solve_energy!Method

Obtain radiative-convective equilibrium using a matrix method.

Solves the non-linear system of equations defined by the flux field divergence, minimising flux loss across a cell by iterating the temperature profile.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.

Optional physics arguments:

  • sol_type::Int solution type, 1: tmpsurf | 2: skin | 3: fluxint | 4: tgt_olr
  • chem::Bool include eqm thermochemistry when solving for RCE?
  • convect::Bool include convection
  • sens_heat::Bool include sensible heating at the surface
  • conduct::Bool include conductive heat transport within the atmosphere
  • latent::Bool include latent heat exchange (condensation/evaporation)
  • advect::Bool include advective heat exchange (dynamics)
  • rainout::Bool allow rainout (phase change impacts mixing ratios, not just energy fluxes)
  • oceans::Bool check surface saturation (ocean formation)

Optional solver arguments:

  • dx_min::Float64 minimum step size [K]
  • dx_max::Float64 maximum step size [K]
  • tmp_pad::Float64 padding around hard limits on temperature floor & ceiling values
  • max_steps::Int maximum number of solver steps
  • max_runtime::Float64 maximum runtime in wall-clock seconds
  • fdc::Bool finite difference: central difference? otherwise use forward difference
  • fdo::Int finite difference: scheme order (2nd or 4th)
  • method::Int numerical method (1: Newton-Raphson, 2: Gauss-Newton, 3: Levenberg-Marquardt)
  • easy_start::Bool improve convergence reliability; introduce convection and latent heat gradually
  • grey_start::Bool improve convergence reliability; obtain double-grey solution first
  • ls_method::Int linesearch algorithm (0: None, 1: golden, 2: backtracking)
  • detect_plateau::Bool assist solver when it is stuck in a region of small dF/dT
  • perturb_all::Bool always recalculate entire Jacobian matrix? Otherwise updates columns only as required
  • modplot::Int iteration frequency at which to make plots
  • save_frames::Bool save plotting frames
  • modprint::Int iteration frequency at which to print info
  • plot_jacobian::Bool plot jacobian too?
  • radiative_Kzz::Bool estimate Kzz in radiative zones? Otherwise left at Kzz=0 in these regions.
  • conv_atol::Float64 convergence: absolute tolerance on per-level flux deviation [W m-2]
  • conv_rtol::Float64 convergence: relative tolerance on per-level flux deviation [dimensionless]

Returns: Nothing

source
AGNI.solver.solve_prescribed!Method

Solve for global (not local) balance with a prescribed atmosphere structure.

Comparable to solve_transparent, but with an opaque prescribed atmospheric structure.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • sol_type::Int solution types, same as solve_energy
  • atm_type::Int atmosphere prescription (1: isothermal, 2: adiabat, 3: adiabat+stratosphere)
  • conv_atol::Float64 convergence: absolute tolerance on global flux [W m-2]
  • conv_rtol::Float64 convergence: relative tolerance on global flux [dimensionless]
  • max_steps::Int maximum number of solver steps
  • tmp_upper::Float64 upper-bound on Tsurf for golden-section search [K]

Returns:

  • Bool indicating success
source
AGNI.solver.solve_transparent!Method

Solve for energy balance with a transparent atmosphere.

This will use an isothermal temperature profile, and only modify T_surf.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • sol_type::Int solution types, same as solve_energy
  • conv_atol::Float64 convergence: absolute tolerance on global flux [W m-2]
  • conv_rtol::Float64 convergence: relative tolerance on global flux [dimensionless]
  • max_steps::Int maximum number of solver steps
  • tmp_upper::Float64 upper-bound on Tsurf for golden-section search [K]

Returns:

  • Bool indicating success
source

Plotting functions and utilities

Functions from plotting.jl.

AGNI.plotting.animateMethod

Convert still-frame images into an animation

Uses FFMPEG provided by Julia library.

Arguments:

  • output_dir::String folder in which to save the animation
  • frames_dir::String folder containing the frames

Optional arguments:

  • output_fmt::String output file format: mp4, mov, ...
  • frames_fmt::String input frame format: png, jpg, ...
  • duration::Float64 animation duration [seconds]
source
AGNI.plotting.plot_contfunc2Method

Plot normalised contribution function (per band)

The data displayed in this plot are fine, but the x-axis ticks are labelled incorrectly by the plotting library. I don't know why this is.

source

Physical properties and constants

Functions from phys.jl.

AGNI.phys._rho_idealMethod

Evaluate the density of a single gas using the ideal gas EOS.

Arguments:

  • tmp::Float64 temperature [K]
  • prs::Float64 pressure [Pa]
  • mmw::Float64 mean molecular weight [kg mol-1]

Returns:

  • rho::Float64 mass density [kg m-3]
source
AGNI.phys.calc_TeqMethod

Calculate planetary equilibrium temperature.

https://en.wikipedia.org/wiki/Planetaryequilibriumtemperature?useskin=vector

Arguments:

  • S::Float64 Bolometric instellation [W m-2]
  • α::Float64 Bond albedo

Returns:

  • Teq::Float64 Planetary equilibrium temperature [K]
source
AGNI.phys.calc_TskinMethod

Calculate planetary skin temperature.

https://en.wikipedia.org/wiki/Skintemperature(atmosphere)?useskin=vector

Arguments:

  • S::Float64 Bolometric instellation [W m-2]
  • α::Float64 Bond albedo

Returns:

  • Tskin::Float64 Planetary skin temperature [K]
source
AGNI.phys.calc_rho_gasMethod

Calculate the density of a gas using the most appropriate equation of state.

Arguments:

  • tmp::Float64 temperature [K]
  • prs::Float64 pressure [Pa]
  • gas::Gas_t the gas struct to be used

Returns:

  • rho::Float64 mass density [kg m-3]
source
AGNI.phys.calc_rho_mixMethod

Calculate the density of a mixture of gases using Amagat's law.

Arguments:

  • gas::Array{Gas_t,1} array of gases
  • vmr::Array{Float64,1} array of volume mixing ratios
  • tmp::Float64 temperature [K]
  • prs::Float64 pressure [Pa]

Returns:

  • rho::Float64 mass density [kg m-3]
source
AGNI.phys.calc_therm_diffusMethod

Calculate thermal diffusivity.

https://en.wikipedia.org/wiki/Thermal_diffusivity?useskin=vector

Arguments:

  • k::Float64 Thermal conductivity [W m-1 K-1]
  • ρ::Float64 Density [kg m-3]
  • cp::Float64 Specific heat capacity [J K-1 kg-1]

Returns:

  • α::Float64 Thermal diffusivity [m2 s-1]
source
AGNI.phys.evaluate_planckMethod

Evaluate the Planck function at a given wavelength and temperature.

Integrated over a hemisphere.

Arguments:

  • wave::Float64 Wavelength [nm]
  • tmp::Float64 Temperature [K]

Returns:

  • flx::Float64 Spectral flux density [W m-2 nm-1]
source
AGNI.phys.get_CpMethod

Get gas heat capacity for a given temperature.

Evaluates at 0 Celcius if gas.tmp_dep=false.

Arguments:

  • gas::Gas_t the gas struct to be used
  • t::Float64 temperature [K]

Returns:

  • cp::Float64 heat capacity of gas [J K-1 kg-1]
source
AGNI.phys.get_KcMethod

Get gas thermal conductivity at a given temperature.

This assumes that the gas is within the ideal regime.

Arguments:

  • gas::Gas_t the gas struct to be used
  • t::Float64 temperature [K]

Returns:

  • kc::Float64 thermal conductivity [W m-1 K-1]
source
AGNI.phys.get_LvMethod

Get gas enthalpy (latent heat) of phase change.

If the temperature is above the critical point, then a zero value is returned. Evaluates at 0 Celcius if gas.tmp_dep=false.

Arguments:

  • gas::Gas_t the gas struct to be used
  • t::Float64 temperature [K]

Returns:

  • h::Float64 enthalpy of phase change [J kg-1]
source
AGNI.phys.get_PsatMethod

Get gas saturation pressure for a given temperature.

If the temperature is above the critical point, then a large value is returned.

Arguments:

  • gas::Gas_t the gas struct to be used
  • t::Float64 temperature [K]

Returns:

  • p::Float64 saturation pressure [Pa]
source
AGNI.phys.get_TdewMethod

Get gas dew point temperature for a given partial pressure.

If the pressure is below the critical point pressure, then T_crit is returned. This function is horrendous, and should be avoided at all costs.

Arguments:

  • gas::Gas_t the gas struct to be used
  • p::Float64 pressure [Pa]

Returns:

  • t::Float64 dew point temperature [K]
source
AGNI.phys.grav_accelMethod

Calculate gravitational acceleration.

Arguments:

  • mass::Float64 Enclosed mass [kg]
  • radius::Float64 Enclosed radius [m]

Returns:

  • grav::Float64 Gravitational acceleration [m s-2]
source
AGNI.phys.is_vapourMethod

Check if pressure-temperature coordinate is within the vapour regime.

Returns true if p > psat and t < tcrit.

Arguments:

  • gas::Gas_t the gas struct to be used
  • t::Float64 temperature [K]
  • p::Float64 temperature [K]

Returns:

  • vapour::Bool is within vapour regime?
source
AGNI.phys.liquid_rhoMethod

Evaluate the density of a liquid phase.

Returns BIGFLOAT density for unsupported phases, to avoid divide-by-zero error

Arguments:

  • name::String Name of liquid

Returns:

  • rho::Float64 Density of liquid phase [kg m-3]
source

File I/O modules

Functions from save.jl and load.jl.

AGNI.save.write_fluxesMethod

Write cell-edge energy fluxes to a CSV file

Arguments

  • atmos::Atmos_t Atmosphere object
  • fname::String Filename to write to
source
AGNI.save.write_ncdfMethod

Write verbose atmosphere data to a NetCDF file

Arguments

  • atmos::Atmos_t Atmosphere object
  • fname::String Filename to write to
source
AGNI.save.write_profileMethod

Write {Pressure, Temperature, Radius} profile to a CSV file

Arguments

  • atmos::Atmos_t Atmosphere object
  • fname::String Filename to write to
source
AGNI.load.load_ncdf!Method

Load atmosphere data from a NetCDF file.

This must be called after setup! and allocate! have been called on this atmos struct. Does not overwrite energy fluxes within the atmospherem, or other wavelength-dependent properties. Only composition, temperatures, layer properties, and boundary conditions are updated by this function.

Arguments:

  • atmos::Atmos_t the atmosphere struct instance to be used.
  • fname::String path to the NetCDF file

Returns:

  • ok::Bool loaded ok?
source