-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from pyiron/executor_test
Add executor test
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import unittest | ||
from ase.build import bulk | ||
from executorlib import Executor | ||
from executorlib.shared.executor import cloudpickle_register | ||
from pylammpsmpi import LammpsASELibrary | ||
|
||
|
||
def calc_lmp(structure): | ||
from mpi4py import MPI | ||
|
||
lmp = LammpsASELibrary( | ||
working_directory=None, | ||
cores=1, | ||
comm=MPI.COMM_SELF, | ||
logger=None, | ||
log_file=None, | ||
library=None, | ||
diable_log_file=True, | ||
) | ||
lmp.interactive_structure_setter( | ||
structure=structure, | ||
units="lj", | ||
dimension=3, | ||
boundary=" ".join(["p" if coord else "f" for coord in structure.pbc]), | ||
atom_style="atomic", | ||
el_eam_lst=["Al"], | ||
calc_md=False, | ||
) | ||
lmp.interactive_lib_command("pair_style lj/cut 6.0") | ||
lmp.interactive_lib_command("pair_coeff 1 1 1.0 1.0 4.04") | ||
lmp.interactive_lib_command( | ||
command="thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol" | ||
) | ||
lmp.interactive_lib_command(command="thermo_modify format float %20.15g") | ||
lmp.interactive_lib_command("run 0") | ||
return lmp.interactive_energy_pot_getter() | ||
|
||
|
||
class TestWithExecutor(unittest.TestCase): | ||
def test_executor(self): | ||
with Executor(max_cores=2, backend="local", hostname_localhost=True) as exe: | ||
cloudpickle_register(ind=1) | ||
future = exe.submit(calc_lmp, bulk("Al", cubic=True).repeat([2, 2, 2])) | ||
energy = future.result() | ||
self.assertAlmostEqual(energy, -0.04342932384411344) |