diff --git a/README.md b/README.md index 16f64aa..5ef4229 100644 --- a/README.md +++ b/README.md @@ -106,11 +106,12 @@ emle-server --backend torchani (The default backend is `torchani`.) -When using the `orca` backend, you will need to ensure that the _fake_ `orca` -executable takes precedence in the `PATH`. (To check that EMLE is running, -look for an `emle_log.txt` file in the working directory, where. The input -for `orca` will be taken from the `&orc` section of the `sander` configuration -file, so use this to specify the method, etc. +When using the `orca` backend, you will also need to specify the path to the +*real* `orca` exectubale using the `--orca-path` command-line argument, or the +`EMLE_ORCA_PATH` environment variable. (To check that EMLE is running, look for +an `emle_log.txt` file in the working directory, where. The input for `orca` will +be taken from the `&orc` section of the `sander` configuration file, so use this +to specify the method, etc. When using `deepmd` as the backend you will also need to specify a model file to use. This can be passed with the `--deepmd-model` command-line argument, diff --git a/bin/emle-server b/bin/emle-server index 656cdd8..37d8f19 100755 --- a/bin/emle-server +++ b/bin/emle-server @@ -89,6 +89,7 @@ except: interpolate_steps = None qm_indices = os.getenv("EMLE_QM_INDICES") sqm_theory = os.getenv("EMLE_SQM_THEORY") +orca_path = os.getenv("EMLE_ORCA_PATH") try: restart = strtobool(os.getenv("EMLE_RESTART")) except: @@ -127,6 +128,7 @@ env = { "parm7": parm7, "qm_indices": qm_indices, "sqm_theory": sqm_theory, + "orca_path": orca_path, "restart": restart, "orca_template": orca_template, "log": log, @@ -255,6 +257,12 @@ parser.add_argument( help="the semi-empirical theory to use for the QM region when using the SQM backend", required=False, ) +parser.add_argument( + "--orca-path", + type=str, + help="the path to the ORCA executable (required when using the ORCA backend)", + required=False, +) parser.add_argument( "--restart", action=argparse.BooleanOptionalAction, diff --git a/emle/calculator.py b/emle/calculator.py index 78a7b0d..ef89709 100644 --- a/emle/calculator.py +++ b/emle/calculator.py @@ -377,6 +377,7 @@ def __init__( rascal_model=None, parm7=None, qm_indices=None, + orca_path=None, sqm_theory="DFTB3", lambda_interpolate=None, interpolate_steps=None, @@ -455,6 +456,10 @@ def __init__( can be specified. The file should contain a single column with the indices being zero-based. + orca_path : str + The path to the ORCA executable. This is required when using the ORCA + backend. + sqm_theory : str The QM theory to use when using the SQM backend. See the AmberTools manual for the supported theory levels for your version of AmberTools. @@ -943,23 +948,19 @@ def __init__( # If the backend is ORCA, then try to find the executable. elif self._backend == "orca": - # Get the PATH for the environment. - path = _os.environ["PATH"] + if orca_path is None: + raise ValueError("'orca_path' must be specified when using the ORCA backend") + + if not isinstance(orca_path, str): + raise TypeError("'orca_path' must be of type 'str'") - # Search the PATH for a matching executable, ignoring any conda - # directories. + # Convert to an absolute path. + abs_orca_path = _os.path.abspath(orca_path) - exes = [] - for p in path.split(":"): - exe = _shutil.which("orca", path=p) - if exe and not ("conda" in exe or "mamba" in exe or "miniforge" in exe): - exes.append(exe) + if not _os.path.isfile(abs_orca_path): + raise IOError(f"Unable to locate ORCA executable: '{orca_path}'") - # Use the first executable. - if len(exes) > 0: - self._orca_exe = exes[0] - else: - raise OSError("Couldn't find ORCA executable for in vacuo backend!") + self._orca_path = abs_orca_path # Initialise the maximum number of MM atom that have been seen. self._max_mm_atoms = 0 @@ -984,6 +985,7 @@ def __init__( "rascal_model": rascal_model, "parm7": parm7, "qm_indices": None if qm_indices is None else self._qm_indices, + "orca_path": orca_path, "sqm_theory": sqm_theory, "lambda_interpolate": lambda_interpolate, "interpolate_steps": interpolate_steps, @@ -2577,7 +2579,7 @@ def _run_orca( _shutil.move(xyz_file_qm, xyz_name) # Create the ORCA command. - command = f"{self._orca_exe} {inp_name}" + command = f"{self._orca_path} {inp_name}" # Run the command as a sub-process. proc = _subprocess.run(