forked from lijiext/lammps
whitespace cleanup
This commit is contained in:
parent
f1ee46cc64
commit
164537cf37
|
@ -5,7 +5,7 @@
|
|||
#
|
||||
# Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
# 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.
|
||||
#
|
||||
# See the README file in the top-level LAMMPS directory.
|
||||
|
@ -37,7 +37,7 @@ def get_ctypes_int(size):
|
|||
return c_int32
|
||||
elif size == 8:
|
||||
return c_int64
|
||||
return c_int
|
||||
return c_int
|
||||
|
||||
class MPIAbortException(Exception):
|
||||
def __init__(self, message):
|
||||
|
@ -47,7 +47,7 @@ class MPIAbortException(Exception):
|
|||
return repr(self.message)
|
||||
|
||||
class lammps(object):
|
||||
|
||||
|
||||
# detect if Python is using version of mpi4py that can pass a communicator
|
||||
|
||||
has_mpi4py = False
|
||||
|
@ -71,7 +71,7 @@ class lammps(object):
|
|||
|
||||
# if a pointer to a LAMMPS object is handed in,
|
||||
# all symbols should already be available
|
||||
|
||||
|
||||
try:
|
||||
if ptr: self.lib = CDLL("",RTLD_GLOBAL)
|
||||
except:
|
||||
|
@ -84,7 +84,7 @@ class lammps(object):
|
|||
# so that LD_LIBRARY_PATH does not need to be set for regular install
|
||||
# fall back to loading with a relative path,
|
||||
# typically requires LD_LIBRARY_PATH to be set appropriately
|
||||
|
||||
|
||||
if not self.lib:
|
||||
try:
|
||||
if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL)
|
||||
|
@ -110,15 +110,15 @@ class lammps(object):
|
|||
self.lib.lammps_gather_atoms.argtypes = \
|
||||
[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_concat.argtypes = \
|
||||
[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_subset.argtypes = \
|
||||
[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_scatter_atoms.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_scatter_atoms.restype = None
|
||||
|
@ -137,7 +137,7 @@ class lammps(object):
|
|||
# just convert it to ctypes ptr and store in self.lmp
|
||||
|
||||
if not ptr:
|
||||
|
||||
|
||||
# with mpi4py v2, can pass MPI communicator to LAMMPS
|
||||
# need to adjust for type of MPI communicator object
|
||||
# allow for int (like MPICH) or void* (like OpenMPI)
|
||||
|
@ -211,7 +211,7 @@ class lammps(object):
|
|||
self.c_imageint = get_ctypes_int(self.extract_setting("imageint"))
|
||||
|
||||
# shut-down LAMMPS instance
|
||||
|
||||
|
||||
def __del__(self):
|
||||
if self.lmp and self.opened:
|
||||
self.lib.lammps_close(self.lmp)
|
||||
|
@ -230,7 +230,7 @@ class lammps(object):
|
|||
self.lib.lammps_file(self.lmp,file)
|
||||
|
||||
# send a single command
|
||||
|
||||
|
||||
def command(self,cmd):
|
||||
if cmd: cmd = cmd.encode()
|
||||
self.lib.lammps_command(self.lmp,cmd)
|
||||
|
@ -250,13 +250,13 @@ class lammps(object):
|
|||
cmds = [x.encode() for x in cmdlist if type(x) is str]
|
||||
args = (c_char_p * len(cmdlist))(*cmds)
|
||||
self.lib.lammps_commands_list(self.lmp,len(cmdlist),args)
|
||||
|
||||
|
||||
# send a string of commands
|
||||
|
||||
def commands_string(self,multicmd):
|
||||
if type(multicmd) is str: multicmd = multicmd.encode()
|
||||
self.lib.lammps_commands_string(self.lmp,c_char_p(multicmd))
|
||||
|
||||
|
||||
# extract lammps type byte sizes
|
||||
|
||||
def extract_setting(self, name):
|
||||
|
@ -265,7 +265,7 @@ class lammps(object):
|
|||
return int(self.lib.lammps_extract_setting(self.lmp,name))
|
||||
|
||||
# extract global info
|
||||
|
||||
|
||||
def extract_global(self,name,type):
|
||||
if name: name = name.encode()
|
||||
if type == 0:
|
||||
|
@ -277,7 +277,7 @@ class lammps(object):
|
|||
return ptr[0]
|
||||
|
||||
# extract global info
|
||||
|
||||
|
||||
def extract_box(self):
|
||||
boxlo = (3*c_double)()
|
||||
boxhi = (3*c_double)()
|
||||
|
@ -286,11 +286,11 @@ class lammps(object):
|
|||
xz = c_double()
|
||||
periodicity = (3*c_int)()
|
||||
box_change = c_int()
|
||||
|
||||
|
||||
self.lib.lammps_extract_box(self.lmp,boxlo,boxhi,
|
||||
byref(xy),byref(yz),byref(xz),
|
||||
periodicity,byref(box_change))
|
||||
|
||||
|
||||
boxlo = boxlo[:3]
|
||||
boxhi = boxhi[:3]
|
||||
xy = xy.value
|
||||
|
@ -298,9 +298,9 @@ class lammps(object):
|
|||
xz = xz.value
|
||||
periodicity = periodicity[:3]
|
||||
box_change = box_change.value
|
||||
|
||||
|
||||
return boxlo,boxhi,xy,yz,xz,periodicity,box_change
|
||||
|
||||
|
||||
# extract per-atom info
|
||||
# NOTE: need to insure are converting to/from correct Python type
|
||||
# e.g. for Python list or NumPy or ctypes
|
||||
|
@ -318,7 +318,7 @@ class lammps(object):
|
|||
else: return None
|
||||
ptr = self.lib.lammps_extract_atom(self.lmp,name)
|
||||
return ptr
|
||||
|
||||
|
||||
@property
|
||||
def numpy(self):
|
||||
if not self._numpy:
|
||||
|
@ -371,7 +371,7 @@ class lammps(object):
|
|||
return self._numpy
|
||||
|
||||
# extract compute info
|
||||
|
||||
|
||||
def extract_compute(self,id,style,type):
|
||||
if id: id = id.encode()
|
||||
if type == 0:
|
||||
|
@ -466,7 +466,7 @@ class lammps(object):
|
|||
cboxlo = (3*c_double)(*boxlo)
|
||||
cboxhi = (3*c_double)(*boxhi)
|
||||
self.lib.lammps_reset_box(self.lmp,cboxlo,cboxhi,xy,yz,xz)
|
||||
|
||||
|
||||
# return vector of atom properties gathered across procs
|
||||
# 3 variants to match src/library.cpp
|
||||
# name = atom property recognized by LAMMPS in atom->extract()
|
||||
|
@ -475,7 +475,7 @@ class lammps(object):
|
|||
# returned data is a 1d vector - doc how it is ordered?
|
||||
# NOTE: need to insure are converting to/from correct Python type
|
||||
# e.g. for Python list or NumPy or ctypes
|
||||
|
||||
|
||||
def gather_atoms(self,name,type,count):
|
||||
if name: name = name.encode()
|
||||
natoms = self.lib.lammps_get_natoms(self.lmp)
|
||||
|
@ -487,7 +487,7 @@ class lammps(object):
|
|||
self.lib.lammps_gather_atoms(self.lmp,name,type,count,data)
|
||||
else: return None
|
||||
return data
|
||||
|
||||
|
||||
def gather_atoms_concat(self,name,type,count):
|
||||
if name: name = name.encode()
|
||||
natoms = self.lib.lammps_get_natoms(self.lmp)
|
||||
|
@ -519,7 +519,7 @@ class lammps(object):
|
|||
# assume data is of correct type and length, as created by gather_atoms()
|
||||
# NOTE: need to insure are converting to/from correct Python type
|
||||
# e.g. for Python list or NumPy or ctypes
|
||||
|
||||
|
||||
def scatter_atoms(self,name,type,count,data):
|
||||
if name: name = name.encode()
|
||||
self.lib.lammps_scatter_atoms(self.lmp,name,type,count,data)
|
||||
|
|
Loading…
Reference in New Issue