Skip to content

Commit

Permalink
Update Q-Chem schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Dec 20, 2023
1 parent a4cad7e commit 67f2d93
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
14 changes: 6 additions & 8 deletions src/quacc/calculators/qchem/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import TYPE_CHECKING

from ase import units
from emmet.core.qc_tasks import TaskDoc
from emmet.core.tasks import _parse_custodian
from pymatgen.io.qchem.inputs import QCInput
from pymatgen.io.qchem.outputs import (
Expand Down Expand Up @@ -68,23 +69,20 @@ def read_qchem(directory: Path | str = ".") -> tuple[Results, list[float]]:
"""
directory = Path(directory)

qc_input = QCInput.from_file(directory / "mol.qin")
qc_output = QCOutput(directory / "mol.qout").data
task_doc = TaskDoc.from_directory(directory).model_dump()
qc_output = task_doc["output"]

results: Results = {
"energy": qc_output["final_energy"] * units.Hartree,
"qc_output": qc_output,
"qc_input": qc_input.as_dict(),
"taskdoc": task_doc,
"custodian": _parse_custodian(directory),
}

# Parse thermo properties
if "total_enthalpy" in qc_output:
results["enthalpy"] = qc_output["total_enthalpy"] * (units.kcal / units.mol)
results["enthalpy"] = qc_output["enthalpy"] * (units.kcal / units.mol)
if "total_entropy" in qc_output:
results["entropy"] = qc_output["total_entropy"] * (
0.001 * units.kcal / units.mol
)
results["entropy"] = qc_output["entropy"] * (0.001 * units.kcal / units.mol)

# Read the gradient scratch file in 8 byte chunks
grad_scratch = directory / "131.0"
Expand Down
3 changes: 1 addition & 2 deletions src/quacc/calculators/qchem/qchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class QChem(FileIOCalculator):
"hessian",
"enthalpy",
"entropy",
"qc_output",
"qc_input",
"taskdoc",
"custodian",
]
results: ClassVar[Results] = {}
Expand Down
10 changes: 5 additions & 5 deletions tests/core/calculators/qchem/test_qchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def test_qchem_read_results_freq(tmp_path, monkeypatch, test_atoms):
assert calc.prev_orbital_coeffs is not None
assert len(calc.results["hessian"]) == 42
assert len(calc.results["hessian"][0]) == 42
assert calc.results["qc_output"]["frequencies"][0] == -340.2
assert len(calc.results["qc_output"]["frequencies"]) == 36
assert len(calc.results["qc_output"]["frequency_mode_vectors"]) == 36
assert len(calc.results["qc_output"]["frequency_mode_vectors"][0]) == 14
assert len(calc.results["qc_output"]["frequency_mode_vectors"][0][0]) == 3
assert calc.results["taskdoc"]["output"]["frequencies"][0] == -340.2
assert len(calc.results["taskdoc"]["output"]["frequencies"]) == 36
assert len(calc.results["taskdoc"]["output"]["frequency_mode_vectors"]) == 36
assert len(calc.results["taskdoc"]["output"]["frequency_mode_vectors"][0]) == 14
assert len(calc.results["taskdoc"]["output"]["frequency_mode_vectors"][0][0]) == 3
4 changes: 2 additions & 2 deletions tests/core/recipes/qchem_recipes/test_qchem_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ def test_freq_job_v1(monkeypatch, tmp_path, test_atoms):
assert output["results"]["energy"] == pytest.approx(-605.6859554019 * units.Hartree)
assert output["results"].get("hessian") is not None
assert output["results"]["enthalpy"] == pytest.approx(
output["results"]["qc_output"]["total_enthalpy"] * (units.kcal / units.mol)
output["results"]["taskdoc"]["output"]["total_enthalpy"] * (units.kcal / units.mol)
)
assert (
output["results"]["entropy"]
== output["results"]["qc_output"]["total_entropy"]
== output["results"]["taskdoc"]["output"]["total_entropy"]
* 0.001
* units.kcal
/ units.mol
Expand Down

0 comments on commit 67f2d93

Please sign in to comment.