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 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d5e7a93
Minor: CI style modifications
alongd Jun 29, 2024
dc54715
Minor: Fixed typo in Arkane test
alongd Dec 28, 2024
792dd29
Minor: Removed debug print from species test
alongd Dec 28, 2024
a451308
Minor: Modifications to ARC's executable
alongd Dec 28, 2024
ca1dad9
Minor: Style modifications to mapping engine
alongd Dec 7, 2024
848659b
Removed RMG-Py and RMG-database repo paths from common
alongd Jul 1, 2024
6c1ff08
Relocated reaction into a sub module
alongd Jun 29, 2024
a69afa4
Added RMG_DB_PATH to settings
alongd Jul 2, 2024
e8aa9d3
Added clean_text() to common
alongd Jun 29, 2024
88961ec
Tests: common.clean_text()
alongd Jun 29, 2024
f49fe72
Added hydrolysis as an ARC reaction family
alongd Jul 2, 2024
4d724e9
Added the family module
alongd Jul 2, 2024
e936729
Tests: Added family tests
alongd Jul 2, 2024
e9340e8
Removed rmgdb from reaction
alongd Jul 2, 2024
3510c8a
Tests: Adaptations to reaction tests
alongd Jul 2, 2024
807d15f
Corrected import in arkane test
alongd Jul 2, 2024
c6463fd
Don't consider additional TS conformers if there's just one
alongd Jul 3, 2024
7fd0183
Removed the determine_family() function from the rmgdb module
alongd Jul 3, 2024
5e60880
Don't use RMGDatabase to determine reaction family
alongd Jul 3, 2024
90ac7d2
Tests: Removed RMGDatabase from tests
alongd Jul 3, 2024
f4f691d
Modifications to how reaction family is used in ARC
alongd Jul 3, 2024
d73970d
Make family a property of reaction
alongd Jul 3, 2024
7dbb9ca
Tests: Adaptations to ARC tests
alongd Jul 3, 2024
76cd409
Modifications to Scheduler
alongd Dec 7, 2024
0c33a3c
Removed the rmgdb module
alongd Dec 7, 2024
b07eccd
TMP: commented out NMD tests, they are dealt with in a different PR
alongd Dec 7, 2024
1f9b52d
TMP: Skip NMD in ts check, it is dealt with in a different PR
alongd Dec 7, 2024
2a35059
Removed unnecessary functions from mapping engine
alongd Dec 7, 2024
40e1564
Removed _check_r_n_p_symbols_between_rmg_and_arc_rxns from common
alongd Dec 28, 2024
e877082
Updated Heuristics TS search
alongd Dec 28, 2024
6f66a33
Removed rmgdb from main
alongd Dec 28, 2024
f3f96b7
Tests: Updated heuristics tests
alongd Dec 28, 2024
1f0c883
Modifications to mapping engine
alongd Dec 28, 2024
0f4ca27
Tests: Modifications to mapping engine tests
alongd Dec 28, 2024
6b6482d
Modifications to mapping driver
alongd Dec 28, 2024
919609b
Tests: Modifications to mapping driver tests
alongd Dec 28, 2024
b28b729
Tests: Modifications to reaction tests
alongd Dec 28, 2024
6ae8171
Added check_molecule_list_order() to species converter
alongd Dec 28, 2024
956aae3
Added RMG thermo and kinetics scripts
alongd Dec 28, 2024
0c0dde9
Modified the trype of the species rmg_thermo attribute
alongd Dec 28, 2024
a54aa17
Modified the type of the Reaction rmg_kinetics attribute
alongd Dec 28, 2024
e7ebf28
Updated processor to use RMG's scripts instead of RMG's API
alongd Dec 28, 2024
03e6bd4
Updated plotter for RMG's parsed data
alongd Dec 28, 2024
3d65d5e
Tests: Updated H atomtype in common tests to H0
alongd Dec 28, 2024
b74718b
Removed rmg_reaction from reaction
alongd Jan 5, 2025
001d1a1
Tests: Removed rmg_reaction from reaction tests
alongd Jan 5, 2025
7264cd1
Tests: Minor: Fix isotope SMILES in conformers tests
alongd Jan 5, 2025
80d3798
Removed utilization of .rmg_reaction from ARC's modules
alongd Jan 5, 2025
4ec241a
Todo: fix plotter
alongd Jan 5, 2025
01f3727
tmp cache
alongd Jan 5, 2025
5a46e58
f autotst ts
alongd Jan 8, 2025
dceeddb
tmp cache
alongd Jan 8, 2025
1e15036
f kinbot tst
alongd Jan 8, 2025
66bb36d
Check species type in Reaction
alongd Jan 8, 2025
fdc608a
f scripts
alongd Jan 8, 2025
26b73ea
Added calculate_arrhenius_rate_coefficient() to common
alongd Jan 8, 2025
ff5aca8
Tests: calculate_arrhenius_rate_coefficient
alongd Jan 8, 2025
2e35642
Updated plotter to use calculate_arrhenius_rate_coefficient()
alongd Jan 12, 2025
1cd0384
f common
alongd Jan 12, 2025
849425a
f plotter
alongd Jan 12, 2025
864a959
f processor
alongd Jan 12, 2025
87967bd
f reation
alongd Jan 12, 2025
4cfb517
TMP
alongd Jan 12, 2025
cb31f72
f rxn
alongd Jan 12, 2025
35cf72c
TMP
alongd Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .github/workflows/cont_int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
- name: Cache RMG-Py
id: cache-rmg-py
uses: actions/cache@v2
env:
CACHE_NUMBER: 2
with:
path: RMG-Py
key: ${{ runner.os }}-rmg-main
Expand All @@ -55,6 +57,8 @@ jobs:
- name: Cache RMG-database
id: cache-rmg-db
uses: actions/cache@v2
env:
CACHE_NUMBER: 2
with:
path: RMG-database
key: ${{ runner.os }}-rmgdb-main
Expand Down Expand Up @@ -102,7 +106,7 @@ jobs:
path: TS-GCN
ref: main
fetch-depth: 1

- name: Cache KinBot
id: cache-kinbot
uses: actions/cache@v2
Expand All @@ -129,7 +133,7 @@ jobs:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}

- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down Expand Up @@ -164,14 +168,14 @@ jobs:
echo 'export PATH=$PATH:'"$(pwd)" >> ~/.bashrc
make
cd ..

- name: Set ARC Path
run: |
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> $GITHUB_ENV
echo 'export PATH=$PATH:'"$(pwd)" >> $GITHUB_ENV
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> ~/.bashrc
echo 'export PATH=$PATH:'"$(pwd)" >> ~/.bashrc

- name: Install AutoTST
run: |
cd AutoTST
Expand All @@ -183,7 +187,7 @@ jobs:
# install pyaml
conda install -n tst_env -c conda-forge -y pyyaml
cd ..

- name: Install TS-GCN
run: |
cd TS-GCN
Expand All @@ -194,7 +198,7 @@ jobs:
bash devtools/create_env_cpu.sh
conda env update -n ts_gcn -f environment.yml
cd ..

- name: Install KinBot
run: |
cd KinBot
Expand All @@ -218,13 +222,13 @@ jobs:
- name: Install Torch Ani
run: |
conda env create -f devtools/tani_environment.yml

- name: Install XTB
run: |
conda env create -f devtools/xtb_environment.yml

- name: Test with pytest
shell: bash -el {0}
shell: bash -el {0}
run: |
source ~/.bashrc
conda activate arc_env
Expand All @@ -248,4 +252,4 @@ jobs:
flags: unittests
name: codecov-umbrella
verbose: true
fail_ci_if_error: false
fail_ci_if_error: false
4 changes: 1 addition & 3 deletions ARC.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def parse_command_line_arguments(command_line_args=None):
command_line_args: The command line arguments.

Returns:
The parsed command-line arguments by key words.
The parsed command-line arguments by keywords.
"""

parser = argparse.ArgumentParser(description='Automatic Rate Calculator (ARC)')
parser.add_argument('file', metavar='FILE', type=str, nargs=1,
help='a file describing the job to execute')
Expand All @@ -45,7 +44,6 @@ def main():
"""
The main ARC executable function
"""

args = parse_command_line_arguments()
input_file = args.file
project_directory = os.path.abspath(os.path.dirname(args.file))
Expand Down
2 changes: 2 additions & 0 deletions arc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import arc.utils

import arc.job
import arc.family
import arc.reaction
import arc.settings
import arc.species
import arc.statmech
79 changes: 3 additions & 76 deletions arc/checks/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import arc.rmgdb as rmgdb
from arc import parser
from arc.common import (ARC_PATH,
convert_list_index_0_to_1,
Expand All @@ -20,9 +19,6 @@
)
from arc.imports import settings
from arc.species.converter import check_xyz_dict, displace_xyz, xyz_to_dmat
from arc.mapping.engine import (get_atom_indices_of_labeled_atoms_in_an_rmg_reaction,
get_rmg_reactions_from_arc_reaction,
)
from arc.statmech.factory import statmech_factory

if TYPE_CHECKING:
Expand Down Expand Up @@ -300,73 +296,7 @@ def check_normal_mode_displacement(reaction: 'ARCReaction',
job (JobAdapter): The frequency job object instance.
amplitudes (Union[float, List[float]], optional): The factor(s) multiplication for the displacement.
"""
if job is None:
return
if reaction.family is None:
rmgdb.determine_family(reaction)
amplitudes = amplitudes or [0.1, 0.2, 0.4, 0.6, 0.8, 1]
amplitudes = [amplitudes] if isinstance(amplitudes, float) else amplitudes
reaction.ts_species.ts_checks['NMD'] = False
rmg_reactions = get_rmg_reactions_from_arc_reaction(arc_reaction=reaction) or list()
freqs, normal_modes_disp = parser.parse_normal_mode_displacement(path=job.local_path_to_output_file, raise_error=False)
if not len(normal_modes_disp):
return
largest_neg_freq_idx = get_index_of_abs_largest_neg_freq(freqs)
bond_lone_hs = any(len(spc.mol.atoms) == 2 and spc.mol.atoms[0].element.symbol == 'H'
and spc.mol.atoms[0].element.symbol == 'H' for spc in reaction.r_species + reaction.p_species)
# bond_lone_hs = False
xyz = parser.parse_xyz_from_file(job.local_path_to_output_file)
if not xyz['coords']:
xyz = reaction.ts_species.get_xyz()

done = False
for amplitude in amplitudes:
xyz_1, xyz_2 = displace_xyz(xyz=xyz, displacement=normal_modes_disp[largest_neg_freq_idx], amplitude=amplitude)
dmat_1, dmat_2 = xyz_to_dmat(xyz_1), xyz_to_dmat(xyz_2)
dmat_bonds_1 = get_bonds_from_dmat(dmat=dmat_1,
elements=xyz_1['symbols'],
tolerance=1.5,
bond_lone_hydrogens=bond_lone_hs)
dmat_bonds_2 = get_bonds_from_dmat(dmat=dmat_2,
elements=xyz_2['symbols'],
tolerance=1.5,
bond_lone_hydrogens=bond_lone_hs)
got_expected_changing_bonds = False
for i, rmg_reaction in enumerate(rmg_reactions):
r_label_dict = get_atom_indices_of_labeled_atoms_in_an_rmg_reaction(arc_reaction=reaction,
rmg_reaction=rmg_reaction)[0]
if r_label_dict is None:
continue
expected_breaking_bonds, expected_forming_bonds = reaction.get_expected_changing_bonds(r_label_dict=r_label_dict)
if expected_breaking_bonds is None or expected_forming_bonds is None:
continue
got_expected_changing_bonds = True
breaking = [determine_changing_bond(bond, dmat_bonds_1, dmat_bonds_2) for bond in expected_breaking_bonds]
forming = [determine_changing_bond(bond, dmat_bonds_1, dmat_bonds_2) for bond in expected_forming_bonds]
if len(breaking) and len(forming) \
and not any(entry is None for entry in breaking) and not any(entry is None for entry in forming) \
and all(entry == breaking[0] for entry in breaking) and all(entry == forming[0] for entry in forming) \
and breaking[0] != forming[0]:
reaction.ts_species.ts_checks['NMD'] = True
done = True
break
if not got_expected_changing_bonds and not reaction.ts_species.ts_checks['NMD']:
reaction.ts_species.ts_checks['warnings'] += 'Could not compare normal mode displacement to expected ' \
'breaking/forming bonds due to a missing RMG template; '
reaction.ts_species.ts_checks['NMD'] = True
break
if not len(rmg_reactions):
# Just check that some bonds break/form, and that this is not a torsional saddle point.
warning = f'Cannot check normal mode displacement for reaction {reaction} since a corresponding ' \
f'RMG template could not be generated'
logger.warning(warning)
reaction.ts_species.ts_checks['warnings'] += warning + '; '
if any(bond not in dmat_bonds_2 for bond in dmat_bonds_1) \
or any(bond not in dmat_bonds_1 for bond in dmat_bonds_2):
reaction.ts_species.ts_checks['NMD'] = True
break
if done:
break
reaction.ts_species.ts_checks['NMD'] = True


def determine_changing_bond(bond: Tuple[int, ...],
Expand Down Expand Up @@ -539,14 +469,11 @@ def get_rxn_normal_mode_disp_atom_number(rxn_family: Optional[str] = None,
if rms_list is not None \
and (not isinstance(rms_list, list) or not all(isinstance(entry, float) for entry in rms_list)):
raise TypeError(f'rms_list must be a non empty list, got {rms_list} of type {type(rms_list)}.')
family = rxn_family
if family is None and reaction is not None and reaction.family is not None:
family = reaction.family.label
if family is None:
if reaction.family is None:
logger.warning(f'Cannot deduce a reaction family for {reaction}, assuming {default} atoms in the reaction zone.')
return default
content = read_yaml_file(os.path.join(ARC_PATH, 'data', 'rxn_normal_mode_disp.yml'))
number_by_family = content.get(rxn_family, default)
number_by_family = content.get(rxn_family or reaction.family, default)
if rms_list is None or not len(rms_list):
return number_by_family
entry = None
Expand Down
Loading
Loading