From ee7f12334d6f321b101914bdfe8c1c42763e4b2c Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 10 Aug 2012 23:22:54 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8603 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- python/README | 48 ++++++++++++++++++++++++++++++------------ python/setup.py | 39 ---------------------------------- python/setup_serial.py | 34 ------------------------------ 3 files changed, 35 insertions(+), 86 deletions(-) delete mode 100755 python/setup.py delete mode 100755 python/setup_serial.py diff --git a/python/README b/python/README index 49465b3596..2b51b5f710 100644 --- a/python/README +++ b/python/README @@ -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 diff --git a/python/setup.py b/python/setup.py deleted file mode 100755 index 072673c027..0000000000 --- a/python/setup.py +++ /dev/null @@ -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] - ) diff --git a/python/setup_serial.py b/python/setup_serial.py deleted file mode 100755 index 2aa242b19a..0000000000 --- a/python/setup_serial.py +++ /dev/null @@ -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] - )