Skip to content

Commit

Permalink
Revert custodian subprocess in Q-Chem (#1844)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Andrew-S-Rosen and pre-commit-ci[bot] authored Mar 6, 2024
1 parent 227379a commit 5eabc19
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/quacc/calculators/qchem/qchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

from __future__ import annotations

import inspect
import sys
from pathlib import Path
from typing import TYPE_CHECKING

from ase.calculators.calculator import FileIOCalculator

from quacc.calculators.qchem import qchem_custodian
from quacc.calculators.qchem.io import read_qchem, write_qchem
from quacc.calculators.qchem.params import cleanup_attrs, make_qc_input
from quacc.calculators.qchem.qchem_custodian import run_custodian
Expand Down Expand Up @@ -241,11 +245,14 @@ def __init__(
# Set default params
self._set_default_params()

# Get Q-Chem executable command
command = self._manage_environment()

# Instantiate the calculator
super().__init__(
restart=None,
label=None,
command="",
command=command,
atoms=self.atoms,
profile=None,
**self.fileiocalculator_kwargs,
Expand Down Expand Up @@ -306,6 +313,19 @@ def read_results(self) -> None:
self.results = results
self.prev_orbital_coeffs = prev_orbital_coeffs

@staticmethod
def _manage_environment() -> str:
"""
Return the command to run the Q-Chem calculator via Custodian.
Returns
-------
str
The command flag to run Q-Chem with Custodian.
"""

qchem_custodian_script = Path(inspect.getfile(qchem_custodian)).resolve()
return f"{sys.executable} {qchem_custodian_script}"

def _set_default_params(self) -> None:
"""
Store the parameters that have been passed to the Q-Chem calculator in
Expand Down

0 comments on commit 5eabc19

Please sign in to comment.