Skip to content

Commit

Permalink
mod: factored out Gaussian16.parse_all_energies
Browse files Browse the repository at this point in the history
  • Loading branch information
eljost authored and Johannes Steinmetzer committed Mar 11, 2024
1 parent 5141406 commit 051238e
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions pysisyphus/calculators/Gaussian16.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ def parse_ci_coeffs(text, restricted_same_ab=False):
return Xa, Ya, Xb, Yb


def noparse(path):
return dict()


@file_or_str(".fchk")
def parse_all_energies(text):
float_ = r"([\d\-\+Ee\.]+)"
gs_re = re.compile(r"SCF Energy\s+R\s+" + float_)
gs_mobj = gs_re.search(text)
gs_energy = float(gs_mobj[1])
# cis_re = re.compile(r"CIS Energy\s+R\s+" + float_)
# cis_mobj = cis_re.search(text)
# cis_energy = float(cis_mobj[1])
etrans_re = re.compile(
r"ETran state values\s+R\s+N=\s+(\d+)([\d\-\.Ee\+\s]+)", re.DOTALL
)
etrans_mobj = etrans_re.search(text)
try:
etrans = etrans_mobj[2].strip().split()
etrans = np.array(etrans, dtype=float).reshape(-1, 16)
exc_energies = etrans[:, 0]
all_energies = np.zeros(exc_energies.size + 1)
all_energies[0] = gs_energy
all_energies[1:] = exc_energies
except TypeError:
all_energies = np.array((gs_energy,))
return all_energies


class Gaussian16(OverlapCalculator):
conf_key = "gaussian16"
_set_plans = (
Expand Down Expand Up @@ -215,7 +244,7 @@ def __init__(
"force": self.parse_force,
"hessian": self.parse_hessian,
"stable": self.parse_stable,
"noparse": lambda path: None,
"noparse": noparse,
"double_mol": self.parse_double_mol,
}

Expand Down Expand Up @@ -538,8 +567,7 @@ def run_calculation(self, atoms, coords, **prepare_kwargs):
self.store_overlap_data(atoms, coords)
self.track_root()
self.log(
"This track_root() call is a bit superfluous as the "
"as the result is ignored :)"
"This track_root() call is a bit superfluous as the result is ignored."
)
return results

Expand Down

0 comments on commit 051238e

Please sign in to comment.