Skip to content

Commit

Permalink
Add empirical scale factor to read_gamess (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
soranjh committed May 26, 2022
1 parent ab1dd50 commit 5db4fa4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions strawberryfields/apps/qchem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,30 @@ def duschinsky(
return U, delta


def read_gamess(file) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
def read_gamess(
file, scale_factor: float = 1.0
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
r"""Reads molecular data from the output file generated by the GAMESS quantum chemistry package
:cite:`schmidt1993general`.
This function extracts the atomic coordinates (r), atomic masses (m), vibrational frequencies
(w), and normal modes (l) of a molecule from the output file of a vibrational frequency
(w), and normal modes (n) of a molecule from the output file of a vibrational frequency
calculation performed with the GAMESS quantum chemistry package. The output file must contain
the results of a `RUNTYP=HESSIAN` calculation performed with GAMESS. We recommend checking the
output of this function with the GAMESS results to assure that the GAMESS output file is parsed
correctly.
correctly. Please also check if the normal modes are mass-weighted.
**Example usage:**
>>> r, m, w, l = read_gamess('../BH_data.out')
>>> r, m, w, n = read_gamess('../BH_data.out')
>>> r # atomic coordinates
array([[0.0000000, 0.0000000, 0.0000000],
[1.2536039, 0.0000000, 0.0000000]])
>>> m # atomic masses
array([11.00931, 1.00782])
>>> w # vibrational frequencies
array([19.74, 19.73, 0.00, 0.00, 0.00, 2320.32])
>>> l # normal modes
>>> n # normal modes
array([[-0.0000000e+00, -7.5322000e-04, -8.7276210e-02, 0.0000000e+00,
8.2280900e-03, 9.5339055e-01],
[-0.0000000e+00, -8.7276210e-02, 7.5322000e-04, 0.0000000e+00,
Expand All @@ -136,6 +138,7 @@ def read_gamess(file) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
Args:
file (str): path to the GAMESS output file
scale_factor: empirical scale factor for correcting the vibrational frequencies
Returns:
tuple[array, array, array, array]: atomic coordinates, atomic masses, normal mode
Expand All @@ -146,7 +149,7 @@ def read_gamess(file) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
r = []
m = []
w = []
l = []
n = []

for line in f:

Expand All @@ -172,7 +175,7 @@ def read_gamess(file) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
d = []
for _ in range(len(r) * 3):
d.append(f.readline().rstrip().split()[-n_mode:])
l.append(np.array(d, float).T)
n.append(np.array(d, float).T)

if not r:
raise ValueError("No atomic coordinates found in the output file")
Expand All @@ -186,8 +189,8 @@ def read_gamess(file) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
return (
np.concatenate(r).reshape(len(r), 3),
np.concatenate(m),
np.concatenate(w),
np.concatenate(l),
np.concatenate(w) * scale_factor,
np.concatenate(n),
)


Expand Down

0 comments on commit 5db4fa4

Please sign in to comment.