git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8603 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,26 +1,48 @@
|
|||||||
This directory contains Python code which wraps LAMMPS as a library
|
This directory contains Python code which wraps LAMMPS as a library
|
||||||
and allows the library interface to be invoked from a Python, either
|
and allows the LAMMPS library interface to be invoked from Python,
|
||||||
from a script or interactively.
|
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.
|
doc/Section_python.html.
|
||||||
|
|
||||||
Basically you have to extend the Python on your box to include the
|
Basically you need to follow these 3 steps:
|
||||||
LAMMPS wrappers:
|
|
||||||
|
|
||||||
python setup_serial.py build # for serial LAMMPS and Python
|
a) Add paths to environment variables in your shell script
|
||||||
sudo python setup_serial.py install
|
|
||||||
|
|
||||||
python setup.py build # for parallel LAMMPS and Python
|
For example, for csh or tcsh, add something like this to ~/.cshrc:
|
||||||
sudo python setup.py install
|
|
||||||
|
|
||||||
but there are several issues to be aware of, as discussed in the doc
|
setenv PYTHONPATH ${PYTHONPATH}:/home/sjplimp/lammps/python
|
||||||
pages.
|
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
|
Once you have successfully wrapped LAMMPS, you can run the Python
|
||||||
the Python scripts in the examples sub-directory:
|
scripts in the examples sub-directory:
|
||||||
|
|
||||||
trivial.py read/run a LAMMPS input script thru Python
|
trivial.py read/run a LAMMPS input script thru Python
|
||||||
demo.py invoke various LAMMPS library interface routines
|
demo.py invoke various LAMMPS library interface routines
|
||||||
|
|||||||
@ -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]
|
|
||||||
)
|
|
||||||
@ -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]
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user