Skip to content

Commit

Permalink
Merge pull request #44 from GES-lbabetto/main
Browse files Browse the repository at this point in the history
code now takes nproc from OMP_NUM_THREADS if available
  • Loading branch information
lbabetto authored May 9, 2022
2 parents aecbfe1 + 9a68865 commit b32859d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 3 deletions.
9 changes: 9 additions & 0 deletions compechem/algorithms/oneeloxidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def calculate_deprotomers(
List containing all the deprotomers with pKa < 20 for the given molecule
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

mol_list = []

if conformer_search:
Expand Down Expand Up @@ -144,6 +147,9 @@ def generate_species(
Species object with the singlets and radicals for the given input molecule
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

species = Species()

molname = base_mol.name
Expand Down Expand Up @@ -250,6 +256,9 @@ def one_electron_oxidation_potentials(
pH_step: float = 1.0,
):

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

os.makedirs("pickle_files", exist_ok=True)

species = generate_species(
Expand Down
18 changes: 18 additions & 0 deletions compechem/calculators/crest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def tautomer_search(
list containing the found tautomers, in order of ascending energy
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

parent_dir = os.getcwd()
logger.info(f"{mol.name}, charge {mol.charge} spin {mol.spin} - CREST tautomer search")

Expand Down Expand Up @@ -102,6 +105,9 @@ def conformer_search(
list containing the found conformers, in order of ascending energy
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

parent_dir = os.getcwd()
logger.info(f"{mol.name}, charge {mol.charge} spin {mol.spin} - CREST conformer search")

Expand Down Expand Up @@ -170,6 +176,9 @@ def deprotonate(
list containing the found deprotomers, in order of ascending energy
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

parent_dir = os.getcwd()
logger.info(f"{mol.name}, charge {mol.charge} spin {mol.spin} - CREST deprotonation")

Expand Down Expand Up @@ -247,6 +256,9 @@ def protonate(
list containing the found protomers, in order of ascending energy
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

parent_dir = os.getcwd()
logger.info(f"{mol.name}, charge {mol.charge} spin {mol.spin} - CREST protonation")

Expand Down Expand Up @@ -341,6 +353,9 @@ def qcg_grow(
Molecule object containing the explicitly solvated input molecule
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

if charge is None:
charge = solute.charge
if spin is None:
Expand Down Expand Up @@ -434,6 +449,9 @@ def qcg_ensemble(
is taken as the weighted average of all generated ensembles.
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

if charge is None:
charge = solute.charge
if spin is None:
Expand Down
3 changes: 3 additions & 0 deletions compechem/calculators/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def __init__(
optional keywords, by default ""
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

self.method = method
self.basis_set = basis_set
self.aux_basis = aux_basis
Expand Down
3 changes: 3 additions & 0 deletions compechem/calculators/xtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def __init__(
optional keywords/flags, by default ""
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

self.method = method

self.nproc = nproc
Expand Down
5 changes: 4 additions & 1 deletion compechem/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def split_multixyz(mol: Molecule, file: str, suffix: str, charge: int = None, sp

def reorder_energies(
molecule_list: list,
nproc: int = 1,
nproc: int = len(os.sched_getaffinity(0)),
maxcore: int = 350,
method_opt: str = None,
method_el: str = None,
Expand Down Expand Up @@ -325,6 +325,9 @@ def reorder_energies(
molecule list, reordered at the new level of theory.
"""

if os.environ["OMP_NUM_THREADS"]:
nproc = int(os.environ["OMP_NUM_THREADS"])

if method_opt is None:
method_opt = XtbInput(nproc=nproc)
if method_el is None:
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "GES-comp-echem" %}
{% set version = "0.1.29a" %}
{% set version = "0.1.30a" %}



Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setuptools.setup(
name="GES-comp-echem",
version="0.1.29a",
version="0.1.30a",
description="",
long_description="",
packages=["compechem"],
Expand Down

0 comments on commit b32859d

Please sign in to comment.