-
Couldn't load subscription status.
- Fork 245
Merging Anna's changes from 'Pdep spin 39' to the main RMG branch #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b972628
650e116
15cdb8c
edc03c4
aac9a56
960dfb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -214,6 +214,32 @@ def copy(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def check_if_spin_allowed(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # get the combined spin for reactants and products | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reactants_combined_spin, products_combined_spin = self.calculate_combined_spin() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # check if there are any matches for combined spin between reactants and products | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if reactants_combined_spin.intersection(products_combined_spin) != set([]): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.debug(f"Reactants combined spin is {reactants_combined_spin}, but the products combined spin is {products_combined_spin}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.debug(f"Reactants combined spin is {reactants_combined_spin}, but the products combined spin is {products_combined_spin}") | |
| logging.debug(f"Reactants combined spin is {reactants_combined_spin}, and the products combined spin is {products_combined_spin}") |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns None for reactions with more than 2 reactants/products, but the caller may not handle this case properly. Consider raising an exception or documenting this limitation clearly.
| if len(self.reactants) == 1: | |
| reactant_combined_spin = {self.reactants[0].multiplicity} | |
| elif len(self.reactants) == 2: | |
| reactant_spin_string = "+".join(sorted([str(reactant.multiplicity) for reactant in self.reactants])) | |
| reactant_combined_spin = allowed_spin[reactant_spin_string] | |
| else: | |
| return None | |
| if len(self.products) == 1: | |
| product_combined_spin = {self.products[0].multiplicity} | |
| elif len(self.products) == 2: | |
| product_spin_string = "+".join(sorted([str(product.multiplicity) for product in self.products])) | |
| product_combined_spin = allowed_spin[product_spin_string] | |
| else: | |
| return None | |
| """ | |
| Calculate the combined spin multiplicities for reactants and products. | |
| This method supports reactions with up to two reactants and two products. | |
| If there are more than two reactants or products, a ValueError is raised. | |
| Returns: | |
| tuple: A tuple containing sets of combined spin multiplicities for reactants and products. | |
| Raises: | |
| ValueError: If there are more than two reactants or products. | |
| """ | |
| if len(self.reactants) == 1: | |
| reactant_combined_spin = {self.reactants[0].multiplicity} | |
| elif len(self.reactants) == 2: | |
| reactant_spin_string = "+".join(sorted([str(reactant.multiplicity) for reactant in self.reactants])) | |
| reactant_combined_spin = allowed_spin[reactant_spin_string] | |
| else: | |
| raise ValueError("calculate_combined_spin only supports up to two reactants.") | |
| if len(self.products) == 1: | |
| product_combined_spin = {self.products[0].multiplicity} | |
| elif len(self.products) == 2: | |
| product_spin_string = "+".join(sorted([str(product.multiplicity) for product in self.products])) | |
| product_combined_spin = allowed_spin[product_spin_string] | |
| else: | |
| raise ValueError("calculate_combined_spin only supports up to two products.") |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns None for reactions with more than 2 reactants/products, but the caller may not handle this case properly. Consider raising an exception or documenting this limitation clearly.
| if len(self.reactants) == 1: | |
| reactant_combined_spin = {self.reactants[0].multiplicity} | |
| elif len(self.reactants) == 2: | |
| reactant_spin_string = "+".join(sorted([str(reactant.multiplicity) for reactant in self.reactants])) | |
| reactant_combined_spin = allowed_spin[reactant_spin_string] | |
| else: | |
| return None | |
| if len(self.products) == 1: | |
| product_combined_spin = {self.products[0].multiplicity} | |
| elif len(self.products) == 2: | |
| product_spin_string = "+".join(sorted([str(product.multiplicity) for product in self.products])) | |
| product_combined_spin = allowed_spin[product_spin_string] | |
| else: | |
| return None | |
| """ | |
| Calculate the combined spin states for reactants and products. | |
| This method supports reactions with up to two reactants and two products. | |
| If there are more than two reactants or products, a ValueError is raised. | |
| Returns: | |
| tuple: A tuple containing the combined spin states for reactants and products. | |
| Raises: | |
| ValueError: If there are more than two reactants or products. | |
| """ | |
| if len(self.reactants) == 1: | |
| reactant_combined_spin = {self.reactants[0].multiplicity} | |
| elif len(self.reactants) == 2: | |
| reactant_spin_string = "+".join(sorted([str(reactant.multiplicity) for reactant in self.reactants])) | |
| reactant_combined_spin = allowed_spin[reactant_spin_string] | |
| else: | |
| raise ValueError("calculate_combined_spin only supports up to two reactants.") | |
| if len(self.products) == 1: | |
| product_combined_spin = {self.products[0].multiplicity} | |
| elif len(self.products) == 2: | |
| product_spin_string = "+".join(sorted([str(product.multiplicity) for product in self.products])) | |
| product_combined_spin = allowed_spin[product_spin_string] | |
| else: | |
| raise ValueError("calculate_combined_spin only supports up to two products.") | |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -311,7 +311,6 @@ def make_new_species(self, object, label="", reactive=True, check_existing=True, | |||||||||
| try: | ||||||||||
| mols = molecule.cut_molecule(cut_through=False) | ||||||||||
| except AttributeError: | ||||||||||
|
||||||||||
| except AttributeError: | |
| except AttributeError: | |
| # Convert the Molecule to a Fragment using its adjacency list. | |
| # This is necessary because the `cut_molecule` method is only available for Fragment objects. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -816,14 +816,6 @@ def update(self, reaction_model, pdep_settings, requires_rms=False): | |||||
| spec.conformer = Conformer(E0=spec.get_thermo_data().E0) | ||||||
| E0.append(spec.conformer.E0.value_si) | ||||||
|
|
||||||
| # Use the average E0 as the reference energy (`energy_correction`) for the network | ||||||
| # The `energy_correction` will be added to the free energies and enthalpies for each | ||||||
| # configuration in the network. | ||||||
| energy_correction = -np.array(E0).mean() | ||||||
| for spec in self.reactants + self.products + self.isomers: | ||||||
| spec.energy_correction = energy_correction | ||||||
| self.energy_correction = energy_correction | ||||||
|
|
||||||
| # Determine transition state energies on potential energy surface | ||||||
| # In the absence of any better information, we simply set it to | ||||||
| # be the reactant ground-state energy + the activation energy | ||||||
|
|
@@ -851,9 +843,9 @@ def update(self, reaction_model, pdep_settings, requires_rms=False): | |||||
| 'type "{2!s}".'.format(rxn, self.index, rxn.kinetics.__class__)) | ||||||
| rxn.fix_barrier_height(force_positive=True) | ||||||
| if rxn.network_kinetics is None: | ||||||
| E0 = sum([spec.conformer.E0.value_si for spec in rxn.reactants]) + rxn.kinetics.Ea.value_si + energy_correction | ||||||
| E0 = sum([spec.conformer.E0.value_si for spec in rxn.reactants]) + rxn.kinetics.Ea.value_si | ||||||
|
||||||
| E0 = sum([spec.conformer.E0.value_si for spec in rxn.reactants]) + rxn.kinetics.Ea.value_si | |
| E0 = sum([spec.conformer.E0.value_si for spec in rxn.reactants]) + rxn.kinetics.Ea.value_si |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace should be removed from this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
set()instead ofset([])for creating an empty set, or use the more Pythonicif reactants_combined_spin.intersection(products_combined_spin):.