pycif.plugins.chemistries.TM5 — API reference

pycif.plugins.chemistries.TM5 — API reference#

Configuration reference: TM5 plugin

pycif.plugins.chemistries.TM5.make_chemistry.create_chemicalscheme(self)[source]#

Generate TM5 chemical-scheme files from the YAML configuration.

Functionally identical to the CHIMERE create_chemicalscheme but uses DEPO_SPECIES instead of DEPO_SPEC for the deposition file. Calls create_mandchem() and create_optchem() to write:

  • REACTIONS / CHEMISTRY / STOICHIOMETRY / REACTION_RATES

  • ACTIVE_SPECIES / ALL_SPECIES / ANTHROPIC / BIOGENIC

  • PHOTO_RATES / FAMILIES

  • chemical_scheme.nml

Parameters:

self – TM5 chemistry plugin instance with all species lists and schemeid / dirchem_ref set.

pycif.plugins.chemistries.TM5.read_chemistry.read_chemicalscheme(chemistry, **kwargs)[source]#

Read the TM5 chemical scheme from pre-computed files.

Parses scheme files in {workdir}/chemical_scheme/{schemeid}/ and populates the chemistry plugin with species lists and counts (same structure as the CHIMERE reader):

  • acspecies / nacspecies — active species.

  • emis_species / nemisspec — anthropogenic emission species.

  • bio_species / nemisspec_interp — biogenic emission species.

  • dep_species / ndepspecies — depositing species.

  • nreacs / nfamilies — reaction and family counts.

Parameters:
  • chemistry – TM5 chemistry plugin instance with workdir and schemeid set.

  • **kwargs – unused.

pycif.plugins.chemistries.TM5.utils.create_mandchem(chemistry, mandatory_files)[source]#

Write the four mandatory TM5 chemistry text files from the YAML config.

Writes (in order):

  1. REACTIONS.{schemeid} — one reaction string per line.

  2. PRESCRIBED_SPECIES.{schemeid} — prescribed species names.

  3. PRODLOSS_SPECIES.{schemeid} — production/loss species names.

  4. DEPO_SPECIES.{schemeid} — depositing species names.

Files are created empty when the corresponding species list is absent.

Parameters:
  • chemistry – TM5 chemistry plugin instance.

  • mandatory_files (list[str]) – four file paths in the order above.

pycif.plugins.chemistries.TM5.utils.create_optchem(chemistry, filer, fileps)[source]#

Build the derived TM5 scheme files from reactions and species lists.

Reads REACTIONS and PRESCRIBED_SPECIES files, parses stoichiometry and rate coefficients (same type codes as CHIMERE), then writes:

  • STOICHIOMETRY / CHEMISTRY / REACTION_RATES

  • PHOTO_RATES / FAMILIES (empty)

  • ALL_SPECIES / ACTIVE_SPECIES / ANTHROPIC / BIOGENIC

Unlike the CHIMERE variant, the active-species file stores TM5-specific restart_id and mass columns instead of transport-scheme flags.

Parameters:
  • chemistry – TM5 chemistry plugin instance.

  • filer (str) – path to the REACTIONS text file.

  • fileps (str) – path to the PRESCRIBED_SPECIES text file.

Returns:

(nallqmax, nphoto_rates) — total species count and number of photolysis reactions.

Return type:

tuple[int, int]

pycif.plugins.chemistries.TM5.utils.read_react(reactions, filej)[source]#

Parse reaction-rate strings and write the PHOTO_RATES file (TM5 variant).

Identical to the CHIMERE read_react() but returns a 2-tuple (reactions_rates, nphoto_rates) without the photo_rates DataFrame (TM5 uses a different photolysis interface).

Classifies each reaction into one of five rate types (same codes as CHIMERE: 1=constant, 2=simplified Arrhenius, 3=full Arrhenius, 4=pressure, 5=photolysis) and writes photolysis index ↔ name pairs to filej.

Parameters:
  • reactions (np.ndarray) – 1-D array of rate-formula strings.

  • filej (str) – path to the PHOTO_RATES output file.

Returns:

(reactions_rates, nphoto_rates) where reactions_rates is a (nreac, 10) float array with the type code in column 0 and kinetic parameters in columns 1–9.

Return type:

tuple[np.ndarray, int]