Skip to content

Commit

Permalink
Use lammps_create_atoms()
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen authored Jun 29, 2022
1 parent d49d6fb commit 9008cee
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pyiron_atomistics/lammps/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,32 @@ def interactive_structure_setter(self, structure):
self._interactive_lib_command(
"mass {0:3d} {1:f}".format(id_eam + 1, 1.00)
)
self._interactive_lib_command(
"create_atoms 1 random " + str(len(structure)) + " 12345 1"
)
positions = structure.positions.flatten()
if np.matrix.trace(self._prism.R) != 3:
positions = np.array(positions).reshape(-1, 3)
positions = np.matmul(positions, self._prism.R)
positions = positions.flatten()
elem_all = np.array([el_dict[el] for el in structure.get_chemical_elements()])
if self.server.run_mode.interactive and self.server.cores == 1:
self._interactive_library.scatter_atoms(
"x", 1, 3, (len(positions) * c_double)(*positions)
)
self._interactive_library.scatter_atoms(
"type", 0, 1, (len(elem_all) * c_int)(*elem_all)
self._interactive_library.create_atoms(
n=len(structure),
id=None,
type=(len(elem_all) * ctypes.c_int)(*elem_all),
x=(len(positions) * ctypes.c_double)(*positions),
v=None,
image=None,
shrinkexceed=False
)
else:
self._interactive_library.scatter_atoms("x", positions)
self._interactive_library.scatter_atoms("type", elem_all)
self._interactive_library.create_atoms(
n=len(structure),
id=None,
type=elem_all,
x=positions,
v=None,
image=None,
shrinkexceed=False
)
self._interactive_lib_command("change_box all remap")
self._interactive_lammps_input()
self._interactive_set_potential()
Expand Down

0 comments on commit 9008cee

Please sign in to comment.