a few new lib interface methods
This commit is contained in:
@ -80,12 +80,59 @@ lmp.commands_list(cmds)
|
||||
# initial thermo should be same as step 20
|
||||
|
||||
natoms = lmp.get_natoms()
|
||||
type = natoms*[1]
|
||||
atype = natoms*[1]
|
||||
|
||||
lmp.command("delete_atoms group all");
|
||||
lmp.create_atoms(natoms,None,type,x,v);
|
||||
lmp.create_atoms(natoms,None,atype,x,v);
|
||||
lmp.command("run 10");
|
||||
|
||||
############
|
||||
# test of new gather/scatter and box extract/reset methods
|
||||
# can try this in parallel and with/without atom_modify sort enabled
|
||||
|
||||
lmp.command("write_dump all custom tmp.simple id type x y z fx fy fz");
|
||||
|
||||
x = lmp.gather_atoms("x",1,3)
|
||||
f = lmp.gather_atoms("f",1,3)
|
||||
|
||||
if me == 0: print("Gather XF:",x[3],x[9],f[3],f[9])
|
||||
|
||||
ids = lmp.gather_atoms_concat("id",0,1)
|
||||
x = lmp.gather_atoms_concat("x",1,3)
|
||||
f = lmp.gather_atoms_concat("f",1,3)
|
||||
|
||||
if me == 0: print("Gather concat XF:",ids[0],ids[1],x[0],x[3],f[0],f[3])
|
||||
|
||||
ids = (2*ctypes.c_int)()
|
||||
ids[0] = 2
|
||||
ids[1] = 4
|
||||
x = lmp.gather_atoms_subset("x",1,3,2,ids)
|
||||
f = lmp.gather_atoms_subset("f",1,3,2,ids)
|
||||
|
||||
if me == 0: print("Gather subset XF:",x[0],x[3],f[0],f[3])
|
||||
|
||||
x[0] = -1.0
|
||||
x[1] = 0.0
|
||||
x[2] = 0.0
|
||||
x[3] = -2.0
|
||||
x[4] = 0.0
|
||||
x[5] = 0.0
|
||||
ids[0] = 100
|
||||
ids[1] = 200
|
||||
lmp.scatter_atoms_subset("x",1,3,2,ids,x)
|
||||
|
||||
x = lmp.gather_atoms("x",1,3)
|
||||
if me == 0: print("Gather post scatter subset:",
|
||||
x[3],x[9],x[297],x[298],x[299],x[597],x[598],x[599])
|
||||
|
||||
boxlo,boxhi,xy,yz,xz,periodicity,box_change = lmp.extract_box()
|
||||
if me == 0: print("Box info",boxlo,boxhi,xy,yz,xz,periodicity,box_change)
|
||||
|
||||
lmp.reset_box([0,0,0],[10,10,8],0,0,0)
|
||||
|
||||
boxlo,boxhi,xy,yz,xz,periodicity,box_change = lmp.extract_box()
|
||||
if me == 0: print("Box info",boxlo,boxhi,xy,yz,xz,periodicity,box_change)
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user