From bf4c43184714163a17ff023bc134c096d9d2092f Mon Sep 17 00:00:00 2001 From: Logan Ward Date: Wed, 6 Dec 2023 13:13:43 -0500 Subject: [PATCH] Add the workflow function --- jitterbug/parsl.py | 23 +++++++++++++++++++++++ tests/files/water.xyz | 5 +++++ tests/test_parsl.py | 8 ++++++++ 3 files changed, 36 insertions(+) create mode 100644 jitterbug/parsl.py create mode 100644 tests/files/water.xyz create mode 100644 tests/test_parsl.py diff --git a/jitterbug/parsl.py b/jitterbug/parsl.py new file mode 100644 index 0000000..117a951 --- /dev/null +++ b/jitterbug/parsl.py @@ -0,0 +1,23 @@ +"""Wrappers for functions compatible with the Parsl workflow engine""" +from typing import Optional + +import ase + +from jitterbug.utils import make_calculator + + +def get_energy(atoms: ase.Atoms, method: str, basis: Optional[str], **kwargs) -> float: + """Compute the energy of an atomic structure + + Keyword arguments are passed to :meth:`make_calculator`. + + Args: + atoms: Structure to evaluate + method: Name of the method to use (e.g., B3LYP) + basis: Basis set to use (e.g., cc-PVTZ) + Returns: + Energy (units: eV) + """ + + calc = make_calculator(method, basis, **kwargs) + return calc.get_potential_energy(atoms) diff --git a/tests/files/water.xyz b/tests/files/water.xyz new file mode 100644 index 0000000..1de00a3 --- /dev/null +++ b/tests/files/water.xyz @@ -0,0 +1,5 @@ +3 +Properties=species:S:1:pos:R:3:forces:R:3 energy=-2080.5785031368773 pbc="F F F" +O 2.53690888 -0.34072954 0.00000000 0.00346641 0.00474413 0.00000000 +H 3.29702983 0.24793463 0.00000000 0.00004343 -0.00355994 -0.00000000 +H 1.77686228 0.24789366 -0.00000000 -0.00350905 -0.00087620 0.00000000 diff --git a/tests/test_parsl.py b/tests/test_parsl.py new file mode 100644 index 0000000..364dd00 --- /dev/null +++ b/tests/test_parsl.py @@ -0,0 +1,8 @@ +from ase.io import read + +from jitterbug.parsl import get_energy + + +def test_energy(xyz_path): + atoms = read(xyz_path) + get_energy(atoms, 'pm7', None)