uclchem.makerates.reaction#
UCLCHEM Reaction.
Module Contents#
Classes#
Representation of reactions that are coupled to another Reaction instance. |
|
Representation of reactions. |
Functions#
|
Context manager to temporarily disable reaction validation. |
Attributes#
- class uclchem.makerates.reaction.CoupledReaction(input: list[str | float] | Reaction)[source]#
Bases:
ReactionRepresentation of reactions that are coupled to another Reaction instance.
This means that if a reaction has a parameter changed by, for example, network.change_binding_energy(), every CoupledReaction that has that instance as its partner also has its binding energy changed to that value.
Initialize the CoupledReaction.
- Parameters:
input (list[str | float] | Reaction) – Either a Reaction object to copy, or a list with reaction data.
- get_partner() Reaction | None[source]#
Get the partner.
- Returns:
partner of this reaction.
- Return type:
Reaction | None
- class uclchem.makerates.reaction.Reaction(input_row: list[str | float] | Reaction, reaction_source: str | None = None)[source]#
Representation of reactions.
Initialize a Reaction object.
- Parameters:
- Raises:
ValueError – If the length of input_row is not long enough.
- changes_surface_count() bool[source]#
Check whether a grain reaction changes number of particles on the surface.
2 reactants to 2 products won’t but two reactants combining to one will.
- Returns:
whether the number of ice molecules changes by this reaction.
- Return type:
- changes_total_mantle() bool[source]#
Check if the total grains on the mantle are changed by the reaction.
- Returns:
Whether the total ice abundance is affected by this reaction.
- Return type:
- check_charge_conservation() None[source]#
Check that the charge is conserved by this reaction.
Grain reactions don’t need to conserve charge, because grains can absorb/release electrons, so they are ignored.
- Raises:
ValueError – If charge is not conserved by the reaction.
- check_element_conservation() None[source]#
Check the conservation of elements.
- Raises:
ValueError – If the elements are not conserved by the reaction.
- check_temperature_collision(other: Reaction) bool[source]#
Check if two reactions have overlapping temperature ranges.
Returning True means there is a collision.
- Parameters:
other (Reaction) – Another reaction
- Returns:
Whether there is a collision (True), or not (False)
- Return type:
- Raises:
NotImplementedError – If other is not a Reaction instance. Currently we can only compare against instantiated Reaction objects.
- convert_gas_to_surf() None[source]#
Convert the gas-phase species to surface species in place for this reaction.
If any ions are produced, the ion is assumed to become neutral because it is on the surface. If any electrons are produced, they are assumed to be absorbed by the grain.
- convert_surf_to_bulk() None[source]#
Convert the surface species to bulk species in place for this reaction.
- generate_ode_bit(i: int, species_names: list[str]) None[source]#
Generate the ODE string of this reaction.
- get_alpha() float[source]#
Get the alpha parameter from the Kooij-Arrhenius equation.
- Returns:
the alpha parameter of the reaction
- Return type:
- get_beta() float[source]#
Get the beta parameter from the Kooij-Arrhenius equation.
- Returns:
the beta parameter of the reaction
- Return type:
- get_exothermicity() float[source]#
Get the cooling/heating for the reaction in erg s^-1.
- Returns:
the reaction enthalpy change
- Return type:
- get_extrapolation() bool[source]#
Get whether extrapolation is applied for this reaction.
- Returns:
whether extrapolation is applied.
- Return type:
- get_gamma() float[source]#
Get the gamma parameter from the Kooij-Arrhenius equation.
- Returns:
the gamma parameter of the reaction
- Return type:
- get_products() list[str][source]#
Get the four products present in the reaction,.
padded with NAN for nonexistent entries.
- get_pure_products() list[str][source]#
Get only the pure species that are products,.
no reaction types and NAN entries.
- get_pure_reactants() list[str][source]#
Get only the pure species, no reaction types and NAN entries.
- get_reactants() list[str][source]#
Get the four reactants present in the reaction,.
padded with NAN for nonexistent entries.
- get_reaction_type() str[source]#
Get the type of a reaction from the reactants.
First check the third reactant for a reaction type, then the second. If there are none in there, it will be regarded as a two body reaction.
- Returns:
reaction type
- Return type:
- get_reduced_mass() float[source]#
Get the reduced mass to be used to calculate tunneling rate in.
atomic mass units.
- Returns:
reduced mass of moving atoms
- Return type:
- get_sorted_products() list[str][source]#
Get the four products present in the reaction,.
sorted for fast comparisons.
- get_sorted_reactants() list[str][source]#
Get the four reactants present in the reaction,.
sorted for fast comparisons.
- get_source() str | None[source]#
Get the source of the reaction.
- Returns:
The source of the reaction
- Return type:
str | None
- get_temphigh() float[source]#
Get the higher temperature boundary of the reaction in Kelvin.
- Returns:
the higher temperature boundary
- Return type:
- get_templow() float[source]#
Get the lower temperature boundary of the reaction in Kelvin.
- Returns:
the lower temperature boundary
- Return type:
- is_bulk_reaction(include_reactants: bool = True, include_products: bool = True, strict: bool = False) bool[source]#
Check whether it is a bulk reaction. Defaults to non-strict since many.
important bulk reactions interact with the surface.
By default it is NOT strict (strict=False); any species in the bulk returns true If strict=True; all species must be on the ice phase
- is_gas_reaction(include_reactants: bool = True, include_products: bool = True, strict: bool = True) bool[source]#
Check whether it is a gas reaction. By default it is strict - all.
reactions must be in the gas-phase - if strict=False; any reaction in the gas-phase returns true.
- is_ice_reaction(include_reactants: bool = True, include_products: bool = True, strict: bool = True) bool[source]#
Check whether it is an ice (surface OR bulk) reaction.
By default it is strict (strict=True); all species must be in the ice phase If strict=False; any species in ice phase returns True
- is_surface_reaction(include_reactants: bool = True, include_products: bool = True, strict: bool = False) bool[source]#
Check whether it is a surface reaction. Defaults to non-strict since many.
important surface reactions can lead to desorption in some way.
By default it is NOT strict (strict=False); any species on the surface returns true If strict=True; all species must be on the ice phase
- predict_reduced_mass() None[source]#
Predict the reduced mass of the tunneling particle in this reaction.
This is used in the calculation of the tunneling rates.
Examples
>>> reaction = Reaction(["#CH3OH", "#H", "LH", "#CH3O", "#H2", "NAN", "NAN"] + [0] * 10) >>> # Setting a custom reduced mass >>> reaction.set_reduced_mass(20.0) >>> >>> # The custom reduced mass that we set. >>> reaction.get_reduced_mass() 20.0 >>> # Predicting the reduced mass of the reaction >>> reaction.predict_reduced_mass() >>> reaction.get_reduced_mass() 1.0
>>> # It is called upon Reaction instantiation >>> reaction = Reaction(["#CH3OH", "#OH", "LH", "#CH3O", "#H2O", "NAN", "NAN"] + [0] * 10) >>> reaction.get_reduced_mass() # mass of atomic hydrogen 1.0
- set_alpha(alpha: float) None[source]#
Set the alpha parameter from the Kooij-Arrhenius equation.
- Parameters:
alpha (float) – the alpha parameter of the reaction
- set_beta(beta: float) None[source]#
Set the beta parameter from the Kooij-Arrhenius equation.
- Parameters:
beta (float) – the beta parameter of the reaction
- set_exothermicity(rate: float) None[source]#
Set the cooling/heating for the reaction in erg s^-1.
- Parameters:
rate (float) – the reaction enthalpy change
- set_extrapolation(flag: bool) None[source]#
Set whether extrapolation is applied for this reaction.
- Parameters:
flag (bool) – whether extrapolation is applied.
- Raises:
AssertionError – If
flagis not a boolean.
- set_gamma(gamma: float) None[source]#
Set the gamma parameter from the Kooij-Arrhenius equation.
- Parameters:
gamma (float) – the gamma parameter of the reaction
- set_products(products: list[str]) None[source]#
Set the four products present in the reaction, padded with NAN for nonexistent entries.
- set_reactants(reactants: list[str]) None[source]#
Set the four reactants present in the reaction,.
padded with NAN for nonexistent entries.
- set_reduced_mass(reduced_mass: float) None[source]#
Set the reduced mass to be used to calculate tunneling rate in.
atomic mass units.
- Parameters:
reduced_mass (float) – reduced mass of moving atoms
- set_source(source: str) None[source]#
Set the source of the reaction.
- Parameters:
source (str) – The source of the reaction
- set_temphigh(temphigh: float) None[source]#
Set the higher temperature boundary of the reaction in Kelvin.
- Parameters:
temphigh (float) – the higher temperature boundary
- set_templow(templow: float) None[source]#
Set the lower temperature boundary of the reaction in Kelvin.
- Parameters:
templow (float) – the lower temperature boundary
- uclchem.makerates.reaction.skip_reaction_validation() collections.abc.Iterator[None][source]#
Context manager to temporarily disable reaction validation.
This is useful when loading pre-validated networks where you do not necessarily want to check element and charge conservation.
- Yields:
None – Control is yielded to the
withblock.
Examples
>>> with skip_reaction_validation(): ... reaction = Reaction(["#C2N", "LH", "NAN", "#CH3CNH", "NAN", "NAN", "NAN"]+ [0] * 10) >>> reaction = Reaction(["#C2N", "LH", "NAN", "#CH3CNH", "NAN", "NAN", "NAN"] + [0] * 10) Traceback (most recent call last): ... ValueError: Elements not conserved in a reaction. The following reaction caused this error: #C2N + LH -> #CH3CNH. ...