uclchem.makerates.network#

This python file contains all functions for de-duplicating species and reaction lists, checking for common errors, and automatic addition of reactions such as freeze out, desorption and bulk reactions for three phase models.

Module Contents#

Classes#

LoadedNetwork

Network version that skips all steps and just loads two lists. This is another

Network

The network class stores all the information about reaction network.

class uclchem.makerates.network.LoadedNetwork(species: list[uclchem.makerates.species.Species], reactions: list[uclchem.makerates.reaction.Reaction])[source]#

Bases: Network

Network version that skips all steps and just loads two lists. This is another here be dragons version, use this with exceeding caution as no checks are performed for you.

Parameters:

Network (_type_) – _description_

A loader of networks without any checks.

Here be dragons.

Parameters:
class uclchem.makerates.network.Network(species: list[uclchem.makerates.species.Species], reactions: list[uclchem.makerates.reaction.Reaction], user_defined_bulk: list = [], gas_phase_extrapolation: bool = False, add_crp_photo_to_grain: bool = False)[source]#

The network class stores all the information about reaction network.

A class to store network information such as indices of important reactions.

The class fully utilizes getters and setters, which can be used to add/remove reactions and the species involved. Important is that you do not directly edit the internal dictionaries that store the species and reactions, unless you know what you are doing. The network by default checks for duplicates in species and identical reactions that overlap in temperature ranges, potentially causing problems.

Parameters:
  • species (list[Species]) – A list of chemical species that are added to the network

  • reactions (list[Reaction]) – A list of chemical reactions that are added to the network

  • user_defined_bulk (list, optional) – List of user defined bulk. Defaults to [].

  • add_crp_photo_to_grain (bool, optional) – Whether to add CRP, CRPHOT and PHOTON reactions from gas-phase into solid phase too.

add_CRP_and_PHOTO_reactions_to_grain() None[source]#

Add all the gas-phase reactions with CRP, CRPHOT or PHOTON to the grain surface too

add_bulk_reactions() None[source]#

We assume any reaction that happens on the surface of grains can also happen in the bulk (just more slowly due to binding energy). The user therefore only lists surface reactions in their input reaction file and we duplicate here.

add_bulk_species() None[source]#

For three phase models, MakeRates will produce the version of the species in the bulk so that the user doesn’t have to endlessly relist the same species

add_chemdes_reactions() None[source]#

We have the user list all Langmuir-Hinshelwood and Eley-Rideal reactions once. Then we duplicate so that the reaction branches with products on grain and products desorbing.

add_desorb_reactions() None[source]#

Save the user effort by automatically generating desorption reactions

add_excited_surface_reactions() None[source]#

All excited species will relax to the ground state if they do not react the vibrational frequency of the species is used as a pseudo approximation of the rate coefficient We assume all grain reactions have an excited variant. For example: #A, #B LH #C will have the variants: #A*, #B EXSOLID #C and #A, #B* EXSOLID #C If only one of the reactants in the base reaction has an excited counterpart then only one excited version of that reaction is created.

add_freeze_reactions() None[source]#

Save the user effort by automatically generating freeze out reactions

add_gas_phase_extrapolation()[source]#
add_reactions(reactions: uclchem.makerates.reaction.Reaction | str | list[uclchem.makerates.reaction.Reaction | str])[source]#

Add a reaction, list of inputs to the Reaction class or list of reactions to the network.

Parameters:

reactions (Union[Union[Reaction, str], list[Union[Reaction, str]]]) – Reaction or list or reactions

add_species(species: uclchem.makerates.species.Species | str | list[uclchem.makerates.species.Species | str])[source]#

Add species to the network, given a (list of) species. If it is a list of strings, it tries to instantiate a species class with it. It also checks for duplicate entries and filters out attempts to add reaction types to the species.

Parameters:

species (Union[Union[Species, str], list[Union[Species, str]]]) – A (list of) species or strings.

Raises:
  • ValueError – If we cannot parse the (list of) reactions

  • ValueError – If an ice specie with binding energy of zero is added.

branching_ratios_checks() None[source]#

Check that the branching ratios for the ice reactions sum to 1.0. If they do not, correct them. This needs to be done for LH and LHDES separately since we already added the desorption to the network.

change_binding_energy(specie: str, new_binding_energy: float) None[source]#
change_reaction_barrier(reaction: uclchem.makerates.reaction.Reaction, barrier: float) None[source]#
check_and_filter_species() None[source]#

Check every speces in network appears in at least one reaction. Remove any that do not and alert user.

check_for_excited_species() bool[source]#

Check if there are any exicted species in the network, true if there are any.

check_freeze_and_desorbs() None[source]#

add_freeze_reactions() and add_desorb_reactions() automatically generate all desorption and freeze out reactions. However, user may want to change a species on freeze out eg C+ becomes #C rather than #C+. This function checks for that and updates species so they’ll freeze or desorb correctly when reactions are generated.

check_network() None[source]#

Run through the list of reactions and check for obvious errors such as duplicate reactions, multiple freeze out routes (to warn, not necessarily an error), etc.

duplicate_checks() None[source]#

Check reaction network to make sure no reaction appears twice unless they have different temperature ranges.

find_similar_reactions(reaction: uclchem.makerates.reaction.Reaction) dict[int, uclchem.makerates.reaction.Reaction][source]#

Reactions are similar if the reaction has the same reactants and products, find all reactions that are similar, returning their index and the reaction itself.

Parameters:

reaction (Reaction) – Reaction with possible identical (but for temperature range) reactions in the network

Returns:

A dict with the identical reactions.

Return type:

dict[int, Reaction]

freeze_checks() None[source]#

Check that every species freezes out and alert the user if a species freezes out via mutiple routes. This isn’t necessarily an error so best just print.

get_reaction(reaction_idx: int) uclchem.makerates.reaction.Reaction[source]#

Obtain a reaction from the reaction set given an index of the internal _reactions_dict.

Parameters:

reaction_idx (int) – The reaction index

Returns:

the desired reaction

Return type:

Reaction

get_reaction_dict() dict[int, uclchem.makerates.reaction.Reaction][source]#

Returns the whole internal reaction dictionary.

Returns:

A copy of the internal reactions dictionary.

Return type:

dict[int, Reaction]

get_reaction_index(reaction: uclchem.makerates.reaction.Reaction) int[source]#

Get the index of a reaction in the internal _reactions_dict.

Parameters:

reaction (Reaction) – The reaction to find the index of

Returns:

The index of the reaction in the internal _reactions_dict

Return type:

int

get_reaction_list() list[uclchem.makerates.reaction.Reaction][source]#

Obtain all the reactions in the Network.

Returns:

A list with all the reaction objects

Return type:

list[Reaction]

get_reactions_by_types(reaction_type: str | list[str]) list[uclchem.makerates.reaction.Reaction][source]#

Get the union of all reactions of a certain type.

Parameters:

reaction_type (str) – The reaction type to filter on

Returns:

A list of reactions of the specified type

Return type:

list[Reaction]

get_reactions_on_grain() list[uclchem.makerates.reaction.Reaction][source]#
get_specie(specie_name: str) uclchem.makerates.species.Species[source]#

Get the species of the reaction network (from the internal dictionary)

Parameters:

specie_name (str) – the name of the species as a string

Returns:

The species object

Return type:

Species

get_species_dict() dict[str, uclchem.makerates.species.Species][source]#

Get the internal dictionary that stores all the species, it consists of all species’ names as key, with the species object as value.

Returns:

A dictionary with the species

Return type:

dict[str, Species]

get_species_list() list[uclchem.makerates.species.Species][source]#

Obtain a list with all the species in the network

Returns:

A list of all the species in the reaction network

Return type:

list[Species]

index_important_reactions() None[source]#

We have a whole bunch of important reactions and we want to store their indices. We find them all here.

index_important_species() None[source]#

Obtain the indices for all the important reactions.

remove_reaction(reaction: uclchem.makerates.reaction.Reaction) None[source]#

Remove the reaction by giving the object itself, this only works if the reaction is not piecewise defined across the temperature ranges.

Parameters:

reaction (Reaction) – The reaction you wish to delete.

remove_reaction_by_index(reaction_idx: int) None[source]#

Remove a reaction by its index in the internal _reactions_dict, this is the only way to remove reactions that are defined piecewise across temperature ranges.

Parameters:

reaction_idx (int) – Index of the reaction to remove

remove_species(specie_name: str) None[source]#

Remove a specie from the network

Parameters:

specie_name (str) – Species to remove

set_reaction(reaction_idx: int, reaction: uclchem.makerates.reaction.Reaction) None[source]#

This setter explicitely sets the reaction for a certain index.

Parameters:
  • reaction_idx (int) – The index to be written to

  • reaction (Reaction) – The reaction to be added to the index.

set_reaction_dict(new_dict: dict[int, uclchem.makerates.reaction.Reaction]) None[source]#

Override the reactions dictionary with a new dictionar.

Parameters:

new_dict (dict[int, Reaction]) – The new reactions_dictionary.

set_specie(species_name: str, species: uclchem.makerates.species.Species) None[source]#

Set the species of the reaction network in the internal dictionary

Parameters:
  • species_name (str) – The name of the species as string

  • species (Species) – The Species object to set

set_species_dict(new_species_dict: dict[str, uclchem.makerates.species.Species]) None[source]#

Set the internal species dict

Parameters:

new_species_dict (dict[str, Species]) – The new dictionary to set

sort_reactions() None[source]#

Sort the reaction dictionary by reaction type first and by the first reactant second.

sort_species() None[source]#

Sort the species based on their mass in ascending order. We always make sure the Electron is last.

add_crp_photo_to_grain = False[source]#
excited_species = False[source]#
property reaction_list[source]#
property reactions[source]#
property species[source]#
property species_list[source]#
user_defined_bulk = [][source]#