Merge branch 'master' into lammps-icms

This commit is contained in:
Axel Kohlmeyer
2012-08-18 17:17:35 -04:00
22 changed files with 1349 additions and 1183 deletions

View File

@ -58,12 +58,13 @@ operations within LAMMPS, such as running a simulation for a
reasonable number of timesteps, then the overhead cost of invoking
LAMMPS thru Python will be negligible.
</P>
<P>Before using LAMMPS from a Python script, you have to do two things.
You need to set two environment variables. And you need to build
LAMMPS as a dynamic shared library, so it can be loaded by Python.
Both these steps are discussed below. If you wish to run LAMMPS in
parallel from Python, you also need to extend your Python with MPI.
This is also discussed below.
<P>Before using LAMMPS from a Python script, you need to do two things.
You need to build LAMMPS as a dynamic shared library, so it can be
loaded by Python. And you need to tell Python how to find the library
and the Python wrapper file python/lammps.py. Both these steps are
discussed below. If you wish to run LAMMPS in parallel from Python,
you also need to extend your Python with MPI. This is also discussed
below.
</P>
<P>The Python wrapper for LAMMPS uses the amazing and magical (to me)
"ctypes" package in Python, which auto-generates the interface code
@ -131,7 +132,7 @@ python/lammps.py file.
</P>
<P>You can invoke install.py from the python directory as
</P>
<PRE>% python install.py <B>libdir</B> <B>pydir</B>
<PRE>% python install.py [libdir] [pydir]
</PRE>
<P>The optional libdir is where to copy the LAMMPS shared library to; the
default is /usr/local/lib. The optional pydir is where to copy the
@ -146,12 +147,12 @@ non-standard locations, such as within your own user space, you will
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
accordingly, as above.
</P>
<P>If the instally.py script does not allow you to copy files into system
<P>If the install.py script does not allow you to copy files into system
directories, prefix the python command with "sudo". If you do this,
make sure that the Python that root runs is the same as the Python you
run. E.g. you may need to do something like
</P>
<PRE>% sudo /usr/local/bin/python install.py <B>libdir</B> <B>pydir</B>
<PRE>% sudo /usr/local/bin/python install.py [libdir] [pydir]
</PRE>
<P>You can also invoke install.py from the make command in the src
directory as
@ -269,20 +270,27 @@ and type:
<PRE>>>> from lammps import lammps
>>> lmp = lammps()
</PRE>
<P>If you get no errors, you're ready to use LAMMPS from Python.
If the load fails, the most common error to see is
<P>If you get no errors, you're ready to use LAMMPS from Python. If the
2nd command fails, the most common error to see is
</P>
<PRE>OSError: Could not load LAMMPS dynamic library
</PRE>
<P>which means Python was unable to load the LAMMPS shared library. This
typically occurs if the system can't find the LAMMMPS shared library
or one of the auxiliary shared libraries it depends on.
typically occurs if the system can't find the LAMMPS shared library or
one of the auxiliary shared libraries it depends on, or if something
about the library is incompatible with your Python. The error message
should give you an indication of what went wrong.
</P>
<P>Python (actually the operating system) isn't verbose about telling you
why the load failed, so carefully go through the steps above regarding
environment variables, and the instructions in <A HREF = "Section_start.html#start_5">Section_start
5</A> about building a shared library and
about setting the LD_LIBRARY_PATH envirornment variable.
<P>You can also test the load directly in Python as follows, without
first importing from the lammps.py file:
</P>
<PRE>>>> from ctypes import CDLL
>>> CDLL("liblammps.so")
</PRE>
<P>If an error occurs, carefully go thru the steps in <A HREF = "Section_start.html#start_5">Section_start
5</A> and above about building a shared
library and about insuring Python can find the necessary two files
it needs.
</P>
<H5><B>Test LAMMPS and Python in serial:</B>
</H5>

View File

@ -55,12 +55,13 @@ operations within LAMMPS, such as running a simulation for a
reasonable number of timesteps, then the overhead cost of invoking
LAMMPS thru Python will be negligible.
Before using LAMMPS from a Python script, you have to do two things.
You need to set two environment variables. And you need to build
LAMMPS as a dynamic shared library, so it can be loaded by Python.
Both these steps are discussed below. If you wish to run LAMMPS in
parallel from Python, you also need to extend your Python with MPI.
This is also discussed below.
Before using LAMMPS from a Python script, you need to do two things.
You need to build LAMMPS as a dynamic shared library, so it can be
loaded by Python. And you need to tell Python how to find the library
and the Python wrapper file python/lammps.py. Both these steps are
discussed below. If you wish to run LAMMPS in parallel from Python,
you also need to extend your Python with MPI. This is also discussed
below.
The Python wrapper for LAMMPS uses the amazing and magical (to me)
"ctypes" package in Python, which auto-generates the interface code
@ -127,7 +128,7 @@ python/lammps.py file.
You can invoke install.py from the python directory as
% python install.py [libdir] [pydir] :pre
% python install.py \[libdir\] \[pydir\] :pre
The optional libdir is where to copy the LAMMPS shared library to; the
default is /usr/local/lib. The optional pydir is where to copy the
@ -142,12 +143,12 @@ non-standard locations, such as within your own user space, you will
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
accordingly, as above.
If the instally.py script does not allow you to copy files into system
If the install.py script does not allow you to copy files into system
directories, prefix the python command with "sudo". If you do this,
make sure that the Python that root runs is the same as the Python you
run. E.g. you may need to do something like
% sudo /usr/local/bin/python install.py [libdir] [pydir] :pre
% sudo /usr/local/bin/python install.py \[libdir\] \[pydir\] :pre
You can also invoke install.py from the make command in the src
directory as
@ -265,20 +266,27 @@ and type:
>>> from lammps import lammps
>>> lmp = lammps() :pre
If you get no errors, you're ready to use LAMMPS from Python.
If the load fails, the most common error to see is
If you get no errors, you're ready to use LAMMPS from Python. If the
2nd command fails, the most common error to see is
OSError: Could not load LAMMPS dynamic library :pre
which means Python was unable to load the LAMMPS shared library. This
typically occurs if the system can't find the LAMMMPS shared library
or one of the auxiliary shared libraries it depends on.
typically occurs if the system can't find the LAMMPS shared library or
one of the auxiliary shared libraries it depends on, or if something
about the library is incompatible with your Python. The error message
should give you an indication of what went wrong.
Python (actually the operating system) isn't verbose about telling you
why the load failed, so carefully go through the steps above regarding
environment variables, and the instructions in "Section_start
5"_Section_start.html#start_5 about building a shared library and
about setting the LD_LIBRARY_PATH envirornment variable.
You can also test the load directly in Python as follows, without
first importing from the lammps.py file:
>>> from ctypes import CDLL
>>> CDLL("liblammps.so") :pre
If an error occurs, carefully go thru the steps in "Section_start
5"_Section_start.html#start_5 and above about building a shared
library and about insuring Python can find the necessary two files
it needs.
[Test LAMMPS and Python in serial:] :h5

View File

@ -850,7 +850,7 @@ should be the file /usr/local/lib/libmpich.so.
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
the system can find it by default, such as /usr/local/lib, or you may
wish to add the lammps src directory to LD_LIBRARY_PATH, so that the
wish to add the LAMMPS src directory to LD_LIBRARY_PATH, so that the
current version of the shared library is always available to programs
that use it.
</P>

View File

@ -844,7 +844,7 @@ The operating system finds shared libraries to load at run-time using
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
the system can find it by default, such as /usr/local/lib, or you may
wish to add the lammps src directory to LD_LIBRARY_PATH, so that the
wish to add the LAMMPS src directory to LD_LIBRARY_PATH, so that the
current version of the shared library is always available to programs
that use it.

View File

@ -30,6 +30,7 @@
#include <compute.h>
#include <modify.h>
#include <error.h>
#include <cstdlib>
using namespace LAMMPS_NS;

View File

@ -21,12 +21,6 @@
library.h. All prototypes herein COULD be added to library.h instead of
including this as a separate file. See the README for instructions. */
/* These prototypes probably belong in mpi.h in the src/STUBS directory. */
#ifndef OPEN_MPI
#define MPI_Comm_f2c(a) a
#define MPI_Fint int
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -38,7 +32,7 @@ int lammps_extract_compute_vectorsize (void*, char*, int);
void lammps_extract_compute_arraysize (void*, char*, int, int*, int*);
int lammps_extract_fix_vectorsize (void*, char*, int);
void lammps_extract_fix_arraysize (void*, char*, int, int*, int*);
void lammps_error_all (void *ptr, const char*, int, const char*);
void lammps_error_all (void*, const char*, int, const char*);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ questions:
Karl D. Hammond
University of Tennessee, Knoxville
karlh at ugcs.caltech.edu
karlh atutk.edu
karlh at utk.edu
-------------------------------------
@ -27,7 +27,7 @@ compile.
The following steps will work to compile this module (replace ${LAMMPS_SRC}
with the path to your LAMMPS source directory):
(1) Compile LAMMPS as a static library. Call the resulting file ${LAMMPS_LIB},
which will have an actual name lake liblammps_openmpi.a. If compiling
which will have an actual name lake liblmp_openmpi.a. If compiling
using the MPI stubs in ${LAMMPS_SRC}/STUBS, you will need to know where
libmpi.a is as well (I'll call it ${MPI_STUBS} hereafter)
(2) Copy said library to your Fortran program's source directory or include
@ -61,7 +61,7 @@ with the path to your LAMMPS source directory):
need to have the .mod file from part (3).
It is also possible to add LAMMPS.o and LAMMPS-wrapper.o into the
LAMMPS library (e.g., liblammps_openmpi.a) instead of creating a separate
LAMMPS library (e.g., liblmp_openmpi.a) instead of creating a separate
library, like so:
ar rs ${LAMMPS_LIB} LAMMPS.o LAMMPS-wrapper.o
In this case, you can now use the Fortran wrapper functions as if they

View File

@ -1,7 +1,7 @@
SHELL = /bin/sh
# Path to LAMMPS extraction directory
LAMMPS_ROOT = ../svn-dist
LAMMPS_ROOT = ../../..
LAMMPS_SRC = $(LAMMPS_ROOT)/src
# Remove the line below if using mpicxx/mpic++ as your C++ compiler

View File

@ -1,35 +1,67 @@
#!/usr/local/bin/python
# copy LAMMPS shared library src/liblammps.so and lammps.py to system dirs
# Syntax: python install.py [libdir] [pydir]
# libdir = target dir for src/liblammps.so, default = /usr/local/lib
# pydir = target dir for lammps.py, default = Python site-packages dir
# copy LAMMPS src/liblammps.so and lammps.py to system dirs
import sys,commands
instructions = """
Syntax: python install.py [-h] [libdir] [pydir]
libdir = target dir for src/liblammps.so, default = /usr/local/lib
pydir = target dir for lammps.py, default = Python site-packages dir
"""
if len(sys.argv) > 3:
print "Syntax: python install.py [libdir] [pydir]"
import sys,os,commands
if (len(sys.argv) > 1 and sys.argv[1] == "-h") or len(sys.argv) > 3:
print instructions
sys.exit()
if len(sys.argv) >= 2: libdir = sys.argv[1]
else: libdir = "/usr/local/lib"
if len(sys.argv) == 3: pydir = sys.argv[2]
else: pydir = ""
# copy C lib to libdir if it exists
# warn if not in LD_LIBRARY_PATH or LD_LIBRARY_PATH is undefined
if not os.path.isdir(libdir):
print "ERROR: libdir %s does not exist" % libdir
sys.exit()
if "LD_LIBRARY_PATH" not in os.environ:
print "WARNING: LD_LIBRARY_PATH undefined, cannot check libdir %s" % libdir
else:
paths = sys.path
for i,path in enumerate(paths):
index = path.rfind("site-packages")
if index < 0: continue
if index == len(path) - len("site-packages"): break
pydir = paths[i]
libpaths = os.environ['LD_LIBRARY_PATH'].split(':')
if libdir not in libpaths:
print "WARNING: libdir %s not in LD_LIBRARY_PATH" % libdir
str = "cp ../src/liblammps.so %s" % libdir
print str
outstr = commands.getoutput(str)
if len(outstr.strip()): print outstr
str = "cp ../python/lammps.py %s" % pydir
print str
outstr = commands.getoutput(str)
if len(outstr.strip()): print outstr
# copy lammps.py to pydir if it exists
# if pydir not specified, install in site-packages via distutils setup()
if pydir:
if not os.path.isdir(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
sys.exit()
print "installing lammps.py in Python site-packages dir"
os.chdir('../python') # in case invoked via make in src dir
from distutils.core import setup
sys.argv = ["setup.py","install"] # as if had run "python setup.py install"
setup(name = "lammps",
version = "15Aug12",
author = "Steve Plimpton",
author_email = "sjplimp@sandia.gov",
url = "http://lammps.sandia.gov",
description = "LAMMPS molecular dynamics library",
py_modules = ["lammps"])

View File

@ -13,7 +13,7 @@
# Python wrapper on LAMMPS library via ctypes
import types
import sys,traceback,types
from ctypes import *
import os.path
@ -27,6 +27,8 @@ class lammps:
if not name: self.lib = CDLL("liblammps.so")
else: self.lib = CDLL("liblammps_%s.so" % name)
except:
type,value,tb = sys.exc_info()
traceback.print_exception(type,value,tb)
raise OSError,"Could not load LAMMPS dynamic library"
# create an instance of LAMMPS

View File

@ -39,6 +39,8 @@ class FFT3d : protected Pointers {
E: Could not create 3d FFT plan
The FFT setup in pppm failed.
The FFT setup for the PPPM solver failed, typically due
to lack of memory. This is an unusual error. Check the
size of the FFT grid you are requesting.
*/

View File

@ -100,7 +100,6 @@ PPPM::PPPM(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
// see JCP 109, pg 7698 for derivation of coefficients
// higher order coefficients may be computed if needed
memory->destroy(acons);
memory->create(acons,8,7,"pppm:acons");
acons[1][0] = 2.0 / 3.0;
acons[2][0] = 1.0 / 50.0;

View File

@ -85,9 +85,6 @@ $(EXE): $(OBJ)
lib: $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
#shlib: $(OBJ)
# $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
shlib: $(OBJ)
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
$(OBJ) $(EXTRA_LIB) $(LIB)

View File

@ -1,6 +1,8 @@
# Make.sh = update Makefile.lib or Makefile.list or style_*.h files
# Make.sh = update Makefile.lib, Makefile.shlib, Makefile.list
# or style_*.h files
# Syntax: sh Make.sh style
# sh Make.sh Makefile.lib
# sh Make.sh Makefile.shlib
# sh Make.sh Makefile.list
# function to create one style_*.h file

View File

@ -130,7 +130,7 @@ makelist:
@$(SHELL) Make.sh style
@$(SHELL) Make.sh Makefile.list
# install LAMMPS shared lib and Python wrapper in Python
# install LAMMPS shared lib and Python wrapper for Python usage
install-python:
@python ../python/install.py

View File

@ -21,9 +21,6 @@ help:
@files="`ls MAKE/Makefile.*`"; \
for file in $$files; do head -1 $$file; done
clean:
rm -rf Obj_*
.DEFAULT:
@test -f MAKE/Makefile.$@
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi

View File

@ -21,9 +21,6 @@ help:
@files="`ls MAKE/Makefile.*`"; \
for file in $$files; do head -1 $$file; done
clean:
rm -rf Obj_*
.DEFAULT:
@test -f MAKE/Makefile.$@
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi

File diff suppressed because one or more lines are too long

View File

@ -410,6 +410,8 @@ void Cuda::setDomainParams()
cu_domain->boxlo_lamda[i] = domain->boxlo_lamda[i];
cu_domain->boxhi_lamda[i] = domain->boxhi_lamda[i];
cu_domain->prd_lamda[i] = domain->prd_lamda[i];
cu_domain->sublo[i] = domain->sublo_lamda[i];
cu_domain->subhi[i] = domain->subhi_lamda[i];
}
cu_domain->xy = domain->xy;

View File

@ -17,7 +17,7 @@
#ifdef PAIR_CLASS
PairStyle(lj/cut/omp,PairLJExpandOMP)
PairStyle(lj/expand/omp,PairLJExpandOMP)
#else

View File

@ -30,7 +30,9 @@
#include "modify.h"
#include "compute.h"
#include "fix.h"
#include "comm.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
@ -383,8 +385,13 @@ void lammps_gather_atoms(void *ptr, char *name,
// error if tags are not defined or not consecutive
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) return;
if (lmp->atom->natoms > MAXSMALLINT) return;
int flag = 0;
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) flag = 1;
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
if (flag && lmp->comm->me == 0) {
lmp->error->warning(FLERR,"Library error in lammps_gather_atoms");
return;
}
int natoms = static_cast<int> (lmp->atom->natoms);
@ -464,10 +471,16 @@ void lammps_scatter_atoms(void *ptr, char *name,
{
LAMMPS *lmp = (LAMMPS *) ptr;
// error if tags are not defined or not consecutive
// error if tags are not defined or not consecutive or no atom map
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) return;
if (lmp->atom->natoms > MAXSMALLINT) return;
int flag = 0;
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) flag = 1;
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
if (lmp->atom->map_style == 0) flag = 1;
if (flag && lmp->comm->me == 0) {
lmp->error->warning(FLERR,"Library error in lammps_scatter_atoms");
return;
}
int natoms = static_cast<int> (lmp->atom->natoms);