Chemistry Models

BeAR currently includes the following chemistry models:

Details on the implementation of these parametrisations are discussed here.

BeAR can also mix several different of these models in a single retrieval. This is explained in this section. All chemical species that BeAR uses have to be defined in a corresponding header file. This is described at the bottom of this chapter.

Isoprofiles

In the corresponding forward_model.toml of the chosen forward model, the isoprofile chemistry model is chosen by using the keyword iso (or isoprofile), followed by a list of species that should be used by the retrieval:

chemistry = [
  { model = "iso", params = ["H2O", "CH4", "NH3", "K", "H2S", "CO2"] },
]

For each species, a corresponding entry in the prior config file is required. The priors are name-keyed and therefore order-independent: for the isoprofile model, each species uses the prior name chem_<species>_mr, with the species symbol written in lower case. For the example above, the priors chem_h2o_mr, chem_ch4_mr, chem_nh3_mr, chem_k_mr, chem_h2s_mr, and chem_co2_mr are expected.

Furthermore, as described by Kitzmann et al. (2020), the abundance of sodium (Na) is linked to the one of potassium (K) through the ratio of their solar elemental abundances (solar_na_k = 16.2181). Thus, in the example above, the Na abundance would automatically be derived from K, without explicitly including the former as a free parameter.

If Na should be retrieved independently, it needs to be added as a separate species as shown below.

chemistry = [
  { model = "iso", params = ["H2O", "CH4", "NH3", "K", "H2S", "CO2", "Na"] },
]

Isoprofiles with centred-log-ratio priors

The standard isoprofile chemistry model described above fills up the background of the atmosphere with a mixture of molecular hydrogen and helium. While this valid for gas giants or brown dwarfs, this is less suitable for atmospheres that are not dominated by H2 and He. For cases, where the background gas is not explicitly known, centred-log-ratio priors for the chemical abundances can be used. These can more efficiently sample the prior distributions in a way to determine which of the chosen species is the dominant one. More detailed information on these priors can be found in Benneke & Seager (2012).

For a given mixture of \(n\) gases, the centred-log-ratio conversion (clr) for the mixing ration \(x_j\) of a given molecule \(j\) in the mixture is given by

\[\xi_j = \mathrm{clr}(x_j) = \ln \frac{x_j}{g(\mathbf x)}\]

where \(g(\mathbf x)\) is the geometric mean of all mixing ratios \(\mathbf{x}\):

\[g(\mathbf{x}) = \left( \prod_{j=1}^{n} x_j \right)^{1/n} \ .\]

Due to the constraint that

\[\sum_{j=1}^n x_j = 1 \quad \text{or} \quad \sum_{j=1}^n \xi_j = 0 \ ,\]

only \(n-1\) free parameters are needed in the retrieval.

The prior distributions for the free parameters should be uniform and vary between 0 and 1. BeAR will use these priors to produce \(\xi_j\) values subject to the constraints that \(\min\left(\mathbf{x}\right) = 10^{-12}\) and \(\max\left(\mathbf{x}\right) = 1\). It is important to note that the prior boundaries for \(\xi_j\) depend on the number of molecules in the retrieval and the chosen value of the smallest allowed mixing ratio. For uniform priors between 0 and 1, BeAR will do the conversion to \(\xi_j\) and then to the mixing ratios \(x_j\) automatically.

This chemistry model is chosen in the forward_model.toml file by using

chemistry = [
  { model = "iso_clr", params = ["H2O", "CH4", "NH3", "H2S", "CO2"] },
]

As noted above, for these 5 species only 4 priors are needed due to the constraint that the sum of their mixing ratios has to be unity. This chemistry model will, therefore, select one of these free species as the dominant background gas. In the prior config file, the clr parameters use the name chem_<species>_clr (species symbol in lower case), and only priors for the first four molecules would need to be listed. The abundance of the last species in the list above will be determined from the other molecules.

Isoprofiles with a retrieved isotopologue ratio

This model is a variant of the isoprofile model in which the abundance of one isotopologue is not retrieved directly but derived from its parent molecule through a retrieved isotopic ratio. It is intended for high-resolution retrievals of, for example, the \(^{13}\mathrm{CO}/^{12}\mathrm{CO}\) ratio. The model is chosen in the forward_model.toml file with the keyword iso_ratio (or isoprofile_ratio), followed by the list of species:

chemistry = [
  { model = "iso_ratio", params = ["H2O", "CO", "13C16O"] },
]

At least two species are required. The last species in the list is the isotopologue and the second-to-last one is its parent molecule. All species except the last one are treated as ordinary isoprofiles with constant mixing ratios, using the prior names chem_<species>_mr as in the isoprofile model. The last species uses the prior name chem_<species>_ratio. For the example above, the priors chem_h2o_mr, chem_co_mr, and chem_13c16o_ratio are expected.

The ratio parameter is the logarithmic offset from the terrestrial standard ratio, following the convention of, e.g., Line et al. (2021):

\[\left[ \mathrm{iso}/\mathrm{parent} \right] = \log_{10} \left( \frac{x_\mathrm{iso}}{x_\mathrm{parent}} \right) - \log_{10} \left( \frac{x_\mathrm{iso}}{x_\mathrm{parent}} \right)_\oplus \ ,\]

such that the mixing ratio of the isotopologue is given by

\[x_\mathrm{iso} = \frac{x_\mathrm{parent}}{89} \, 10^{\left[ \mathrm{iso}/\mathrm{parent} \right]} \ .\]

A value of 0 therefore corresponds to the terrestrial ratio, while positive values indicate an enrichment of the isotopologue. Note that the standard ratio of 89 (the terrestrial \(^{12}\mathrm{C}/^{13}\mathrm{C}\) ratio) is currently hard-coded in src/chemistry/iso_ratio_chemistry.h and is used regardless of the chosen species.

In contrast to the standard isoprofile model, the Na abundance is not automatically linked to K in this model. The remaining background of the atmosphere is treated in the same way as for the other free chemistry models, see the section on mixing chemistry models.

Piecewise polynomials

If a chemical species, say, H2O should be included using non-constant abundances by using the parametrisation with piecewise polynomials, the keyword free, followed by the species’ formula, the number of elements k, and the polynomial degree q need to be added to the forward_model.toml file. This model takes exactly three parameters:

chemistry = [
  { model = "free", params = ["H2O", "k", "q"] },
]

Note, that unlike the isoprofile chemistry above, only a single species can be used here. As stated here, the number of free parameters for this parametrisation is \(k q + 1\). The free parameters correspond to the mixing ratios of the chosen species at the \(k q + 1\) discrete pressure points that are distributed equidistantly in logarithmic pressure space. In the prior config file, they are name-keyed as chem_<species>_mr_<i>, running from chem_<species>_mr_0 at the bottom of the atmosphere to chem_<species>_mr_<kq> at its top.

Cubic b splines

For parametrising the vertical profile of a species, for example, CH4 by a cubic b spline, the keyword free_cs (or free_cspline), followed by the species’ formula and the number of points k need to be added to the forward_model.toml file. This model takes exactly two parameters:

chemistry = [
  { model = "free_cs", params = ["CH4", "k"] },
]

Note, that like for the piecewise polynomials, only a single species can be used here. As stated here, the number of free parameters for this parametrisation is equal to the number of points \(k\) and needs to be at least 5. They correspond to the mixing ratios at the \(k\) discrete pressure points that are distributed equidistantly in logarithmic pressure space.

In the prior config file, these free parameters are name-keyed as chem_<species>_mr_<i>, running from chem_<species>_mr_0 at the bottom of the atmosphere to chem_<species>_mr_<k-1> at its top.

Piecewise cubic Hermite interpolation

For parametrising the vertical profile of a species, for example, CH4 by a monotone piecewise cubic Hermite interpolant (PCHIP), the keyword free_p (or free_pchip), followed by the species’ formula and the number of control points k need to be added to the forward_model.toml file. This model takes exactly two parameters:

chemistry = [
  { model = "free_p", params = ["CH4", "k"] },
]

Note, that like for the piecewise polynomials and the cubic b splines, only a single species can be used here. The number of free parameters is equal to the number of control points \(k\), which needs to be at least 4. They correspond to the mixing ratios at the \(k\) control points that are distributed equidistantly in logarithmic pressure space.

BeAR uses the monotone PCHIP interpolant from the Boost.Math library to construct the profile between the control points. Unlike the cubic b spline model (which requires at least 5 control points and does not preserve monotonicity), the PCHIP interpolant is shape-preserving: it does not overshoot between adjacent control points and preserves the monotonicity of the control-point values, thus avoiding the spurious oscillations that a cubic b spline can introduce.

In the prior config file, these free parameters are name-keyed as chem_<species>_mr_<i> (species symbol in lower case), running from chem_<species>_mr_0 at the bottom of the atmosphere to chem_<species>_mr_<k-1> at its top.

Details on the implementation of this parametrisation are discussed here.

Step function

The step-function model describes the vertical profile of a single species by two constant mixing ratios separated by a sharp transition in pressure: a constant deep mixing ratio below the transition pressure and a constant upper mixing ratio above it. This can, for example, approximate a species that is quenched in the deep atmosphere but depleted or enhanced higher up. It is chosen in the forward_model.toml file with the keyword sf (or step_function), followed by the species’ formula. This model takes exactly one parameter:

chemistry = [
  { model = "sf", params = ["CH4"] },
]

As for the other free-profile models, only a single species can be used here. The step-function model always has three free parameters (with the species symbol written in lower case):

  • chem_<species>_mr_deep: the constant mixing ratio at pressures greater than or equal to the transition pressure, i.e. in the deep atmosphere;

  • chem_<species>_mr_upper: the constant mixing ratio at pressures lower than the transition pressure, i.e. in the upper atmosphere;

  • chem_<species>_p_transition: the transition pressure that separates the two levels.

The transition is a sharp step, without any smoothing: at every level BeAR assigns the deep mixing ratio if the pressure is at or above the transition pressure, and the upper mixing ratio otherwise.

As with all chemistry models, these parameters are name-keyed and can be listed in any order in the prior config file.

Equilibrium chemistry

BeAR has the option of calculating the chemical composition of the atmosphere using the equilibrium chemistry code FastChem. In the forward_model.toml file, this is chosen by

chemistry = [
  { model = "eq", params = ["fastchem_parameters.dat"] },
]

The indicated file after the keyword eq is the main configuration file for FastChem 4. It contains information on the elemental abundances and thermochemical data that FastChem should use. This file has the following structure

#element abundance file
fastchem_data/element_abundances/asplund_2021.dat

#species data file
fastchem_data/logK/logK.dat fastchem_data/logK/logK_condensates.dat

#accuracy of chemistry iteration
1.0e-5

#accuracy of element conservation
1.0e-4

#max number of chemistry iterations
10000

#max number internal solver iterations
20000

The parameter file consists of six blocks, in this order:

  1. the elemental abundance file;

  2. the gas-phase species data file. Optionally, a condensate species data file can be given on the same line, separated by a space (e.g. logK.dat logK_condensates.dat), to enable equilibrium condensation;

  3. the relative accuracy of the chemistry iteration;

  4. the accuracy of the element conservation (new in FastChem 4);

  5. the maximum number of chemistry iterations;

  6. the maximum number of internal solver iterations.

BeAR already includes samples of the elemental abundance and species data files in the folder fastchem_data. Otherwise, they can be obtained from the FastChem repository. More details on FastChem and these parameters can be found in the FastChem documentation.

The equilibrium chemistry model always has one free parameter, the metallicity factor fc_metallicity. It is a general factor that multiplies all elemental abundances read from the abundance file, except hydrogen and helium. It refers to the elemental abundances specified in the FastChem parameter file, which are not necessarily always solar.

In addition, individual elemental abundance ratios can be turned into free parameters by listing them as "X/Y" strings after the parameter file in the params array:

chemistry = [
  { model = "eq", params = ["fastchem_parameters.dat", "C/O", "Fe/H", "V/H"] },
]

Each ratio adds a free parameter with the name fc_<x>_<y>_ratio (both element symbols in lower case), e.g. fc_c_o_ratio for C/O or fc_v_h_ratio for V/H. For a ratio relative to hydrogen (X/H), the parameter scales the abundance relative to the reference X/H value; for a ratio X/Y with Y other than hydrogen, the parameter is the literal number ratio of the two elements. As with all priors, these parameters are name-keyed and can be listed in any order in the prior config file, with fc_metallicity as the metallicity factor.

Even though FastChem is a very fast chemistry code, the computational time will increase substantially when using this chemistry model. One way to decrease the calculation time is to reduce the number of elements treated in FastChem to only the most important ones, such as H, He, C, O, and N. Information on how to change the FastChem input files can again be found in the FastChem documentation.

Background species

This chemistry model will fill up the background of the atmosphere with a specific chemical species. The mixing ratio \(x_\mathrm{bg}\) of this background species \(i\) is determined by the mixing ratios of all other species \(j\):

\[x_\mathrm{bg} = 1 - \sum_{j, j \neq i} x_j \ .\]

For a gas giant or a brown dwarf, the background is usually given by a combination of molecular hydrogen (H2) and helium (He), whereas for the atmosphere of an Earth-like planet, the background species is rather molecular nitrogen (N2).

This background chemistry model is chosen in the forward_model.toml file by using the keyword bg or background, followed by a single parameter that selects one of three modes:

chemistry = [
  { model = "bg", params = ["N2"] },
]

The three available modes are:

  • A single chemical species symbol (e.g. "N2"): the background is filled up with that one species. The species has to be present in the header file src/chemistry/chem_species.h.

  • “H2He”: the background is filled with a mixture of H2 and He at their fixed solar elemental abundance ratio. This special “species” does not need to be added to the list of chemical species in src/chemistry/chem_species.h, but H2 and He individually need to be present there.

  • “HHeEquilibrium”: the background is filled with hydrogen and helium, where the split between atomic H, molecular H2, and He is computed from a temperature- and pressure-dependent equilibrium. This is useful for hot atmospheres in which hydrogen is partly dissociated.

Since the mixing ratio of the background species is determined by those of all other species, none of these modes requires a free parameter in the prior distribution file.

Mixing different chemistry models

BeAR also has the ability to use multiple chemistry models simultaneously. For example, to constrain the constant abundances of some species and then fill up the rest of the atmosphere with H2 and He, the following can be used:

chemistry = [
  { model = "iso", params = ["H2O", "NH3", "CO2"] },
  { model = "bg", params = ["H2He"] },
]

Another use case could be to perform a retrieval with constant mixing ratios for a selection of species and a separate species, say CH4, that is assumed to have non-constant abundances. Together with a background gas, the following can be used as configuration in the forward_model.toml file:

chemistry = [
  { model = "iso", params = ["H2O", "NH3", "CO2"] },
  { model = "free_cs", params = ["CH4", "5"] },
  { model = "background", params = ["N2"] },
]

BeAR will call the chemistry models in the order they appear in this list. That means, in this example it would first set the constant mixing ratios of H2O, NH3, and CO2, then use a variable profile based on cubic splines for methane, and finally fill up the rest of the atmosphere with molecular nitrogen.

The mean molecular weight is recalculated after each chemistry model. BeAR will also check the sum of all mixing ratios and reject parameter combinations where the sum exceeds 1.1.

Yet another possibility is to calculate the background atmosphere in chemical equilibrium and try to retrieve a separate species assumed not to be in equilibrium:

chemistry = [
  { model = "eq", params = ["fastchem_parameters.dat"] },
  { model = "iso", params = ["CO"] },
]

Here, BeAR would first use FastChem to determine the chemical composition in equilibrium and then replace the CO abundance by a constant mixing ratio that is a separate free parameter. This can, for example, simulate the impact of vertical mixing. An extension of that case could also include other non-constant species to take into account photochemical effects in the upper atmosphere:

chemistry = [
  { model = "eq", params = ["fastchem_parameters.dat"] },
  { model = "iso", params = ["CO"] },
  { model = "free_cs", params = ["SO2", "5"] },
  { model = "free_cs", params = ["HCN", "5"] },
]

Because the priors are name-keyed, the free parameters can be listed in any order in the prior config file, independently of the order of the chemistry models in forward_model.toml.

Thus, for the first example, the following priors need to be listed:

  • constant mixing ratios chem_h2o_mr, chem_nh3_mr, chem_co2_mr

  • 5 mixing ratios chem_ch4_mr_0 to chem_ch4_mr_4 for CH4

For the last example above, the prior file needs to list

  • fc_metallicity for the equilibrium chemistry

  • the constant CO mixing ratio chem_co_mr

  • 5 mixing ratios chem_so2_mr_0 to chem_so2_mr_4 for SO2

  • 5 mixing ratios chem_hcn_mr_0 to chem_hcn_mr_4 for HCN

One should still pay careful attention to the order of the chemistry models themselves, since they are applied in sequence. For example, in this case:

chemistry = [
  { model = "iso", params = ["CO"] },
  { model = "eq", params = ["fastchem_parameters.dat"] },
]

CO would first be set to an isoprofile and then in the second step be replaced with the results from the equilibrium chemistry calculation. The free mixing ratio of CO will, therefore, remain unconstrained.

Another incorrect order would, for example, also be the following case:

chemistry = [
  { model = "bg", params = ["H2He"] },
  { model = "iso", params = ["H2O", "CO2", "NH3"] },
]

Here, BeAR would first fill up the entire atmosphere with H2 and He. This means that when H2O, CO2, and NH3 are added through the second model, the sum of all mixing ratios would exceed 1.1. All parameter combinations during the retrieval calculations would, therefore, be rejected.

Chemical species list

For internal and external communications in the code, BeAR defines a list of all chemical species it can use. The corresponding source code can be found in the header file src/chemistry/chem_species.h.

Here, an enumeration is first declared

src/chemistry/chem_species.h
enum chemical_species_id {
  _TOTAL, _H, _He, _C, _O, _Fe, _Fep, _Ca, _Ti, _Tip, _H2, _H2O, _CO2, _CO, _CH4, _HCN, _NH3, _C2H2,
  _N2, _Na, _K, _H2S, _Hm, _TiO, _VO, _FeH, _SH, _MgO, _AlO, _CaO, _CrH, _MgH, _CaH, _TiH, _OH, _e,
  _V, _Vp, _Mn, _Si, _Cr, _Crp, _SiO, _SiO2, _SO2, _CS2, _Co, _Ni, _Mg, _13C16O, _SiS, _SiH, _CH, _HCl, _ScH};

This creates a list of integer constants, such that later in the code, the position of, say, H2O in a vector with chemical species can be referred to as _H2O. As can be seen above, the current list contains about 55 species, including neutral metals (Fe, Ca, Ti, V, Mn, Si, Cr, Co, Ni, Mg), their ions (Fe+, Ti+, V+, Cr+), free electrons (e-), a wide range of molecules (CO, CH4, HCN, NH3, TiO, VO, FeH, SO2, SiS, HCl, …), and the isotopologue 13C16O.

Each species is described by the struct chemistry_data, which has four fields: the integer id, the usual symbol/formula, the fastchem_symbol used by FastChem, and the atomic/molecular weight:

src/chemistry/chem_species.h
struct chemistry_data{
  chemical_species_id id;
  std::string symbol;
  std::string fastchem_symbol;
  double molecular_weight;
};

A vector with the important chemical information of all species is then created:

src/chemistry/chem_species.h
const std::vector<chemistry_data> species_data{
  {_TOTAL,  "Total",  "Total",       0.0},
  {_H,      "H",      "H",           1.00784},
  {_He,     "He",     "He",          4.002602},
  {_C,      "C",      "C",           12.0107},
  {_O,      "O",      "O",           15.999},
  {_Fe,     "Fe",     "Fe",          55.845},
  {_Fep,    "Fe+",    "Fe1+",        55.845},
  {_Ca,     "Ca",     "Ca",          40.078},
  {_Ti,     "Ti",     "Ti",          47.867},
  {_Tip,    "Ti+",    "Ti1+",        47.867},
  {_H2,     "H2",     "H2",          2.01588},
  {_H2O,    "H2O",    "H2O1",        18.01528},
  {_CO2,    "CO2",    "C1O2",        44.01},
  {_CO,     "CO",     "C1O1",        28.0101},
  {_CH4,    "CH4",    "C1H4",        16.04246},
  {_HCN,    "HCN",    "C1H1N1_hcn",  27.0253},
  {_NH3,    "NH3",    "H3N1",        17.03052},
  {_C2H2,   "C2H2",   "C2H2",        26.04},
  {_N2,     "N2",     "N2",          28.0134},
  {_Na,     "Na",     "Na",          22.98977},
  {_K,      "K",      "K",           39.0983},
  {_H2S,    "H2S",    "H2S1",        34.09099},
  {_Hm,     "H-",     "H1-",         1.00784},
  {_TiO,    "TiO",    "O1Ti1",       63.8664},
  {_VO,     "VO",     "O1V1",        66.9409},
  {_FeH,    "FeH",    "H1Fe1",       56.853},
  {_SH,     "SH",     "H1S1",        34.08},
  {_MgO,    "MgO",    "Mg1O1",       40.3044},
  {_AlO,    "AlO",    "Al1O1",       42.981},
  {_CaO,    "CaO",    "Ca1O1",       56.0774},
  {_CrH,    "CrH",    "Cr1H1",       54.0040},
  {_MgH,    "MgH",    "H1Mg1",       26.3209},
  {_CaH,    "CaH",    "Ca1H1",       41.0859},
  {_TiH,    "TiH",    "H1Ti1",       48.87484},
  {_OH,     "OH",     "H1O1",        17.008},
  {_e,      "e-",     "e-",          5.4857990907e-4},
  {_V,      "V",      "V",           50.9415},
  {_Vp,     "V+",     "V1+",         50.9415},
  {_Mn,     "Mn",     "Mn",          54.938044},
  {_Si,     "Si",     "Si",          28.085},
  {_Cr,     "Cr",     "Cr",          51.996},
  {_Crp,    "Cr+",    "Cr1+",        51.996},
  {_SiO,    "SiO",    "O1Si1",       44.08},
  {_SiO2,   "SiO2",   "O2Si1",       60.08},
  {_SO2,    "SO2",    "O2S1",        64.066},
  {_CS2,    "CS2",    "C1S2",        76.139},
  {_Co,     "Co",     "Co",          58.9332},
  {_Ni,     "Ni",     "Ni",          58.6934},
  {_Mg,     "Mg",     "Mg",          24.3050},
  {_13C16O, "13C16O", "C1O1",        28.9982},
  {_SiS,    "SiS",    "S1Si1",       60.150},
  {_SiH,    "SiH",    "H1Si1",       29.093},
  {_CH,     "CH",     "C1H1",        13.01},
  {_HCl,    "HCl",    "Cl1H1",       36.46},
  {_ScH,    "ScH",    "H1Sc1",       47.98}};

This vector connects the defined integer constants with actual chemical species. The second column contains the usual symbol/formula of the chemical species, the third the corresponding Hill notation for FastChem, and the last column the atomic/molecular weight. Note that some FastChem symbols carry a suffix to disambiguate isomers, such as HCN whose FastChem symbol is C1H1N1_hcn. The molecular-weight information is used internally to compute important quantities, such as the mean molecular weight. A special species is _TOTAL. This refers to the total number density, given through the pressure via the ideal gas law. It has a molecular weight of 0 to prevent it from contributing to the mean molecular weight.

BeAR already includes a list of important species. If a species that should be used in a retrieval is missing, it needs to be added to src/chemistry/chem_species.h.

This has to be done at two places:

  • the enumeration enum chemical_species_id

  • the vector const std::vector<chemistry_data> species_data

It is recommended to always add a new species at the end of each vector to avoid confusion. For example, to add phosphine (PH3) as a new species, the code needs to be adapted to

src/chemistry/chem_species.h
enum chemical_species_id {
  _TOTAL, _H, _He, _C, _O, /* ... */, _HCl, _ScH, _PH3};

const std::vector<chemistry_data> species_data{
  {_TOTAL,  "Total",  "Total",       0.0},
  /* ... */
  {_ScH,    "ScH",    "H1Sc1",       47.98},
  {_PH3,    "PH3",    "H3P1",        33.99758}};

After changing the header file, the code needs to be re-compiled.