Skip to content

Commit 0b8be98

Browse files
Andrew-S-Rosenpre-commit-ci[bot]janosh
authored
Support parsing of "final_energy" in Q-Chem 6.1.1 (#3580)
* Support parsing of "final_energy" in Q-Chem 6.1.1 * pre-commit auto-fixes * explain double read_pattern() in comment with ref to GH issue --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
1 parent 7e0c8f4 commit 0b8be98

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pymatgen/io/qchem/outputs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,13 @@ def __init__(self, filename: str):
327327
temp_dict = read_pattern(
328328
self.text,
329329
{"final_energy": r"\s*Total\s+energy in the final basis set\s+=\s*([\d\-\.]+)"},
330+
) or read_pattern( # support Q-Chem 6.1.1+ (gh-3580)
331+
self.text,
332+
{"final_energy": r"\s+Total energy\s+=\s+([\d\-\.]+)"},
330333
)
331334

332-
if temp_dict.get("final_energy") is not None:
333-
self.data["final_energy"] = float(temp_dict.get("final_energy")[-1][0])
335+
if e_final_match := temp_dict.get("final_energy"):
336+
self.data["final_energy"] = float(e_final_match[-1][0])
334337

335338
# Check if calculation is using dft_d and parse relevant info if so
336339
self.data["using_dft_d3"] = read_pattern(self.text, {"key": r"dft_d\s*= d3"}, terminate_on_match=True).get(

tests/files/qchem/6.1.1.wb97xv.out.gz

11.6 KB
Binary file not shown.

tests/io/qchem/test_outputs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
__maintainer__ = "Samuel Blau"
3232
__email__ = "samblau1@gmail.com"
3333

34-
single_job_dict = loadfn(os.path.join(os.path.dirname(__file__), "single_job.json"))
35-
multi_job_dict = loadfn(os.path.join(os.path.dirname(__file__), "multi_job.json"))
34+
module_dir = os.path.dirname(__file__)
35+
single_job_dict = loadfn(f"{module_dir}/single_job.json")
36+
multi_job_dict = loadfn(f"{module_dir}/multi_job.json")
3637

3738
property_list = {
3839
"errors",
@@ -522,6 +523,12 @@ def test_nbo_3_c(self):
522523
assert perturb_ene[0]["acceptor type"][723] == "3C*"
523524
assert perturb_ene[0]["perturbation energy"][3209] == 3.94
524525

526+
def test_qchem_6_1_1(self):
527+
qc_out = QCOutput(f"{TEST_FILES_DIR}/qchem/6.1.1.wb97xv.out.gz")
528+
assert qc_out.data["final_energy"] == -76.43205015
529+
n_vals = sum(1 for val in qc_out.data.values() if val is not None)
530+
assert n_vals == 21
531+
525532

526533
def test_gradient(tmp_path):
527534
with gzip.open(f"{TEST_FILES_DIR}/qchem/131.0.gz", "rb") as f_in, open(tmp_path / "131.0", "wb") as f_out:

0 commit comments

Comments
 (0)