Dear Sir,
The following code creates no atoms with scatter_atoms.
from lammps import lammps
import numpy as np
from ctypes import *
def main():
\# First creating a simple fcc system with lammps command
\# and noting down the atom positions
lmp = lammps\(cmdargs=\['\-log', 'none'\]\)
lmp\.command\('units metal'\)
lmp\.command\('atom\_style atomic'\)
lmp\.command\('boundary p p p'\)
lmp\.command\('atom\_modify map array'\)
lmp\.command\('lattice fcc 4 origin 0\.25 0\.25 0\.25'\)
lmp\.command\('region simul\_cell block \-2 2 \-2 2 \-2 2 units lattice'\)
lmp\.command\('create\_box 1 simul\_cell'\)
lmp\.command\('create\_atoms 1 box'\)
lmp\.command\('mass 1 1\.0'\)
lmp\.command\('write\_data atoms\_dump\.dat'\) \# this has 256 atoms as expected
atom\_pos = np\.array\(lmp\.gather\_atoms\('x', 1, 3\)\)\.reshape\(\-1,3\)
atom\_pos\_ctypes = \(3\*lmp\.get\_natoms\(\)\*c\_double\)\(\)
atom\_pos\_ctypes\[:\] = atom\_pos\.flatten\(\)
lmp\.close\(\)
\# Creating another system, this time with scatter\_atoms using the previously
\# saved atom positions
lmp = lammps\(cmdargs=\['\-log', 'none'\]\)
lmp\.command\('units metal'\)
lmp\.command\('atom\_style atomic'\)
lmp\.command\('boundary p p p'\)
lmp\.command\('atom\_modify map array'\)
lmp\.command\('region simul\_cell block \-8 8 \-8 8 \-8 8 units box'\)
lmp\.command\('create\_box 1 simul\_cell'\)
lmp\.scatter\_atoms\('x', 1, 3, atom\_pos\_ctypes\)
lmp\.command\('mass 1 1\.0'\)
lmp\.command\('write\_data atoms\_dump\_scatter\_atoms\.dat'\) \# this does not have any atoms
lmp\.close\(\)
if __name__ == '__main__':
main()
Please tell me know where I am doing wrong. I have also attached the two datafiles generated.
Best regards,
Shankha.
atoms_dump_scatter_atoms.dat (154 Bytes)
atoms_dump.dat (10.3 KB)