uclchem.makerates.network ========================= .. py:module:: uclchem.makerates.network .. autoapi-nested-parse:: 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 ~~~~~~~ .. autoapisummary:: uclchem.makerates.network.LoadedNetwork uclchem.makerates.network.Network .. py:class:: LoadedNetwork(species: list[uclchem.makerates.species.Species], reactions: list[uclchem.makerates.reaction.Reaction]) Bases: :py:obj:`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. :param Network: _description_ :type Network: _type_ A loader of networks without any checks. Here be dragons. :param species: A list of species objects :type species: list[Species] :param reactions: A list of reaction objects. :type reactions: list[Reaction] .. py:class:: 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) 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. :param species: A list of chemical species that are added to the network :type species: list[Species] :param reactions: A list of chemical reactions that are added to the network :type reactions: list[Reaction] :param user_defined_bulk: List of user defined bulk. Defaults to []. :type user_defined_bulk: list, optional :param add_crp_photo_to_grain: Whether to add CRP, CRPHOT and PHOTON reactions from gas-phase into solid phase too. :type add_crp_photo_to_grain: bool, optional .. py:method:: add_CRP_and_PHOTO_reactions_to_grain() -> None Add all the gas-phase reactions with CRP, CRPHOT or PHOTON to the grain surface too .. py:method:: add_bulk_reactions() -> None 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. .. py:method:: add_bulk_species() -> None 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 .. py:method:: add_chemdes_reactions() -> None 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. .. py:method:: add_desorb_reactions() -> None Save the user effort by automatically generating desorption reactions .. py:method:: add_excited_surface_reactions() -> None 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. .. py:method:: add_freeze_reactions() -> None Save the user effort by automatically generating freeze out reactions .. py:method:: add_gas_phase_extrapolation() .. py:method:: add_reactions(reactions: Union[Union[uclchem.makerates.reaction.Reaction, str], list[Union[uclchem.makerates.reaction.Reaction, str]]]) Add a reaction, list of inputs to the Reaction class or list of reactions to the network. :param reactions: Reaction or list or reactions :type reactions: Union[Union[Reaction, str], list[Union[Reaction, str]]] .. py:method:: add_species(species: Union[Union[uclchem.makerates.species.Species, str], list[Union[uclchem.makerates.species.Species, str]]]) 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. :param species: A (list of) species or strings. :type species: Union[Union[Species, str], list[Union[Species, str]]] :raises ValueError: If we cannot parse the (list of) reactions :raises ValueError: If an ice specie with binding energy of zero is added. .. py:method:: branching_ratios_checks() -> None 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. .. py:method:: change_binding_energy(specie: str, new_binding_energy: float) -> None .. py:method:: change_reaction_barrier(reaction: uclchem.makerates.reaction.Reaction, barrier: float) -> None .. py:method:: check_and_filter_species() -> None Check every speces in network appears in at least one reaction. Remove any that do not and alert user. .. py:method:: check_for_excited_species() -> bool Check if there are any exicted species in the network, true if there are any. .. py:method:: check_freeze_and_desorbs() -> None `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. .. py:method:: check_network() -> None 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. .. py:method:: duplicate_checks() -> None Check reaction network to make sure no reaction appears twice unless they have different temperature ranges. .. py:method:: find_similar_reactions(reaction: uclchem.makerates.reaction.Reaction) -> dict[int, uclchem.makerates.reaction.Reaction] 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. :param reaction: Reaction with possible identical (but for temperature range) reactions in the network :type reaction: Reaction :returns: A dict with the identical reactions. :rtype: dict[int, Reaction] .. py:method:: freeze_checks() -> None 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. .. py:method:: get_reaction(reaction_idx: int) -> uclchem.makerates.reaction.Reaction Obtain a reaction from the reaction set given an index of the internal _reactions_dict. :param reaction_idx: The reaction index :type reaction_idx: int :returns: the desired reaction :rtype: Reaction .. py:method:: get_reaction_dict() -> dict[int, uclchem.makerates.reaction.Reaction] Returns the whole internal reaction dictionary. :returns: A copy of the internal reactions dictionary. :rtype: dict[int, Reaction] .. py:method:: get_reaction_index(reaction: uclchem.makerates.reaction.Reaction) -> int Get the index of a reaction in the internal _reactions_dict. :param reaction: The reaction to find the index of :type reaction: Reaction :returns: The index of the reaction in the internal _reactions_dict :rtype: int .. py:method:: get_reaction_list() -> list[uclchem.makerates.reaction.Reaction] Obtain all the reactions in the Network. :returns: A list with all the reaction objects :rtype: list[Reaction] .. py:method:: get_reactions_by_types(reaction_type: Union[str, list[str]]) -> list[uclchem.makerates.reaction.Reaction] Get the union of all reactions of a certain type. :param reaction_type: The reaction type to filter on :type reaction_type: str :returns: A list of reactions of the specified type :rtype: list[Reaction] .. py:method:: get_reactions_on_grain() -> list[uclchem.makerates.reaction.Reaction] .. py:method:: get_specie(specie_name: str) -> uclchem.makerates.species.Species Get the species of the reaction network (from the internal dictionary) :param specie_name: the name of the species as a string :type specie_name: str :returns: The species object :rtype: Species .. py:method:: get_species_dict() -> dict[str, uclchem.makerates.species.Species] 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 :rtype: dict[str, Species] .. py:method:: get_species_list() -> list[uclchem.makerates.species.Species] Obtain a list with all the species in the network :returns: A list of all the species in the reaction network :rtype: list[Species] .. py:method:: index_important_reactions() -> None We have a whole bunch of important reactions and we want to store their indices. We find them all here. .. py:method:: index_important_species() -> None Obtain the indices for all the important reactions. .. py:method:: remove_reaction(reaction: uclchem.makerates.reaction.Reaction) -> None Remove the reaction by giving the object itself, this only works if the reaction is not piecewise defined across the temperature ranges. :param reaction: The reaction you wish to delete. :type reaction: Reaction .. py:method:: remove_reaction_by_index(reaction_idx: int) -> None 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. :param reaction_idx: Index of the reaction to remove :type reaction_idx: int .. py:method:: remove_species(specie_name: str) -> None Remove a specie from the network :param specie_name: Species to remove :type specie_name: str .. py:method:: set_reaction(reaction_idx: int, reaction: uclchem.makerates.reaction.Reaction) -> None This setter explicitely sets the reaction for a certain index. :param reaction_idx: The index to be written to :type reaction_idx: int :param reaction: The reaction to be added to the index. :type reaction: Reaction .. py:method:: set_reaction_dict(new_dict: dict[int, uclchem.makerates.reaction.Reaction]) -> None Override the reactions dictionary with a new dictionar. :param new_dict: The new reactions_dictionary. :type new_dict: dict[int, Reaction] .. py:method:: set_specie(species_name: str, species: uclchem.makerates.species.Species) -> None Set the species of the reaction network in the internal dictionary :param species_name: The name of the species as string :type species_name: str :param species: The Species object to set :type species: Species .. py:method:: set_species_dict(new_species_dict: dict[str, uclchem.makerates.species.Species]) -> None Set the internal species dict :param new_species_dict: The new dictionary to set :type new_species_dict: dict[str, Species] .. py:method:: sort_reactions() -> None Sort the reaction dictionary by reaction type first and by the first reactant second. .. py:method:: sort_species() -> None Sort the species based on their mass in ascending order. We always make sure the Electron is last. .. py:attribute:: add_crp_photo_to_grain :value: False .. py:attribute:: excited_species :value: False .. py:property:: reaction_list .. py:property:: reactions .. py:property:: species .. py:property:: species_list .. py:attribute:: user_defined_bulk :value: []