pycif.plugins.chemistries.lmdz — API reference

pycif.plugins.chemistries.lmdz — API reference#

Configuration reference: lmdz plugin

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

Write the LMDZ chemical_scheme.nml Fortran namelist.

Parses each reaction string in self.reactions using parse_reaction(), then assembles three Fortran namelists (&dims, &species, &reactions) and writes them to {chem_dir}/chemical_scheme.nml.

Parameters:

self – LMDZ chemistry plugin instance with reactions, prescribed_species, prodloss_species, deposition_species, and chem_dir set.

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

Not implemented for the LMDZ/SACS chemistry plugin.

The LMDZ chemistry scheme is always generated from the YAML configuration at runtime (see create_chemicalscheme()). Reading a pre-existing scheme from files is not supported.

Raises:

NotImplementedError – always.

pycif.plugins.chemistries.lmdz.utils.parse_reaction(self, reac_str: str) tuple[list[str], list[str], list[int], Literal['constant', 'simplified_arrhenius', 'arrhenius', 'pressure', 'photolysis'], str | list[float]][source]#

Parse a SACS reaction string into its components.

The expected format is:

{reactants} -> {products}  {rate_type} = {rate_formula}

where {reactants} and {products} are +-separated species names (with optional stoichiometric prefixes N*species), and the rate section is one of:

  • k = <float> — constant rate.

  • k(T) = Aexp(-B/T), A = …, B = — simplified Arrhenius.

  • k(T) = Aexp(-B/T)(300/T)**N, A = …, B = …, N = — full Arrhenius.

  • k(P) = A(B+C*P/Pref), A = …, B = …, C = — pressure-dependent.

  • J = <varname> — photolysis (hv must appear in reactants).

Parameters:
  • self – LMDZ chemistry plugin instance (provides active_species and prescribed_species for validation).

  • reac_str (str) – one reaction line from the YAML reactions list.

Returns:

(reactant_list, product_list, stoi_list, rate_type, rate_terms) where stoi_list contains integer stoichiometric coefficients for each product, rate_type is one of the RATE_TYPE literals, and rate_terms is either a list of floats (kinetic parameters) or a string (J-rate variable name).

Return type:

tuple

Raises:

ValueError – if the reaction string does not match the expected grammar, if a reactant is neither active nor prescribed, or if stoichiometric numbers are non-positive.

pycif.plugins.chemistries.lmdz.utils.format_reaction(reactant_list: list[str], product_list: list[str], stoi_list: list[int], rate_type: Literal['constant', 'simplified_arrhenius', 'arrhenius', 'pressure', 'photolysis'], rate_terms: list[str]) str[source]#

Serialise parsed reaction components back into a SACS reaction string.

The inverse of parse_reaction(). Formats reactants, products (with stoichiometric prefixes when stoi > 1), and the rate formula into the canonical SACS one-line representation.

Parameters:
  • reactant_list (list[str]) – reactant species names.

  • product_list (list[str]) – product species names.

  • stoi_list (list[int]) – stoichiometric coefficient for each product.

  • rate_type (RATE_TYPE) – one of 'constant', 'simplified_arrhenius', 'arrhenius', 'pressure', 'photolysis'.

  • rate_terms (list[str]) – rate parameters (floats for kinetic types, J-rate variable name for photolysis).

Returns:

the formatted reaction string.

Return type:

str

Raises:

ValueError – if rate_type is unrecognised.