From 6bfc975580b681b1fafbf5e3e3d39234a60e6884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20R=2E=20Sch=C3=A4fer?= Date: Thu, 23 Mar 2023 09:48:55 +0100 Subject: [PATCH 1/2] Added LJ singlepointnode --- ipsuite/calculators/__init__.py | 2 ++ ipsuite/calculators/lj.py | 29 +++++++++++++++++++++++ tests/unit_tests/calculators/__init__.py | 0 tests/unit_tests/calculators/test_u_lj.py | 23 ++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 ipsuite/calculators/lj.py create mode 100644 tests/unit_tests/calculators/__init__.py create mode 100644 tests/unit_tests/calculators/test_u_lj.py diff --git a/ipsuite/calculators/__init__.py b/ipsuite/calculators/__init__.py index 0be7165a..4d6e919e 100644 --- a/ipsuite/calculators/__init__.py +++ b/ipsuite/calculators/__init__.py @@ -1,6 +1,7 @@ from ipsuite.calculators.ase_geoopt import ASEGeoOpt from ipsuite.calculators.ase_md import ASEMD, FixedSphereASEMD from ipsuite.calculators.cp2k import CP2KSinglePoint, CP2KYaml +from ipsuite.calculators.lj import LJSinglePoint from ipsuite.calculators.xtb import xTBSinglePoint __all__ = [ @@ -10,4 +11,5 @@ "ASEMD", "FixedSphereASEMD", "xTBSinglePoint", + "LJSinglePoint", ] diff --git a/ipsuite/calculators/lj.py b/ipsuite/calculators/lj.py new file mode 100644 index 00000000..69673e07 --- /dev/null +++ b/ipsuite/calculators/lj.py @@ -0,0 +1,29 @@ +import tqdm +from ase.calculators.lj import LennardJones + +from ipsuite import base + + +class LJSinglePoint(base.ProcessAtoms): + """This is a testing Node! + It uses ASE'S Lennard-Jones calculator with default arguments. + The calculator accept all elements and implements energy, forces and stress, + making it very useful for creating dummy data. + """ + + def run(self): + self.atoms = self.get_data() + + calculator = self.calc + + for atom in tqdm.tqdm(self.atoms): + atom.calc = calculator + atom.get_potential_energy() + atom.get_stress() + + @property + def calc(self): + """Get an LJ ase calculator.""" + + calculator = LennardJones() + return calculator diff --git a/tests/unit_tests/calculators/__init__.py b/tests/unit_tests/calculators/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit_tests/calculators/test_u_lj.py b/tests/unit_tests/calculators/test_u_lj.py new file mode 100644 index 00000000..576457ca --- /dev/null +++ b/tests/unit_tests/calculators/test_u_lj.py @@ -0,0 +1,23 @@ +import pathlib +import shutil + +import ipsuite as ips + + +def test_lj_single_point(proj_path, traj_file): + traj_file = pathlib.Path(traj_file) + shutil.copy(traj_file, ".") + + with ips.Project() as project: + data = ips.AddData(file=traj_file.name) + + lj = ips.calculators.LJSinglePoint( + data=data.atoms, + ) + project.run() + + lj.load() + results = lj.atoms[0].calc.results + + assert "energy" in results.keys() + assert "forces" in results.keys() From 48c73a714c1ea6792ef835f2c5969fe2d6a7d0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20R=2E=20Sch=C3=A4fer?= Date: Thu, 23 Mar 2023 09:49:12 +0100 Subject: [PATCH 2/2] lint of geometry integration test --- tests/integration/test_i_geometry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_i_geometry.py b/tests/integration/test_i_geometry.py index 0ceb0a82..e4cc1f3d 100644 --- a/tests/integration/test_i_geometry.py +++ b/tests/integration/test_i_geometry.py @@ -1,7 +1,7 @@ -import pytest import numpy as np -from ase import Atoms import pytest +from ase import Atoms + import ipsuite as ips