From 0f88747f5110937732f3e8c81f9745784d43066d Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Wed, 23 Feb 2022 14:54:53 +0000 Subject: [PATCH] Psi4 minimum version check (#300) * change the default pre-opt method to xtb. Add a minimum version check to the mbis stage. * update channels * roll back pis4 version * update minimum version * remove mbis test --- devtools/conda-envs/basic.yaml | 1 + qubekit/charges/mbis.py | 19 ++++++++++++++++--- qubekit/workflow/helper_stages.py | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/devtools/conda-envs/basic.yaml b/devtools/conda-envs/basic.yaml index 26641455..2a8ede41 100644 --- a/devtools/conda-envs/basic.yaml +++ b/devtools/conda-envs/basic.yaml @@ -30,6 +30,7 @@ dependencies: - tqdm # Optional + - xtb-python - torchani - ambertools - optking \ No newline at end of file diff --git a/qubekit/charges/mbis.py b/qubekit/charges/mbis.py index 4e6df23f..c3a7615e 100644 --- a/qubekit/charges/mbis.py +++ b/qubekit/charges/mbis.py @@ -5,7 +5,8 @@ from typing import Any, Dict, Optional from pydantic import Field -from qcelemental.util import which_import +from qcelemental.util import parse_version, safe_version, which, which_import +from qcengine.util import popen from typing_extensions import Literal from qubekit.charges.base import ChargeBase @@ -13,6 +14,7 @@ from qubekit.engines import call_qcengine from qubekit.molecules import Dipole, Ligand, Quadrupole from qubekit.utils.datastructures import LocalResource, QCOptions +from qubekit.utils.exceptions import SpecificationError class MBISCharges(ChargeBase): @@ -32,12 +34,23 @@ def is_available(cls) -> bool: """ The MBIS option is only available via new psi4 so make sure it is installed. """ - return which_import( + # check installed + psi4 = which_import( "psi4", return_bool=True, raise_error=True, - raise_msg="Please install via `conda install psi4 -c psi4/label/dev`.", + raise_msg="Please install via `conda install psi4 -c psi4`.", ) + # now check the version meets the minimum requirement + which_psi4 = which("psi4") + with popen([which_psi4, "--version"]) as exc: + exc["proc"].wait(timeout=30) + version = parse_version(safe_version(exc["stdout"].split()[-1])) + if version <= parse_version("1.4a1"): + raise SpecificationError( + f"The version of psi4 installed is {version} and needs to be 1.4 or newer please update it to continue." + ) + return psi4 def _gas_calculation_settings(self) -> Dict[str, Any]: return {"scf_properties": ["MBIS_CHARGES"]} diff --git a/qubekit/workflow/helper_stages.py b/qubekit/workflow/helper_stages.py index d322c416..c72a6ebb 100644 --- a/qubekit/workflow/helper_stages.py +++ b/qubekit/workflow/helper_stages.py @@ -90,7 +90,7 @@ class Optimiser(StageBase): type: Literal["Optimiser"] = "Optimiser" pre_optimisation_method: Optional[PreOptMethods] = Field( - "uff", + "gfn2xtb", description="The pre-optimisation method that should be used before full QM.", ) seed_conformers: int = Field(