Skip to content
Snippets Groups Projects
Commit 164537cf authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

whitespace cleanup

parent f1ee46cc
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# #
# Copyright (2003) Sandia Corporation. Under the terms of Contract # Copyright (2003) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under # certain rights in this software. This software is distributed under
# the GNU General Public License. # the GNU General Public License.
# #
# See the README file in the top-level LAMMPS directory. # See the README file in the top-level LAMMPS directory.
...@@ -37,7 +37,7 @@ def get_ctypes_int(size): ...@@ -37,7 +37,7 @@ def get_ctypes_int(size):
return c_int32 return c_int32
elif size == 8: elif size == 8:
return c_int64 return c_int64
return c_int return c_int
class MPIAbortException(Exception): class MPIAbortException(Exception):
def __init__(self, message): def __init__(self, message):
...@@ -47,7 +47,7 @@ class MPIAbortException(Exception): ...@@ -47,7 +47,7 @@ class MPIAbortException(Exception):
return repr(self.message) return repr(self.message)
class lammps(object): class lammps(object):
# detect if Python is using version of mpi4py that can pass a communicator # detect if Python is using version of mpi4py that can pass a communicator
has_mpi4py = False has_mpi4py = False
...@@ -71,7 +71,7 @@ class lammps(object): ...@@ -71,7 +71,7 @@ class lammps(object):
# if a pointer to a LAMMPS object is handed in, # if a pointer to a LAMMPS object is handed in,
# all symbols should already be available # all symbols should already be available
try: try:
if ptr: self.lib = CDLL("",RTLD_GLOBAL) if ptr: self.lib = CDLL("",RTLD_GLOBAL)
except: except:
...@@ -84,7 +84,7 @@ class lammps(object): ...@@ -84,7 +84,7 @@ class lammps(object):
# so that LD_LIBRARY_PATH does not need to be set for regular install # so that LD_LIBRARY_PATH does not need to be set for regular install
# fall back to loading with a relative path, # fall back to loading with a relative path,
# typically requires LD_LIBRARY_PATH to be set appropriately # typically requires LD_LIBRARY_PATH to be set appropriately
if not self.lib: if not self.lib:
try: try:
if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL) if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL)
...@@ -110,15 +110,15 @@ class lammps(object): ...@@ -110,15 +110,15 @@ class lammps(object):
self.lib.lammps_gather_atoms.argtypes = \ self.lib.lammps_gather_atoms.argtypes = \
[c_void_p,c_char_p,c_int,c_int,c_void_p] [c_void_p,c_char_p,c_int,c_int,c_void_p]
self.lib.lammps_gather_atoms.restype = None self.lib.lammps_gather_atoms.restype = None
self.lib.lammps_gather_atoms_concat.argtypes = \ self.lib.lammps_gather_atoms_concat.argtypes = \
[c_void_p,c_char_p,c_int,c_int,c_void_p] [c_void_p,c_char_p,c_int,c_int,c_void_p]
self.lib.lammps_gather_atoms_concat.restype = None self.lib.lammps_gather_atoms_concat.restype = None
self.lib.lammps_gather_atoms_subset.argtypes = \ self.lib.lammps_gather_atoms_subset.argtypes = \
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p] [c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
self.lib.lammps_gather_atoms_subset.restype = None self.lib.lammps_gather_atoms_subset.restype = None
self.lib.lammps_scatter_atoms.argtypes = \ self.lib.lammps_scatter_atoms.argtypes = \
[c_void_p,c_char_p,c_int,c_int,c_void_p] [c_void_p,c_char_p,c_int,c_int,c_void_p]
self.lib.lammps_scatter_atoms.restype = None self.lib.lammps_scatter_atoms.restype = None
...@@ -137,7 +137,7 @@ class lammps(object): ...@@ -137,7 +137,7 @@ class lammps(object):
# just convert it to ctypes ptr and store in self.lmp # just convert it to ctypes ptr and store in self.lmp
if not ptr: if not ptr:
# with mpi4py v2, can pass MPI communicator to LAMMPS # with mpi4py v2, can pass MPI communicator to LAMMPS
# need to adjust for type of MPI communicator object # need to adjust for type of MPI communicator object
# allow for int (like MPICH) or void* (like OpenMPI) # allow for int (like MPICH) or void* (like OpenMPI)
...@@ -211,7 +211,7 @@ class lammps(object): ...@@ -211,7 +211,7 @@ class lammps(object):
self.c_imageint = get_ctypes_int(self.extract_setting("imageint")) self.c_imageint = get_ctypes_int(self.extract_setting("imageint"))
# shut-down LAMMPS instance # shut-down LAMMPS instance
def __del__(self): def __del__(self):
if self.lmp and self.opened: if self.lmp and self.opened:
self.lib.lammps_close(self.lmp) self.lib.lammps_close(self.lmp)
...@@ -230,7 +230,7 @@ class lammps(object): ...@@ -230,7 +230,7 @@ class lammps(object):
self.lib.lammps_file(self.lmp,file) self.lib.lammps_file(self.lmp,file)
# send a single command # send a single command
def command(self,cmd): def command(self,cmd):
if cmd: cmd = cmd.encode() if cmd: cmd = cmd.encode()
self.lib.lammps_command(self.lmp,cmd) self.lib.lammps_command(self.lmp,cmd)
...@@ -250,13 +250,13 @@ class lammps(object): ...@@ -250,13 +250,13 @@ class lammps(object):
cmds = [x.encode() for x in cmdlist if type(x) is str] cmds = [x.encode() for x in cmdlist if type(x) is str]
args = (c_char_p * len(cmdlist))(*cmds) args = (c_char_p * len(cmdlist))(*cmds)
self.lib.lammps_commands_list(self.lmp,len(cmdlist),args) self.lib.lammps_commands_list(self.lmp,len(cmdlist),args)
# send a string of commands # send a string of commands
def commands_string(self,multicmd): def commands_string(self,multicmd):
if type(multicmd) is str: multicmd = multicmd.encode() if type(multicmd) is str: multicmd = multicmd.encode()
self.lib.lammps_commands_string(self.lmp,c_char_p(multicmd)) self.lib.lammps_commands_string(self.lmp,c_char_p(multicmd))
# extract lammps type byte sizes # extract lammps type byte sizes
def extract_setting(self, name): def extract_setting(self, name):
...@@ -265,7 +265,7 @@ class lammps(object): ...@@ -265,7 +265,7 @@ class lammps(object):
return int(self.lib.lammps_extract_setting(self.lmp,name)) return int(self.lib.lammps_extract_setting(self.lmp,name))
# extract global info # extract global info
def extract_global(self,name,type): def extract_global(self,name,type):
if name: name = name.encode() if name: name = name.encode()
if type == 0: if type == 0:
...@@ -277,7 +277,7 @@ class lammps(object): ...@@ -277,7 +277,7 @@ class lammps(object):
return ptr[0] return ptr[0]
# extract global info # extract global info
def extract_box(self): def extract_box(self):
boxlo = (3*c_double)() boxlo = (3*c_double)()
boxhi = (3*c_double)() boxhi = (3*c_double)()
...@@ -286,11 +286,11 @@ class lammps(object): ...@@ -286,11 +286,11 @@ class lammps(object):
xz = c_double() xz = c_double()
periodicity = (3*c_int)() periodicity = (3*c_int)()
box_change = c_int() box_change = c_int()
self.lib.lammps_extract_box(self.lmp,boxlo,boxhi, self.lib.lammps_extract_box(self.lmp,boxlo,boxhi,
byref(xy),byref(yz),byref(xz), byref(xy),byref(yz),byref(xz),
periodicity,byref(box_change)) periodicity,byref(box_change))
boxlo = boxlo[:3] boxlo = boxlo[:3]
boxhi = boxhi[:3] boxhi = boxhi[:3]
xy = xy.value xy = xy.value
...@@ -298,9 +298,9 @@ class lammps(object): ...@@ -298,9 +298,9 @@ class lammps(object):
xz = xz.value xz = xz.value
periodicity = periodicity[:3] periodicity = periodicity[:3]
box_change = box_change.value box_change = box_change.value
return boxlo,boxhi,xy,yz,xz,periodicity,box_change return boxlo,boxhi,xy,yz,xz,periodicity,box_change
# extract per-atom info # extract per-atom info
# NOTE: need to insure are converting to/from correct Python type # NOTE: need to insure are converting to/from correct Python type
# e.g. for Python list or NumPy or ctypes # e.g. for Python list or NumPy or ctypes
...@@ -318,7 +318,7 @@ class lammps(object): ...@@ -318,7 +318,7 @@ class lammps(object):
else: return None else: return None
ptr = self.lib.lammps_extract_atom(self.lmp,name) ptr = self.lib.lammps_extract_atom(self.lmp,name)
return ptr return ptr
@property @property
def numpy(self): def numpy(self):
if not self._numpy: if not self._numpy:
...@@ -371,7 +371,7 @@ class lammps(object): ...@@ -371,7 +371,7 @@ class lammps(object):
return self._numpy return self._numpy
# extract compute info # extract compute info
def extract_compute(self,id,style,type): def extract_compute(self,id,style,type):
if id: id = id.encode() if id: id = id.encode()
if type == 0: if type == 0:
...@@ -466,7 +466,7 @@ class lammps(object): ...@@ -466,7 +466,7 @@ class lammps(object):
cboxlo = (3*c_double)(*boxlo) cboxlo = (3*c_double)(*boxlo)
cboxhi = (3*c_double)(*boxhi) cboxhi = (3*c_double)(*boxhi)
self.lib.lammps_reset_box(self.lmp,cboxlo,cboxhi,xy,yz,xz) self.lib.lammps_reset_box(self.lmp,cboxlo,cboxhi,xy,yz,xz)
# return vector of atom properties gathered across procs # return vector of atom properties gathered across procs
# 3 variants to match src/library.cpp # 3 variants to match src/library.cpp
# name = atom property recognized by LAMMPS in atom->extract() # name = atom property recognized by LAMMPS in atom->extract()
...@@ -475,7 +475,7 @@ class lammps(object): ...@@ -475,7 +475,7 @@ class lammps(object):
# returned data is a 1d vector - doc how it is ordered? # returned data is a 1d vector - doc how it is ordered?
# NOTE: need to insure are converting to/from correct Python type # NOTE: need to insure are converting to/from correct Python type
# e.g. for Python list or NumPy or ctypes # e.g. for Python list or NumPy or ctypes
def gather_atoms(self,name,type,count): def gather_atoms(self,name,type,count):
if name: name = name.encode() if name: name = name.encode()
natoms = self.lib.lammps_get_natoms(self.lmp) natoms = self.lib.lammps_get_natoms(self.lmp)
...@@ -487,7 +487,7 @@ class lammps(object): ...@@ -487,7 +487,7 @@ class lammps(object):
self.lib.lammps_gather_atoms(self.lmp,name,type,count,data) self.lib.lammps_gather_atoms(self.lmp,name,type,count,data)
else: return None else: return None
return data return data
def gather_atoms_concat(self,name,type,count): def gather_atoms_concat(self,name,type,count):
if name: name = name.encode() if name: name = name.encode()
natoms = self.lib.lammps_get_natoms(self.lmp) natoms = self.lib.lammps_get_natoms(self.lmp)
...@@ -519,7 +519,7 @@ class lammps(object): ...@@ -519,7 +519,7 @@ class lammps(object):
# assume data is of correct type and length, as created by gather_atoms() # assume data is of correct type and length, as created by gather_atoms()
# NOTE: need to insure are converting to/from correct Python type # NOTE: need to insure are converting to/from correct Python type
# e.g. for Python list or NumPy or ctypes # e.g. for Python list or NumPy or ctypes
def scatter_atoms(self,name,type,count,data): def scatter_atoms(self,name,type,count,data):
if name: name = name.encode() if name: name = name.encode()
self.lib.lammps_scatter_atoms(self.lmp,name,type,count,data) self.lib.lammps_scatter_atoms(self.lmp,name,type,count,data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment