Skip to content

Commit

Permalink
Adapt parse_nd_scan_energies() to a slightly different Gaussian 2D sc…
Browse files Browse the repository at this point in the history
…an format (#777)

A test was added with a trimmed log file
  • Loading branch information
JintaoWu98 authored Dec 30, 2024
2 parents 6fda63e + 69bf820 commit 5518ed6
Show file tree
Hide file tree
Showing 3 changed files with 44,083 additions and 3 deletions.
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

0 comments on commit 5518ed6

Please sign in to comment.