mirror of https://github.com/lammps/lammps.git
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15039 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
dfb0f528c0
commit
c3a95c782b
|
@ -2,16 +2,18 @@
|
|||
|
||||
# copy LAMMPS src/liblammps.so and lammps.py to system dirs
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
instructions = """
|
||||
Syntax: python install.py [-h] [pydir]
|
||||
pydir = target dir for lammps.py and liblammps.so
|
||||
default = Python site-packages dir
|
||||
"""
|
||||
|
||||
import sys,os,commands
|
||||
import sys,os,shutil
|
||||
|
||||
if (len(sys.argv) > 1 and sys.argv[1] == "-h") or len(sys.argv) > 2:
|
||||
print instructions
|
||||
print(instructions)
|
||||
sys.exit()
|
||||
|
||||
if len(sys.argv) == 2: pydir = sys.argv[1]
|
||||
|
@ -22,18 +24,24 @@ else: pydir = ""
|
|||
|
||||
if pydir:
|
||||
if not os.path.isdir(pydir):
|
||||
print "ERROR: pydir %s does not exist" % pydir
|
||||
print( "ERROR: pydir %s does not exist" % pydir)
|
||||
sys.exit()
|
||||
str = "cp ../python/lammps.py %s" % pydir
|
||||
print str
|
||||
outstr = commands.getoutput(str)
|
||||
if len(outstr.strip()): print outstr
|
||||
print(str)
|
||||
try:
|
||||
shutil.copyfile("../python/lammps.py", os.path.join(pydir,'lammps.py') )
|
||||
except shutil.Error:
|
||||
pass # source and destination are identical
|
||||
|
||||
str = "cp ../src/liblammps.so %s" % pydir
|
||||
print str
|
||||
outstr = commands.getoutput(str)
|
||||
print(str)
|
||||
try:
|
||||
shutil.copyfile("../src/liblammps.so", os.path.join(pydir,"liblammps.so") )
|
||||
except shutil.Error:
|
||||
pass # source and destination are identical
|
||||
sys.exit()
|
||||
|
||||
print "installing lammps.py in Python site-packages dir"
|
||||
print("installing lammps.py in Python site-packages dir")
|
||||
|
||||
os.chdir('../python') # in case invoked via make in src dir
|
||||
|
||||
|
@ -60,7 +68,7 @@ try:
|
|||
data_files = [(get_python_lib(), ["../src/liblammps.so"])])
|
||||
except:
|
||||
tryuser=True
|
||||
print "Installation into global site-packages dir failed.\nTrying user site dir %s now." % site.USER_SITE
|
||||
print ("Installation into global site-packages dir failed.\nTrying user site dir %s now." % site.USER_SITE)
|
||||
|
||||
|
||||
if tryuser:
|
||||
|
@ -75,7 +83,7 @@ if tryuser:
|
|||
py_modules = ["lammps"],
|
||||
data_files = [(site.USER_SITE, ["../src/liblammps.so"])])
|
||||
except:
|
||||
print "Installation into user site package dir failed.\nGo to ../python and install manually."
|
||||
print("Installation into user site package dir failed.\nGo to ../python and install manually.")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -125,12 +125,15 @@ class lammps:
|
|||
return self.lib.lammps_version(self.lmp)
|
||||
|
||||
def file(self,file):
|
||||
file = file.encode()
|
||||
self.lib.lammps_file(self.lmp,file)
|
||||
|
||||
def command(self,cmd):
|
||||
cmd = cmd.encode()
|
||||
self.lib.lammps_command(self.lmp,cmd)
|
||||
|
||||
def extract_global(self,name,type):
|
||||
name = name.encode()
|
||||
if type == 0:
|
||||
self.lib.lammps_extract_global.restype = POINTER(c_int)
|
||||
elif type == 1:
|
||||
|
@ -140,6 +143,7 @@ class lammps:
|
|||
return ptr[0]
|
||||
|
||||
def extract_atom(self,name,type):
|
||||
name = name.encode()
|
||||
if type == 0:
|
||||
self.lib.lammps_extract_atom.restype = POINTER(c_int)
|
||||
elif type == 1:
|
||||
|
@ -153,6 +157,7 @@ class lammps:
|
|||
return ptr
|
||||
|
||||
def extract_compute(self,id,style,type):
|
||||
id = id.encode()
|
||||
if type == 0:
|
||||
if style > 0: return None
|
||||
self.lib.lammps_extract_compute.restype = POINTER(c_double)
|
||||
|
@ -172,6 +177,7 @@ class lammps:
|
|||
# double was allocated by library interface function
|
||||
|
||||
def extract_fix(self,id,style,type,i=0,j=0):
|
||||
id = ide.encode()
|
||||
if style == 0:
|
||||
self.lib.lammps_extract_fix.restype = POINTER(c_double)
|
||||
ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j)
|
||||
|
@ -195,6 +201,8 @@ class lammps:
|
|||
# memory was allocated by library interface function
|
||||
|
||||
def extract_variable(self,name,group,type):
|
||||
name = name.encode()
|
||||
group = group.encode()
|
||||
if type == 0:
|
||||
self.lib.lammps_extract_variable.restype = POINTER(c_double)
|
||||
ptr = self.lib.lammps_extract_variable(self.lmp,name,group)
|
||||
|
@ -218,6 +226,8 @@ class lammps:
|
|||
# returns 0 for success, -1 if failed
|
||||
|
||||
def set_variable(self,name,value):
|
||||
name = name.encode()
|
||||
value = str(value).encode()
|
||||
return self.lib.lammps_set_variable(self.lmp,name,str(value))
|
||||
|
||||
# return total number of atoms in system
|
||||
|
@ -228,6 +238,7 @@ class lammps:
|
|||
# return vector of atom properties gathered across procs, ordered by atom ID
|
||||
|
||||
def gather_atoms(self,name,type,count):
|
||||
name = name.encode()
|
||||
natoms = self.lib.lammps_get_natoms(self.lmp)
|
||||
if type == 0:
|
||||
data = ((count*natoms)*c_int)()
|
||||
|
@ -242,4 +253,7 @@ class lammps:
|
|||
# assume vector is of correct type and length, as created by gather_atoms()
|
||||
|
||||
def scatter_atoms(self,name,type,count,data):
|
||||
name = name.encode()
|
||||
self.lib.lammps_scatter_atoms(self.lmp,name,type,count,data)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue