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

Adapt parse_nd_scan_energies() to a slightly different Gaussian 2D scan format #777

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions arc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,17 @@ def parse_nd_scan_energies(path: str,

elif 'Summary of Optimized Potential Surface Scan' in line:
# ' Summary of Optimized Potential Surface Scan (add -264.0 to energies):'
base_e = float(line.split('(add ')[1].split()[0])
base_e = float(line.split('(add ')[1].split()[0]) if '(add' in line and 'to energies):' in line else 0.0
energies, dihedrals_dict = list(), dict()
dihedral_num = 0
while 'Grad' not in line:
while 'Grad' not in line and 'Largest change from initial coordinates' not in line:
line = f.readline()
splits = line.split()
numbers = re.findall(r'-?\d+\.\d+', line)
if 'Eigenvalues --' in line:
# convert Hartree energy to kJ/mol
energies = [(base_e + float(e)) * 4.3597447222071e-18 * 6.02214179e23 * 1e-3
for e in splits[2:]]
for e in numbers]
min_es = min(energies)
min_e = min_es if min_e is None else min(min_e, min_es)
dihedral_num = 0
Expand Down
8 changes: 8 additions & 0 deletions arc/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,14 @@ def test_parse_nd_scan_energies(self):
self.assertEqual(len(list(results[0]['directed_scan'].keys())), 36 * 36 + 1) # 1297
self.assertAlmostEqual(results[0]['directed_scan']['170.00', '40.00']['energy'], 26.09747088)

path2 = os.path.join(ARC_PATH, 'arc', 'testing', 'rotor_scans', 'scan_2D_N3H5.out')
results = parser.parse_nd_scan_energies(path=path2, software='gaussian')
self.assertEqual(results[0]['directed_scan_type'], 'ess_gaussian')
self.assertEqual(results[0]['scans'], [(1, 2, 3, 7), (4, 1, 2, 3)])
self.assertEqual(len(list(results[0].keys())), 3)
self.assertEqual(len(list(results[0]['directed_scan'].keys())), 45 * 45) # 2025
self.assertAlmostEqual(results[0]['directed_scan']['-38.33', '-65.67']['energy'], 27.01639591)

def test_parse_dipole_moment(self):
"""Test parsing the dipole moment from an opt job output file"""
path1 = os.path.join(ARC_PATH, 'arc', 'testing', 'composite', 'SO2OO_CBS-QB3.log')
Expand Down
Loading
Loading