Skip to content
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

Added a module for working with RMG reaction families #754

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

alongd
Copy link
Member

@alongd alongd commented Jul 2, 2024

Now we can identify for each ARC reaction all possible pathways between the reactants and products according to reaction families supported by RMG.
Also added dummy ARC families (w/o kinetics) to assist in identifying reaction templates.
Tests added.

arc/reaction/family_test.py Fixed Show fixed Hide fixed
arc/reaction/family_test.py Fixed Show fixed Hide fixed
arc/reaction/family.py Fixed Show fixed Hide fixed
arc/mapping/engine.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/driver.py Fixed Show fixed Hide fixed
arc/mapping/driver.py Fixed Show fixed Hide fixed
arc/mapping/engine.py Fixed Show fixed Hide fixed
arc/mapping/engine.py Fixed Show fixed Hide fixed
arc/reaction/family.py Fixed Show fixed Hide fixed
arc/reaction/reaction.py Fixed Show fixed Hide fixed
arc/reaction/reaction.py Fixed Show fixed Hide fixed
@alongd alongd force-pushed the reaction_families branch from 7d65d10 to 828dadd Compare December 7, 2024 17:33

if TYPE_CHECKING:
from arc.species import ARCSpecies
from arc.reaction.reaction import ARCReaction

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'ARCReaction' may not be defined if module
arc.reaction.reaction
is imported before module
arc.family.family
, as the
definition
of ARCReaction occurs after the cyclic
import
of arc.family.family.
arc/family/family.py Fixed Show fixed Hide fixed
arc/mapping/engine.py Fixed Show fixed Hide fixed
arc/mapping/engine.py Fixed Show fixed Hide fixed
from arc.common import get_logger
from arc.exceptions import ReactionError, InputError
from arc.family.family import ReactionFamily, get_reaction_family_products

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'ReactionFamily' may not be defined if module
arc.family.family
is imported before module
arc.reaction.reaction
, as the
definition
of ReactionFamily occurs after the cyclic
import
of arc.reaction.reaction.
from arc.common import get_logger
from arc.exceptions import ReactionError, InputError
from arc.family.family import ReactionFamily, get_reaction_family_products

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'get_reaction_family_products' may not be defined if module
arc.family.family
is imported before module
arc.reaction.reaction
, as the
definition
of get_reaction_family_products occurs after the cyclic
import
of arc.reaction.reaction.
@alongd alongd force-pushed the reaction_families branch 2 times, most recently from 6f59670 to ae816fc Compare December 7, 2024 22:18
Comment on lines +365 to +453
# def test_check_normal_mode_displacement(self):
# """Test the check_normal_mode_displacement() function."""
# self.rxn_2a.ts_species.populate_ts_checks()
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_intra_H_migration_CBS-QB3.out')
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertTrue(self.rxn_2a.ts_species.ts_checks['NMD'])
# self.rxn_2a.ts_species.populate_ts_checks()
#
# self.rxn_2b.ts_species.populate_ts_checks()
# self.assertFalse(self.rxn_2b.ts_species.ts_checks['NMD'])
# ts.check_normal_mode_displacement(reaction=self.rxn_2b, job=self.job1)
# self.assertFalse(self.rxn_2b.ts_species.ts_checks['NMD'])
#
# # Wrong TS for intra H migration [CH2]CC <=> C[CH]C
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_1.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_2.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_3.out') # ** The correct TS. **
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertTrue(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_4.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_5.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_6.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS_C3_intraH_7.out') # A wrong TS.
# self.rxn_2a.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'freq',
# 'TS_C3_intraH_8.out') # Correct TS (freq run, not composite).
# self.rxn_2a.ts_species.populate_ts_checks()
# self.assertFalse(self.rxn_2a.ts_species.ts_checks['NMD'])
# ts.check_normal_mode_displacement(reaction=self.rxn_2a, job=self.job1)
# self.assertTrue(self.rxn_2a.ts_species.ts_checks['NMD'])
#
# # CCO[O] + CC <=> CCOO + [CH2]C, incorrect TS:
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS0_composite_2043.out')
# self.rxn_4.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_4, job=self.job1)
# self.assertFalse(self.rxn_4.ts_species.ts_checks['NMD'])
#
# # CCO[O] + CC <=> CCOO + [CH2]C, correct TS:
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS0_composite_2102.out')
# self.rxn_4.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_4, job=self.job1)
# self.assertTrue(self.rxn_4.ts_species.ts_checks['NMD'])
#
# # NCC + H <=> CH3CHNH2 + H2, correct TS:
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'composite',
# 'TS0_composite_2044.out')
# self.rxn_5.ts_species.populate_ts_checks()
# ts.check_normal_mode_displacement(reaction=self.rxn_5, job=self.job1)
# self.assertTrue(self.rxn_5.ts_species.ts_checks['NMD'])
#
# # NH2 + N2H3 <=> NH + N2H4:
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'freq', 'TS_NH2+N2H3.out')
# rxn_6 = ARCReaction(r_species=[ARCSpecies(label='NH2', xyz="""N 0.00000000 -0.00000000 0.14115400

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +519 to +526
# def test_check_normal_mode_displacement_wip(self):
# """Test the check_normal_mode_displacement() function."""
# self.job1.local_path_to_output_file = os.path.join(ts.ARC_PATH, 'arc', 'testing', 'freq',
# 'TS_NH3+H=NH2+H2.out') # NH3 + H <=> NH2 + H2
# self.rxn_3.ts_species.populate_ts_checks()
# self.assertFalse(self.rxn_3.ts_species.ts_checks['NMD'])
# ts.check_normal_mode_displacement(reaction=self.rxn_3, job=self.job1)
# self.assertTrue(self.rxn_3.ts_species.ts_checks['NMD'])

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +633 to +652
# def test_get_expected_num_atoms_with_largest_normal_mode_disp(self):
# """Test the get_expected_num_atoms_with_largest_normal_mode_disp() function"""
# normal_disp_mode_rms = [0.01414213562373095, 0.05, 0.04, 0.5632938842203065, 0.7993122043357026,
# 0.08944271909999159, 0.10677078252031312, 0.09000000000000001, 0.05, 0.09433981132056604]
# num_of_atoms = ts.get_expected_num_atoms_with_largest_normal_mode_disp(normal_mode_disp_rms=normal_disp_mode_rms,
# ts_guesses=self.ts_1.ts_guesses)
# self.assertEqual(num_of_atoms, 4)

# def test_get_rxn_normal_mode_disp_atom_number(self):
# """Test the get_rxn_normal_mode_disp_atom_number() function."""
# with self.assertRaises(TypeError):
# ts.get_rxn_normal_mode_disp_atom_number('family', rms_list='family')
# with self.assertRaises(TypeError):
# ts.get_rxn_normal_mode_disp_atom_number('family', rms_list=['family'])
# with self.assertRaises(TypeError):
# ts.get_rxn_normal_mode_disp_atom_number('family', rms_list=15.215)
# self.assertEqual(ts.get_rxn_normal_mode_disp_atom_number(), 3)
# self.assertEqual(ts.get_rxn_normal_mode_disp_atom_number('default'), 3)
# self.assertEqual(ts.get_rxn_normal_mode_disp_atom_number('intra_H_migration'), 3)
# self.assertEqual(ts.get_rxn_normal_mode_disp_atom_number('intra_H_migration', rms_list=self.rms_list_1), 4)

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
arc/family/family.py Fixed Show fixed Hide fixed
arc/family/family_test.py Fixed Show fixed Hide fixed
arc/job/adapters/ts/heuristics.py Fixed Show fixed Hide fixed
arc/job/adapters/ts/heuristics_test.py Fixed Show fixed Hide fixed
arc/job/adapters/ts/heuristics_test.py Fixed Show fixed Hide fixed
arc/job/adapters/ts/heuristics_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/family/__init__.py Fixed Show fixed Hide fixed
arc/mapping/driver.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/mapping/engine_test.py Fixed Show fixed Hide fixed
arc/family/__init__.py Fixed Show fixed Hide fixed
xyz_1, xyz_2 = None, None
try:
xyz_1 = new_spc.get_xyz()
except:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
xyz_1, xyz_2 = None, None
try:
xyz_1 = new_spc.get_xyz()
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
pass
try:
xyz_2 = spc.get_xyz()
except:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
pass
try:
xyz_2 = spc.get_xyz()
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
Currently the rmgdb module is only used by processor which will be dealt with in a different PR
It is no longer an object, no need to call family.label
No need to call determine_family() since family is now a property of reaction
f! ts check (? replaced this function?)
to run RMG as standalone in its own env to get thermo and kinetics for comparisons
when comparing RMG's thermo and kinetics to ARC's computations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant