Skip to content

Commit

Permalink
Make ORCA executable path an explicit option.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Jan 19, 2024
1 parent e5f6032 commit 5d531a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions bin/emle-server
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 17 additions & 15 deletions emle/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5d531a4

Please sign in to comment.