Merge branch 'master' into lammps-icms

Resolved Conflicts:
	python/lammps.py
	src/MAKE/Makefile.mingw
	src/MAKE/Makefile.openmpi
	src/MAKE/Makefile.serial
	src/MAKE/Makefile.serial_debug
	src/USER-CUDA/verlet_cuda.cpp
This commit is contained in:
Axel Kohlmeyer
2012-08-14 03:35:29 -04:00
117 changed files with 2365 additions and 1679 deletions

View File

@ -1,26 +1,48 @@
This directory contains Python code which wraps LAMMPS as a library
and allows the library interface to be invoked from a Python, either
from a script or interactively.
and allows the LAMMPS library interface to be invoked from Python,
either from a script or interactively.
Details on how to build and use this Python interface are given in
Details on the Python interface to LAMMPS and how to build LAMMPS as a
shared library for use with Python are given in
doc/Section_python.html.
Basically you have to extend the Python on your box to include the
LAMMPS wrappers:
Basically you need to follow these 3 steps:
python setup_serial.py build # for serial LAMMPS and Python
sudo python setup_serial.py install
a) Add paths to environment variables in your shell script
python setup.py build # for parallel LAMMPS and Python
sudo python setup.py install
For example, for csh or tcsh, add something like this to ~/.cshrc:
but there are several issues to be aware of, as discussed in the doc
pages.
setenv PYTHONPATH ${PYTHONPATH}:/home/sjplimp/lammps/python
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src/STUBS
The latter is only necessary if you will use the MPI stubs library
instead of an MPI installed on your machine.
b) Build LAMMPS as a dynamic library, including dynamic versions of
any libraries it includes for the packages you have installed,
e.g. STUBS, MPI, FFTW, JPEG, package libs.
From the src directory:
% make makeshlib
% make -f Makefile.shlib g++
If successful, this results in the file src/liblmp_g++.so
c) Launch Python and import the LAMMPS wrapper
% python
>>> from lammps import lammps
>>> lmp = lammps()
If that gives no errors, you have succesfully wrapped LAMMPS with
Python.
-------------------------------------------------------------------
Once you have successfully built and tested the wrappers, you can run
the Python scripts in the examples sub-directory:
Once you have successfully wrapped LAMMPS, you can run the Python
scripts in the examples sub-directory:
trivial.py read/run a LAMMPS input script thru Python
demo.py invoke various LAMMPS library interface routines

View File

@ -26,28 +26,26 @@ LMPDPTRPTR = 4
LOCATION = os.path.dirname(__file__)
class lammps:
def __init__(self,args=None):
def __init__(self,name="",cmdlineargs=None):
# attempt to load parallel library first, serial library next
# could provide caller a flag to choose which library to load
# load liblmp.so by default
# if name = "g++", load liblmp_g++.so
try:
self.lib = CDLL(os.path.join(LOCATION, "_lammps.so"))
if not name: self.lib = CDLL("liblmp.so")
else: self.lib = CDLL("liblmp_%s.so" % name)
except:
try:
self.lib = CDLL(os.path.join(LOCATION, "_lammps_serial.so"))
except:
raise OSError,"Could not load LAMMPS dynamic library"
raise OSError,"Could not load LAMMPS dynamic library"
# create an instance of LAMMPS
# don't know how to pass an MPI communicator from PyPar
# no_mpi call lets LAMMPS use MPI_COMM_WORLD
# cargs = array of C strings from args
if args:
args.insert(0,"lammps.py")
narg = len(args)
cargs = (c_char_p*narg)(*args)
if cmdlineargs:
cmdlineargs.insert(0,"lammps.py")
narg = len(cmdlineargs)
cargs = (c_char_p*narg)(*cmdlineargs)
self.lmp = c_void_p()
self.lib.lammps_open_no_mpi(narg,cargs,byref(self.lmp))
else:

View File

@ -1,39 +0,0 @@
#!/usr/local/bin/python
"""
setup.py file for LAMMPS with system MPICH library
"""
from distutils.core import setup, Extension
import os, glob
path = os.path.dirname(os.getcwd())
# list of src files for LAMMPS
libfiles = glob.glob("%s/src/*.cpp" % path)
lammps_library = Extension("_lammps",
sources = libfiles,
define_macros = [("MPICH_IGNORE_CXX_SEEK",1),
("LAMMPS_GZIP",1),
("FFT_NONE",1),],
# src files for LAMMPS
include_dirs = ["../src"],
# additional libs for MPICH on Linux
libraries = ["mpich","mpl","pthread"],
# where to find the MPICH lib on Linux
library_dirs = ["/usr/local/lib"],
# additional libs for MPI on Mac
# libraries = ["mpi"],
)
setup(name = "lammps",
version = "28Nov11",
author = "Steve Plimpton",
author_email = "sjplimp@sandia.gov",
url = "http://lammps.sandia.gov",
description = """LAMMPS molecular dynamics library - parallel""",
py_modules = ["lammps"],
ext_modules = [lammps_library]
)

View File

@ -1,34 +0,0 @@
#!/usr/local/bin/python
"""
setup_serial.py file for LAMMPS with dummy serial MPI library
"""
from distutils.core import setup, Extension
import os, glob
path = os.path.dirname(os.getcwd())
# list of src files for LAMMPS and MPI STUBS
libfiles = glob.glob("%s/src/*.cpp" % path) + \
glob.glob("%s/src/STUBS/*.c" % path)
lammps_library = Extension("_lammps_serial",
sources = libfiles,
define_macros = [("MPICH_IGNORE_CXX_SEEK",1),
("LAMMPS_GZIP",1),
("FFT_NONE",1),],
# src files for LAMMPS and MPI STUBS
include_dirs = ["../src", "../src/STUBS"]
)
setup(name = "lammps_serial",
version = "28Nov11",
author = "Steve Plimpton",
author_email = "sjplimp@sandia.gov",
url = "http://lammps.sandia.gov",
description = """LAMMPS molecular dynamics library - serial""",
py_modules = ["lammps"],
ext_modules = [lammps_library]
)