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#
Network version that skips all steps and just loads two lists. This is another |
|
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:
NetworkNetwork 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.
- 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_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.
- 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_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.
- 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.
- get_reaction_dict() dict[int, uclchem.makerates.reaction.Reaction][source]#
Returns the whole internal reaction dictionary.
- get_reaction_index(reaction: uclchem.makerates.reaction.Reaction) int[source]#
Get the index of a reaction in the internal _reactions_dict.
- get_reaction_list() list[uclchem.makerates.reaction.Reaction][source]#
Obtain all the reactions in the Network.
- 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.
- 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)
- 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.
- get_species_list() list[uclchem.makerates.species.Species][source]#
Obtain a list with all the species in the network
- 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.
- 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.
- set_reaction_dict(new_dict: dict[int, uclchem.makerates.reaction.Reaction]) None[source]#
Override the reactions dictionary with a new dictionar.
- set_specie(species_name: str, species: uclchem.makerates.species.Species) None[source]#
Set the species of the reaction network in the internal dictionary
- set_species_dict(new_species_dict: dict[str, uclchem.makerates.species.Species]) None[source]#
Set the internal species dict
- sort_reactions() None[source]#
Sort the reaction dictionary by reaction type first and by the first reactant second.