Skip to content

Commit

Permalink
Add the workflow function
Browse files Browse the repository at this point in the history
  • Loading branch information
WardLT committed Dec 6, 2023
1 parent 18a0c6d commit bf4c431
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions jitterbug/parsl.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions tests/files/water.xyz
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/test_parsl.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bf4c431

Please sign in to comment.