From c0f23c4918daf02dd0a16bab29552d9891f34c47 Mon Sep 17 00:00:00 2001 From: Corin Wagen Date: Mon, 1 Aug 2022 08:15:45 -0400 Subject: [PATCH] add ability to pass more flags to crest --- cctk/molecule.py | 7 ++++--- cctk/optimize.py | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cctk/molecule.py b/cctk/molecule.py index cba2cf6..2ccd3d3 100644 --- a/cctk/molecule.py +++ b/cctk/molecule.py @@ -1664,7 +1664,7 @@ def compute_energy(self, nprocs=1): energy = opt.get_energy(self, nprocs=nprocs) return energy - def csearch(self, nprocs=1, constraints=[], logfile=None, noncovalent=False, use_tempdir=True, gfn=2): + def csearch(self, nprocs=1, constraints=[], logfile=None, noncovalent=False, use_tempdir=True, gfn=2, additional_flags=None): """ Optimize molecule at the GFN2-xtb level of theory. @@ -1674,14 +1674,15 @@ def csearch(self, nprocs=1, constraints=[], logfile=None, noncovalent=False, use noncovalent (bool): whether or not to use non-covalent settings logfile (str): file to write ongoing ``crest`` output to use_tempdir (bool): write intermediate files to hidden directory (as opposed to current directory) - gfn (int or ``ff``): level of theory, either 1, 2, or ``ff``:w + gfn (int or ``ff``): level of theory, either 1, 2, or ``ff`` + additional_flags (str): additional flags for command line Returns ConformationalEnsemble """ import cctk.optimize as opt assert isinstance(nprocs, int), "nprocs must be int!" - return opt.csearch(molecule=self, nprocs=nprocs, constraints=constraints, noncovalent=noncovalent, logfile=logfile, use_tempdir=use_tempdir, gfn=gfn) + return opt.csearch(molecule=self, nprocs=nprocs, constraints=constraints, noncovalent=noncovalent, logfile=logfile, use_tempdir=use_tempdir, gfn=gfn, additional_flags=additional_flags) def num_neighbors_by_atom(self): """ diff --git a/cctk/optimize.py b/cctk/optimize.py index f4183e9..598119c 100644 --- a/cctk/optimize.py +++ b/cctk/optimize.py @@ -121,6 +121,7 @@ def csearch(use_tempdir=True, **kwargs): nprocs (int): number of processors to use noncovalent (Bool): whether or not to use non-covalent settings logfile (str): file to write ongoing ``crest`` output to + additional_flags (str): flags to pass to command line Returns: cctk.ConformationalEnsemble @@ -139,7 +140,7 @@ def csearch(use_tempdir=True, **kwargs): return ensemble -def _do_csearch(molecule, directory, gfn=2, nprocs=1, logfile=None, noncovalent=False, constraints=None): +def _do_csearch(molecule, directory, gfn=2, nprocs=1, logfile=None, noncovalent=False, constraints=None, additional_flags=None): assert isinstance(molecule, cctk.Molecule), "need a valid molecule!" assert isinstance(nprocs, int) assert isinstance(logfile, str) @@ -163,6 +164,9 @@ def _do_csearch(molecule, directory, gfn=2, nprocs=1, logfile=None, noncovalent= else: command = f"crest xtb-in.xyz --gfn{gfn} --chrg {molecule.charge} --uhf {molecule.multiplicity - 1} -T {nprocs} {nci}" + if additional_flags is not None: + command = command + " " + additional_flags + if logfile: with open(logfile, "w") as f: result = sp.run(command, stdout=f, stderr=f, cwd=directory, shell=True)