Skip to content

Commit

Permalink
Merge pull request #25 from pyiron/lammps_triclinic
Browse files Browse the repository at this point in the history
Lammps: Use change_box when switching from orthogonal box to triclini…
  • Loading branch information
jan-janssen committed Jan 22, 2021
2 parents c891995 + 3468bd0 commit bc4c321
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
32 changes: 26 additions & 6 deletions pyiron_atomistics/lammps/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,46 @@ def interactive_cells_setter(self, cell):
warnings.warn('set_relative() is deprecated as of 2020-02-26. It is not guaranteed from pyiron_atomistics vers. 0.3')

if is_skewed and is_scaled:
self._interactive_lib_command(
"change_box all triclinic"
)
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f \
xy final %f xz final %f yz final %f triclinic remap units box"
xy final %f xz final %f yz final %f remap units box"
% (lx, ly, lz, xy, xz, yz)
)
elif is_skewed and not is_scaled:
self._interactive_lib_command(
"change_box all triclinic"
)
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f \
xy final %f xz final %f yz final %f triclinic units box"
xy final %f xz final %f yz final %f units box"
% (lx, ly, lz, xy, xz, yz)
)
elif not is_skewed and is_scaled:
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f remap units box"
% (lx, ly, lz)
"change_box all triclinic"
)
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f \
xy final %f xz final %f yz final %f remap units box"
% (lx, ly, lz, 0.0, 0.0, 0.0)
)
self._interactive_lib_command(
"change_box all ortho"
)
else: # is neither skewed nor scaled
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f units box"
% (lx, ly, lz)
"change_box all triclinic"
)
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f \
xy final %f xz final %f yz final %f units box"
% (lx, ly, lz, 0.0, 0.0, 0.0)
)
self._interactive_lib_command(
"change_box all ortho"
)

def interactive_volume_getter(self):
Expand Down
10 changes: 9 additions & 1 deletion tests/lammps/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ def tearDownClass(cls):

def test_interactive_cells_setter(self):
self.job.interactive_cells_setter(np.eye(3))
self.assertEqual(
self.job._interactive_library._command[-3],
"change_box all triclinic",
)
self.assertEqual(
self.job._interactive_library._command[-2],
"change_box all x final 0 1.000000 y final 0 1.000000 z final 0 1.000000 xy final 0.000000 xz final 0.000000 yz final 0.000000 units box",
)
self.assertEqual(
self.job._interactive_library._command[-1],
"change_box all x final 0 1.000000 y final 0 1.000000 z final 0 1.000000 units box",
"change_box all ortho",
)

def test_interactive_positions_setter(self):
Expand Down

0 comments on commit bc4c321

Please sign in to comment.