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_chemicalschemebut usesDEPO_SPECIESinstead ofDEPO_SPECfor the deposition file. Callscreate_mandchem()andcreate_optchem()to write:REACTIONS/CHEMISTRY/STOICHIOMETRY/REACTION_RATESACTIVE_SPECIES/ALL_SPECIES/ANTHROPIC/BIOGENICPHOTO_RATES/FAMILIESchemical_scheme.nml
- Parameters:
self – TM5 chemistry plugin instance with all species lists and
schemeid/dirchem_refset.
- 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
workdirandschemeidset.**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):
REACTIONS.{schemeid}— one reaction string per line.PRESCRIBED_SPECIES.{schemeid}— prescribed species names.PRODLOSS_SPECIES.{schemeid}— production/loss species names.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
REACTIONSandPRESCRIBED_SPECIESfiles, parses stoichiometry and rate coefficients (same type codes as CHIMERE), then writes:STOICHIOMETRY/CHEMISTRY/REACTION_RATESPHOTO_RATES/FAMILIES(empty)ALL_SPECIES/ACTIVE_SPECIES/ANTHROPIC/BIOGENIC
Unlike the CHIMERE variant, the active-species file stores TM5-specific
restart_idandmasscolumns instead of transport-scheme flags.- Parameters:
chemistry – TM5 chemistry plugin instance.
filer (str) – path to the
REACTIONStext file.fileps (str) – path to the
PRESCRIBED_SPECIEStext 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_RATESfile (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_RATESoutput 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]