API reference
Atmosphere initialisation and variables
Functions from atmosphere.jl.
AGNI.atmosphere — Module
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.
AGNI.atmosphere._check_range — Method
Check that a named parameter value lies within a valid range, logging an error if not.
AGNI.atmosphere._iphot_from_cff — Method
Calculate index of photosphere from contribution function.
This is retained as a legacy method.
Estimates the location of the photosphere by finding the median of the contribution function in each band (0.2 μm to 150 μm), and then finding the pressure level at which these median values are maximised.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
iphot::Int64index of photosphere
AGNI.atmosphere._iphot_from_prs! — Method
Calculate index of photosphere simply from a reference pressure.
This is a simple method that does not require optical depth profiles.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.p_ref::Float64reference pressure [Pa]
Returns:
Int64index of photosphere
AGNI.atmosphere._iphot_from_tau — Method
Calculate index of photosphere at a reference wavelength.
Assuming that atmos.tau_p has already been determined using calc_tau_isolines!, this method finds the index of the photosphere at the reference wavelength.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.ref_wl::Float64reference wavelength [m]
Returns:
Int64index of photosphere
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_tthe atmosphere struct instance to be used.stellar_spectrum::Stringpath to stellar spectrum csv filestellar_Teff::Float64star effective temperature if blackbodycheck_safe_gas::Boolrequire that there be at least one 'safe' gas in the mix
AGNI.atmosphere.calc_cond_mmr — Method
Calculate condensate mass mixing ratio at a specific layer.
Arguments:
atmos::atmosphere.Atmos_tatmosphere struct instance to be used.c::Stringcondensate species to calculate for (e.g. "H2O")i::Int64layer index
Returns:
cond_mmr::Float64condensatecmass mixing ratio at layeri
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
AGNI.atmosphere.calc_observed_rho! — Method
Calculate planet's bulk density.
This function is retained for legacy API compatibility. The main calculation of the bulk density is done by estimate_photosphere!.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
transspec_rho::Float64the bulk density observed in transmission
AGNI.atmosphere.calc_profile_Hp! — Method
Calculate the scale height for all layers.
Requires temperature, pressure, mmw to be already have been set.
Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.
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.
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.
AGNI.atmosphere.calc_profile_mmw! — Method
Calculate mean molecular weight for all layers.
MMW stored as kg/mol.
Arguments: - atmos::Atmos_t the atmosphere struct instance to be used.
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_tthe atmosphere struct instance to be used.
Returns:
bound::Boolatmosphere is strongly bound by gravity
AGNI.atmosphere.calc_single_Hp! — Method
Calculate the scale height of a single layer.
Requires temperature, pressure, mmw to be already have been set.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.idx::Int64index of the layer
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::Int64 index of the layer
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_tthe atmosphere struct instance to be used.idx::Int64index of the layer
AGNI.atmosphere.calc_tau_isolines! — Method
Find pressure and radius where optical depth τ=τ_ref, for each spectral band.
Uses the optical depth profiles stored in atmos.tau_band and determines the layer where τ is closest to atmos.transspec_ref_tau. Values are stored in atmos.tau_p [Pa] and atmos.tau_r [m].
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
tau_p::Array{Float64,1}pressure at which τ=τ_ref for each band [Pa]tau_r::Array{Float64,1}radius at which τ=τ_ref for each band [m]
AGNI.atmosphere.calc_toa_heating — Method
Get TOA heating from atmosphere parameters.
Return the effective irradiation flux at the top of the atmosphere (TOA).
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be accessed
Returns:
Float64effective TOA heating [W m-2]
AGNI.atmosphere.calc_zenith_angle — Method
Get the solar zenith angle for a given longitude and latitude
Assuming tidally locked planet with coordinate system centred on subsolar point. Does not account for super-illumination in the twilight regions.
Arguments:
lon::Float64the longitude of location (degrees)lat::Float64the latitude of location (degrees)
Returns:
zen::Float64the zenith angle for the location (degrees)
AGNI.atmosphere.deallocate! — Method
Deallocate SOCRATES arrays and mark the atmosphere as unallocated.
AGNI.atmosphere.estimate_photosphere! — Method
Estimate the index of the photosphere.
This is the layer that is probed in transmission, and is used to calculate the observed radius and bulk density. This is a wrapper function that updates the transspec_* properties of the atmosphere struct.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be updated.setby::Stringmethod to use for estimating photosphere ("tau" or "prs")
Returns:
idx::Int64index of photosphere
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_tthe atmosphere struct instance to be used.
AGNI.atmosphere.get_interleaved_ptr — Method
Get interleaved cell-centre and cell-edge PTR grid.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
arr_P::Arraypressure array [Pa]arr_T::Arraytemperature array [K]arr_R::Arrayradius array [m]
AGNI.atmosphere.integ_hydrograv — Method
Integrate hydrostatic and gravity equations across a pressure interval.
Uses the classic fourth-order Runge-Kutta method.
Internally, this function integrates from p0 to p1, which means that the pressure is decreasing across the interval. The gravity is updated at each integration step, and is offset by the centrifugal acceleration.
Arguments:
r0::Float64radius at start of interval [m]g0::Float64gravity at start of interval [m s-2]a0::Float64net accel at start of interval (grav - cent) [m s-2]m0::Float64mass enc at start of interval [kg]p0::Float64pressure at start of interval [Pa]p1::Float64pressure at end of interval [Pa]rho::Float64density throughout interval, constant [kg m-3]n::Int64number of steps for integration (n >= 2)
Returns:
rj::Float64radius at end of interval [m]gj::Float64gravity at end of interval [kg]mj::Float64mass enc at end of interval [kg]
AGNI.atmosphere.list_available_aerosols — Method
List available aerosol species.
Arguments:
atmos::atmosphere.Atmos_tthe atmosphere struct instance to check
Returns:
aerosol_names::Array{String, 1}list of available aerosol species
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_tthe atmosphere struct instance to be used.
AGNI.atmosphere.set_aerosol! — Function
Set aerosol MMR profiles for a given species.
Aerosol in the singular form.
Arguments:
atmos::atmosphere.Atmos_tthe atmosphere struct instance to be usedspecies::Stringthe name of the aerosol species to setmmrthe mixing ratio to assign (1D array, or Float, or species String)pmin::Float64the minimum pressure to set aerosol at [Pa]pmax::Float64the maximum pressure to set aerosol at[Pa]mmr_sf::Float64scaling factor to apply to aerosol MMR
Returns:
any_aerosol::Boolwhether aerosol is present after setting
AGNI.atmosphere.set_aerosols! — Method
Loop over all available aerosols and set profiles based on condensate yields.]
Aerosols in the plural form.
Arguments:
atmos::atmosphere.Atmos_tthe atmosphere struct instance to be usedmmr_sf::Float64scaling factor to apply to all aerosol MMR profiles
Returns:
any_aerosol::Boolwhether any aerosols are present after setting
AGNI.atmosphere.set_cloud! — Method
Set water cloud profile based on saturation.
Arguments:
atmos::atmosphere.Atmos_tthe atmosphere struct instance to be used.from_yield::Boolset cloud properties based on condensation yieldmmr_sf::Float64scaling factor to apply to cloud MMR
Returns:
any_cloud::Boolwhether any clouds are present
AGNI.atmosphere.set_deep_heating! — Method
Set deep atmospheric heating parameters.
Configures the deep heating source which deposits energy as a Gaussian distribution in log-pressure space.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.Pmid::Float64deposition pressure [Pa].Pwid::Float64width of Gaussian in log-pressure space [logPa].flux_rel::Float64heating flux relative to instellation.flux_abs::Float64heating flux absolute [W m-2].norm_method::Stringmethod for normalising the Gaussian (pressure, mass).domain::Stringhow to handle deposition pressures outside the domain (clamp, boundary_flux).power_mode::Stringoff, or relative/absolute flux (off, rel, abs).verbose::Boolwhether to show info messages about the configuration.
Returns:
Boolindicating success or failure of the operation.
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_tthe atmosphere struct instance to be used.
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_tthe atmosphere struct instance to be used.ROOT_DIR::StringAGNI root directory.OUT_DIR::StringOutput directory.spfile::Stringpath to spectral file ('grey' => use grey gas)instellation::Float64bolometric solar flux at the top of the atmosphere [W m-2]s0_fact::Float64scale factor to account for planetary rotation (i.e. S0^*/S0 in Cronin+14)albedo_b::Float64bond albedo scale factor applied to instellation in order to imitate shortwave reflectionzenith_degrees::Float64angle of radiation from the star, relative to the zenith [degrees].tmp_surf::Float64effective surface temperature to provide upward longwave flux at the bottom of the atmosphere [K].gravity::Float64gravitational acceleration at the surface [m s-2].radius::Float64planet radius at the surface [m].nlev_centre::Int64number of model levels.p_surf::Float64total surface pressure [bar].p_top::Float64total top of atmosphere pressure [bar].mf_dict::Dictdictionary of VMRs in the format (key,value)=(gas,mf).mf_path::Stringpath to file containing VMRs at each level.
Optional arguments:
name::Stringname of the atmosphere (generates name if not provided).IO_DIR::Stringdirectory used for fast file operations.condensateslist of condensates (gas names).metallicities::Dictdictionary of elemental metallicities (mass ratio rel to hydrogen)surface_material::Stringsurface material (default is "greybody", but can point to file instead).albedo_s::Float64grey surface albedo used whensurface_material="greybody".tmp_floor::Float64temperature floor [K].surf_roughness::Float64surface roughness length scale [m]surf_windspeed::Float64surface wind speed [m s-1].Kzz_kbreak::Float64reference eddy diffusion coefficient, SI units [m2 s-1]Kzz_pbreak::Float64reference pressure for Kzz break point [Pa]Kzz_floor::Float64minimum Kzz value used for filling [m2 s-1]Kzz_type::Int64parametrisation of Kzz. Options: 1 (constant), 2 (MLT wl), 3 (MLT Fc)mlt_asymptotic::Boolmixing length scales asymptotically, but ~0 near groundmlt_criterion::CharMLT stability criterion. Options: (s)chwarzschild, (l)edoux.tmp_magma::Float64mantle temperature [K] for sol_type==2.skin_d::Float64skin thickness [m].skin_k::Float64skin thermal conductivity [W m-1 K-1].overlap_method::Stringgaseous overlap scheme (ro: rand overlap, ee: equiv extinct, rorr: ro+resort+rebin).target_olr::Float64target OLR [W m-2] for sol_type==4.flux_int::Float64planet's internal flux for sol_type==3.all_channels::Booluse all channels available for RT?flag_rayleigh::Boolinclude rayleigh scattering?flag_gcontinuum::Boolinclude generalised continuum absorption?flag_aerosol::Boolinclude aerosols?aerosol_species::Dictaerosols MMR values or associated condensatesflag_cloud::Boolinclude clouds?phs_timescale::Float64phase change timescale [s]evap_efficiency::Float64re-evaporatione efficiency compared to saturating amountcoldtrap::Boolkeep the cold-trapping effect of condensation on gas mixing ratiosreal_gas::Booluse real gas EOS where possiblethermo_functions::Booluse temperature-dependent thermodynamic propertiesuse_all_gases::Boolstore information on all supported gases, incl those not provided in cfguse_all_vols::Boolstore information on all supported VOLATILE gases, neglecting rock vapourscheck_integrity::Boolconfirm integrity of thermo files using their checksumκ_grey_lw::Float64gas opacity when using grey-gas RT scheme, longwaveκ_grey_sw::Float64gas opacity when using grey-gas RT scheme, shortwavefastchem_work::Stringworking directory for fastchemfastchem_floor::Float64temperature floor on profile provided to fastchemfastchem_maxiter_chem::Float64maximum chemical iterations allowed by fastchemfastchem_maxiter_solv:Float64maximum solver iterations allowed by fastchemfastchem_xtol_chem::Float64solution tolerance required of fastchem (chemical)fastchem_xtol_elem::Float64solution tolerance required of fastchem (elemental)rfm_parfile::Stringpath to HITRAN-formatted .par file provided to RFMtransspec_ref_tau::Float64vertical (normal) optical depth used to define the photospheretransspec_ref_wl::Float64wavelength used to define photosphere [m]transspec_ref_p::Float64pressure level used to define photosphere [bar]ocean_ob_frac::Float64ocean basin area, as fraction of planet surfaceocean_cs_height::Float64continental shelf height [m]
Returns: Nothing
Energy flux calculations
Functions from energy.jl.
AGNI.energy — Module
Contains the energy module, for everything relating to energy transport
Calculates radiative, convective, conductive, etc, flux terms. Combines them together self-consistently to update the temperature profile.
AGNI.energy._make_finite! — Method
Set non-finite values in an array equal to a given fill value.
Arguments:
arrarray potentially containing non-finite valuesfillreplacement value to fill with
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/
- Optical depth across each layer,
τ = κ * (p_bot - p_top) / g - Transmissivity of each layer,
T = exp(-τ) - Emissivity of each layer,
ε = 1 - T - Where κ is the opacity, p is pressure, and g is gravity.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
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_tthe atmosphere struct instance to be used.lw::BoolTrue: longwave calculation. False: shortwave calculation.
Optional arguments:
calc_cf::Boolcalculate contribution function and store optical depths?gauss_ir::Boolusing gaussian angular integration in IR, otherwise uses two-stream approximationrescale_pf::Boolperform rescaling on phase function
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_tthe atmosphere instance to be used.
Optional arguments:
radiative::Boolinclude radiation fluxeslatent_heat::Boolinclude condensation fluxconvective::Boolinclude MLT convection fluxsens_heat::Boolinclude TKE sensible heat fluxconductive::Boolinclude conductive heat fluxdeep::Boolinclude deep heating flux (layer-internal production)convect_sf::Float64scale factor applied to convection fluxeslatent_sf::Float64scale factor applied to phase change fluxescalc_cf::Boolcalculate LW contribution function?calc_hr::Boolcalculate heating rates from fluxes?
Returns:
Boolcalculation succeeded
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_dif). Heating rates are calculated in units of kelvin per day.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
Boolwhether the calculation succeeded
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_tthe atmosphere struct instance to be used
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_tthe atmosphere struct instance to be used.
Returns:
Boolwhether the calculation succeeded
AGNI.energy.deep_heating! — Method
Calculate deep atmospheric heating flux.
The heating is deposited as a Gaussian distribution in log-pressure space, centered at P_dep with width sigma_P.
Two power modes are supported:
"rel"total flux =deepheat_flux_rel * instellation(stellar efficiency)"abs"total flux =deepheat_flux_abs(fixed radiative flux in W m⁻²)
The flux gradient is defined as: dFdeep/dP = Ftotal / (sqrt(2π) * σP * P) * exp(-(ln(P) - ln(Pdep))² / (2 * σ_P²))
This flux is integrated from the TOA downwards to obtain the cumulative flux at each cell edge, representing energy being deposited into the atmosphere.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
AGNI.energy.eval_exchange_coeff — Method
Calculate turbulent kinetic energy (TKE) exchange coefficient.
Based on Monin–Obukhov similarity theory, from roughness length scale. See eq 9 in Nicholson & Benn (2006). Added small epsilon-factor to avoid function blowing-up around regime where height ≈ roughness.
Arguments:
height::Float64Height above surface [m]roughness::Float64Roughness length scale [m]
Returns:
C_d::Float64TKE exchange coefficient [dimensionless]
AGNI.energy.fill_Kzz! — Method
Fill Kzz values for remaining regions of profile.
This function is called after the convective fluxes have been calculated. The Kzz value in the convective regions are already calculated in the MLT scheme.
This function calculates Kzz in the non-convective regions, by extending the Kzz values from the convective region through various parameters.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
Boolfunction executed successfully
AGNI.energy.latent! — Method
Analytical diffusion scheme for condensation and evaporation energy.
Updates fluxes. Requires chemistry._sat_aloft 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_tthe atmosphere struct instance to be used.
Returns:
Boolwhether the calculation succeeded
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_tthe atmosphere struct instance to be used.lw::Boollongwave calculation? Else: shortwavecalc_cf::Bool=falsecalculate contribution function and optical depths?
Returns:
Boolwhether the calculation succeeded
AGNI.energy.reset_fluxes! — Method
Reset energy fluxes to zero.
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_tthe atmosphere struct instance to be used
AGNI.energy.skin_depth — Method
Calculate conductive skin boundary layer thickness, given a conductive flux.
This is effectively the inverse of the skin_flux function, and can be used to determine the thickness of the boundary layer.
d = k * ΔT / F
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.flux_skn::Float64the conductive flux through the skin layer [W m-2].
Returns:
skin_d::Float64conductive skin boundary layer thickness [m].
AGNI.energy.skin_flux — Method
Calculate conductive flux carried by conductive skin boundary layer.
This is a simple implementation of fourier's conduction law, with fixed conductivity and thickness of the boundary layer. Parameters are set in the atmos struct.
F = k * ΔT / d
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
Returns:
flux::Float64conductive flux through the skin layer [W m-2].
Chemistry and phase-change calculations
Functions from chemistry.jl.
AGNI.chemistry — Module
This module handles chemistry, condensation, and evaporation.
Note the important distinctions between the variables which store atmospheric composition.
gas_ovmrstores VMRs inputted by the user, which are usually constant in height.gas_cvmrstores the VMRs calculated by fastchem, which are used as the starting point for condensation calculations.gas_vmrstores the runtime gas volume mixing ratios, after all calculations are performed.
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_tthe atmosphere struct instance to be used.write_cfg::Boolwrite config and elements
Returns:
state::Int64fastchem state (0: success, 1: criticalfail, 2: elemfail, 3: convfail, 4: bothfail)
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.
Does not update aerosols or clouds, which should be handled separately.
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
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_tthe atmosphere struct instance to be used.
Returns:
any_changed::Booldid any component condense or evaporate?
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:
- call
_sat_surf!to handle saturation at the surface, and adjust the pressure grid - call
_chem_gas!to handle gas-phase chemistry in the column - call
_sat_aloft!to handle saturation aloft, above the surface. - update aerosols and clouds
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.do_surf::Booldo saturation cond/evap at surfacedo_chem::Booldo thermochemistry in the columndo_aloft::Booldo saturation cond/evap aloft
Returns:
state::Int64fastchem state (0: success, 1: criticalfail, 2: elemfail, 3: convfail, 4: bothfail)
AGNI.chemistry.normalise_vmrs! — Method
Normalise gas VMRs, keeping condensates unchanged
Only acts on a single model level.
Parameters:
atmos::atmosphere.Atmos_tatmosphere structurei::Int64level index to normalise
AGNI.chemistry.reset_to_chem! — Method
Reset gas VMRs to post-chemistry values, overwriting condensate effect on VMR
Arguments:
atmos::Atmos_tthe atmosphere struct instance to be used.
AGNI.chemistry.restore_composition! — Method
Reset mixing ratios, pressures, and oceans to their original values
Numerical solvers
Functions from solver.jl.
AGNI.solver — Module
Wrapper module around the various solver modules.
Plotting functions and utilities
Functions from plotting.jl.
AGNI.plotting — Module
Contains functions for plotting/diagnosing the atmosphere
AGNI.plotting._get_ylims — Method
Return (p_top, p_bot) pressure axis limits [bar] for a standard profile plot.
AGNI.plotting._get_yticks — Method
Return pressure tick mark values [bar] on a log10 scale for a standard profile plot.
AGNI.plotting._intstr — Method
Format an integer as a plain decimal string.
AGNI.plotting._plot_bandpasses! — Method
Plot telescope bandpasses as translucent vertical spans.
Arguments:
pltplot object to modifyxlims::Tuple{Float64,Float64}x-axis limits on plotinstrumentslist of instruments to plotprspressure level on figure y-axisylimsy-axis limits on plot
AGNI.plotting._plot_tau_isoline! — Method
Plot tau=reftau isoline using precomputed taup arrays.
AGNI.plotting._symlog — Method
Apply a signed symmetric log10 transform, returning zero for |v| < thresh.
Arguments:
v::Float64value to transformthresh::Float64threshold below which to return zero (default: 1.0)
Returns:
Float64log10 transformed value
AGNI.plotting.animate — Method
Convert still-frame images into an animation
Uses FFMPEG provided by Julia library.
Arguments:
output_dir::Stringfolder in which to save the animationframes_dir::Stringfolder containing the frames
Optional arguments:
output_fmt::Stringoutput file format: mp4, mov, ...frames_fmt::Stringinput frame format: png, jpg, ...duration::Float64animation duration [seconds]
AGNI.plotting.combined — Method
Combined multi-panel plot used for tracking behaviour of the solver at runtime.
AGNI.plotting.jacobian — Method
Plot jacobian matrix
Arguments:
b::Array{Float64,2}jacobian matrix (∂r/∂x) to plot as a colormapfname::Stringfilename to save the plotperturb::Array{Bool,1}boolean array indicating which levels were perturbed
AGNI.plotting.plot_albedo — Method
Plot spectral albedo (ratio of SWUP to SWDN)
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixels
AGNI.plotting.plot_cloud — Method
Plot the cloud and aerosol mass mixing ratios.
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelstitle::Stringtitle for the plot
AGNI.plotting.plot_contfunc1 — Method
Plot contribution function at different bands.
The contribution function is plotted with one line (vs pressure) per spectral band.
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelscf_min::Float64minimum contribution function value to plot (log10 units)
AGNI.plotting.plot_contfunc2 — Method
Plot normalised contribution function, per band, versus pressure
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelswl_max::Float64maximum wavelength to plot [nm]
AGNI.plotting.plot_emission — Method
Plot emission spectrum at the TOA
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelswl_max::Float64maximum wavelength to plot [nm]
AGNI.plotting.plot_fluxes — Method
Plot the fluxes at each pressure level
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelsincl_eff::Boolwhether to include the intrinsic (or interior) heat flux as a dashed lineincl_mlt::Boolwhether to include the convective flux as a solid lineincl_cdct::Boolwhether to include the conductive flux as a solid lineincl_latent::Boolwhether to include the latent heating flux as a solid lineincl_deep::Boolwhether to include the deep heating flux as a solid linetitle::Stringtitle for the plot
AGNI.plotting.plot_globe — Method
Globe plot of multi-column atmosphere climate and energy balance.
Left panel: temperature profiles, coloured by column longitude. Right panel: heating rate profiles, coloured by column longitude.
Arguments:
globe::multicol.Globe_tglobe objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixels
AGNI.plotting.plot_pt — Method
Plot the temperature-pressure and Kzz profile.
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelsincl_magma::Boolinclude the magma temperature as a scatter pointtitle::Stringtitle for the plot
AGNI.plotting.plot_radius — Method
Plot the radius vs pressure profile.
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixelstitle::Stringtitle for the plot
AGNI.plotting.plot_tau — Method
Plot optical depth per band as heatmap (LW + SW)
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of each plot panel in pixelssize_y::Int64height of each plot panel in pixelswl_max::Float64maximum wavelength to plot [nm]
AGNI.plotting.plot_vmr — Method
Plot the gas phase volume mixing ratios at each cell-centre location.
Arguments:
atmos::atmosphere.Atmos_tatmosphere objectfname::Stringfilename to save the plot (if empty, does not save)size_x::Int64width of the plot in pixelssize_y::Int64height of the plot in pixels
Physical properties and constants
Functions from phys.jl.
AGNI.phys.calc_Teq — Method
Calculate planetary equilibrium temperature.
https://en.wikipedia.org/wiki/Planetaryequilibriumtemperature?useskin=vector
Arguments:
S::Float64Bolometric instellation [W m-2]α::Float64Bond albedo
Returns:
Teq::Float64Planetary equilibrium temperature [K]
AGNI.phys.calc_Tskin — Method
Calculate planetary skin temperature.
https://en.wikipedia.org/wiki/Skintemperature(atmosphere)?useskin=vector
Arguments:
S::Float64Bolometric instellation [W m-2]α::Float64Bond albedo
Returns:
Tskin::Float64Planetary skin temperature [K]
AGNI.phys.calc_therm_diffus — Method
Calculate thermal diffusivity.
https://en.wikipedia.org/wiki/Thermal_diffusivity?useskin=vector
Arguments:
k::Float64Thermal conductivity [W m-1 K-1]ρ::Float64Density [kg m-3]cp::Float64Specific heat capacity [J K-1 kg-1]
Returns:
α::Float64Thermal diffusivity [m2 s-1]
AGNI.phys.cent_accel — Method
Calculate radial component of centripetal acceleration.
Note that this is only the component of the centripetal acceleration which acts in the radial direction, and is relevant for calculating the effective gravity at the surface of a rotating planet. This means a_c is zero at the poles.
The full centripetal acceleration is given by the equation below, where d is the distance from the rotation axis and p is the rotation period.
a_c = 4 * pi^2 * d / p^2
The distance d is equal to r * cos(θ), so the equation can be rewritten as:
a_c = 4 * pi^2 * d * cos(θ) / p^2
And then to get the radial component, we multiply by cos(θ) again:
a_c = r * ( 2 * pi * cos(θ) / p )^2
Arguments:
p::Float64Axial rotation period [s]r::Float64Radius of this layer [m]θ::Float64Latitude of this column [degrees]
Returns:
a_c::Float64Centripetal acceleration [m s-2]
AGNI.phys.evaluate_planck — Method
Evaluate the Planck function at a given wavelength and temperature.
Integrated over a hemisphere.
Arguments:
wave::Float64Wavelength [nm]tmp::Float64Temperature [K]
Returns:
flx::Float64Spectral flux density [W m-2 nm-1]
AGNI.phys.grav_accel — Method
Calculate gravitational acceleration.
Using the Newtonian formula for universal gravitation in spherical geometry.
Arguments:
mass::Float64Enclosed mass [kg]radius::Float64Enclosed radius [m]
Returns:
grav::Float64Gravitational acceleration [m s-2]
File I/O modules
Functions from save.jl and load.jl.
AGNI.save.write_fluxes — Method
Write cell-edge energy fluxes to a CSV file
Arguments
atmos::Atmos_tAtmosphere objectfname::StringFilename to write to
AGNI.save.write_ncdf — Method
Write verbose atmosphere data to a NetCDF file
Arguments
atmos::Atmos_tAtmosphere objectfname::StringFilename to write to
AGNI.save.write_profile — Method
Write {Pressure, Temperature, Radius} profile to a CSV file
Arguments
atmos::Atmos_tAtmosphere objectfname::StringFilename to write to
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_tthe atmosphere struct instance to be used.fname::Stringpath to the NetCDF file
Returns:
ok::Boolloaded ok?