git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8615 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2012-08-13 14:34:09 +00:00
parent 3fea520ef9
commit 6908ce6e9d
6 changed files with 230 additions and 174 deletions

View File

@ -85,38 +85,18 @@ that Python checks.
<P>The first is the environment variable PYTHONPATH. It needs
to include the directory where the python/lammps.py file is.
</P>
<P>For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
<P>For the csh or tcsh shells, add something like this to your ~/.cshrc
file:
</P>
<PRE>setenv PYTHONPATH $<I>PYTHONPATH</I>:/home/sjplimp/lammps/python
</PRE>
<P>The second is the environment variable LD_LIBRARY_PATH, which is used
by the operating system to find dynamic shared libraries when it loads
them. It needs to include the directory where the shared LAMMPS
library will be. Normally this is the LAMMPS src dir, as explained in
the following section.
them. See the discussion in <A HREF = "Section_start.html#start_5">Section_start
5</A> of the manual about building LAMMPS as a
shared library, for instructions on how to set the LD_LIBRARY_PATH
variable appropriately.
</P>
<P>For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src
</PRE>
<P>As discussed below, if your LAMMPS build includes auxiliary libraries,
they must also be available as shared libraries for Python to
successfully load LAMMPS. If they are not in default places where the
operating system can find them, then you also have to add their paths
to the LD_LIBRARY_PATH environment variable.
</P>
<P>For example, if you are using the dummy MPI library provided in
src/STUBS, you need to add something like this to your ~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src/STUBS
</PRE>
<P>If you are using the LAMMPS USER-ATC package, you need to add
something like this to your ~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/lib/atc
</PRE>
<HR>
<A NAME = "py_2"></A><H4>11.2 Building LAMMPS as a shared library
@ -126,11 +106,11 @@ something like this to your ~/.cshrc file:
that is dynamically loadable, which is what Python requires. On Linux
this is a library file that ends in ".so", not ".a".
</P>
<P>>From the src directory, type
</P>
<P>make makeshlib
make -f Makefile.shlib foo
<P>From the src directory, type
</P>
<PRE>make makeshlib
make -f Makefile.shlib foo
</PRE>
<P>where foo is the machine target name, such as linux or g++ or serial.
This should create the file liblmp_foo.so in the src directory, as
well as a soft link liblmp.so which is what the Python wrapper will
@ -138,47 +118,7 @@ load by default. If you are building multiple machine versions of the
shared library, the soft link is always set to the most recently built
version.
</P>
<P>Note that as discussed in below, a LAMMPS build may depend on several
auxiliary libraries, which are specified in your low-level
src/Makefile.foo file. For example, an MPI library, the FFTW library,
a JPEG library, etc. Depending on what LAMMPS packages you have
installed, the build may also require additional libraries from the
lib directories, such as lib/atc/libatc.so or lib/reax/libreax.so.
</P>
<P>You must insure that each of these libraries exist in shared library
form (*.so file for Linux systems), or either the LAMMPS shared
library build or the Python load of the library will fail. For the
load to be successful all the shared libraries must also be in
directories that the operating system checks. See the discussion in
the preceding section about the LD_LIBRARY_PATH environment variable
for how to insure this.
</P>
<P>Note that some system libraries, such as MPI, if you installed it
yourself, may not be built by default as shared libraries. The build
instructions for the library should tell you how to do this.
</P>
<P>For example, here is how to build and install the <A HREF = "http://www-unix.mcs.anl.gov/mpi">MPICH
library</A>, a popular open-source version of MPI, distributed by
Argonne National Labs, as a shared library in the default
/usr/local/lib location:
</P>
<PRE>./configure --enable-shared
make
make install
</PRE>
<P>You may need to use "sudo make install" in place of the last line if
you do not have write priveleges for /usr/local/lib. The end result
should be the file /usr/local/lib/libmpich.so.
</P>
<P>Note that not all of the auxiliary libraries provided with LAMMPS have
shared-library Makefiles in their lib directories. Typically this
simply requires a Makefile.foo that adds a -fPIC switch when files are
compiled and a "-fPIC -shared" switches when the library is linked
with a C++ (or Fortran) compiler, as well as an output target that
ends in ".so", like libatc.o. As we or others create and contribute
these Makefiles, we will add them to the LAMMPS distribution.
<P>See <A HREF = "Section_start.html#start_5">Section_start 5</A> for more details.
</P>
<HR>
@ -197,7 +137,7 @@ as a library and allow MPI functions to be called from Python.
<LI><A HREF = "http://code.google.com/p/maroonmpi/">maroonmpi</A>
<LI><A HREF = "http://code.google.com/p/mpi4py/">mpi4py</A>
<LI><A HREF = "http://nbcr.sdsc.edu/forum/viewtopic.php?t=89&sid=c997fefc3933bd66204875b436940f16">myMPI</A>
<LI><A HREF = "http://datamining.anu.edu.au/~ole/pypar">Pypar</A>
<LI><A HREF = "http://code.google.com/p/pypar">Pypar</A>
</UL>
<P>All of these except pyMPI work by wrapping the MPI library (which must
be available on your system as a shared library, as discussed above),
@ -272,7 +212,7 @@ and type:
<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>
<P>"CDLL: asdfasdfasdf"
<P>OSError: Could not load LAMMPS dynamic library
</P>
<P>which means Python was unable to load the LAMMPS shared library. This
can occur if it can't find the LAMMMPS library; see the environment

View File

@ -81,37 +81,17 @@ that Python checks.
The first is the environment variable PYTHONPATH. It needs
to include the directory where the python/lammps.py file is.
For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
For the csh or tcsh shells, add something like this to your ~/.cshrc
file:
setenv PYTHONPATH ${PYTHONPATH}:/home/sjplimp/lammps/python :pre
The second is the environment variable LD_LIBRARY_PATH, which is used
by the operating system to find dynamic shared libraries when it loads
them. It needs to include the directory where the shared LAMMPS
library will be. Normally this is the LAMMPS src dir, as explained in
the following section.
For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src :pre
As discussed below, if your LAMMPS build includes auxiliary libraries,
they must also be available as shared libraries for Python to
successfully load LAMMPS. If they are not in default places where the
operating system can find them, then you also have to add their paths
to the LD_LIBRARY_PATH environment variable.
For example, if you are using the dummy MPI library provided in
src/STUBS, you need to add something like this to your ~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src/STUBS :pre
If you are using the LAMMPS USER-ATC package, you need to add
something like this to your ~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/lib/atc :pre
them. See the discussion in "Section_start
5"_Section_start.html#start_5 of the manual about building LAMMPS as a
shared library, for instructions on how to set the LD_LIBRARY_PATH
variable appropriately.
:line
@ -122,10 +102,10 @@ Instructions on how to build LAMMPS as a shared library are given in
that is dynamically loadable, which is what Python requires. On Linux
this is a library file that ends in ".so", not ".a".
>From the src directory, type
From the src directory, type
make makeshlib
make -f Makefile.shlib foo
make -f Makefile.shlib foo :pre
where foo is the machine target name, such as linux or g++ or serial.
This should create the file liblmp_foo.so in the src directory, as
@ -134,47 +114,7 @@ load by default. If you are building multiple machine versions of the
shared library, the soft link is always set to the most recently built
version.
Note that as discussed in below, a LAMMPS build may depend on several
auxiliary libraries, which are specified in your low-level
src/Makefile.foo file. For example, an MPI library, the FFTW library,
a JPEG library, etc. Depending on what LAMMPS packages you have
installed, the build may also require additional libraries from the
lib directories, such as lib/atc/libatc.so or lib/reax/libreax.so.
You must insure that each of these libraries exist in shared library
form (*.so file for Linux systems), or either the LAMMPS shared
library build or the Python load of the library will fail. For the
load to be successful all the shared libraries must also be in
directories that the operating system checks. See the discussion in
the preceding section about the LD_LIBRARY_PATH environment variable
for how to insure this.
Note that some system libraries, such as MPI, if you installed it
yourself, may not be built by default as shared libraries. The build
instructions for the library should tell you how to do this.
For example, here is how to build and install the "MPICH
library"_mpich, a popular open-source version of MPI, distributed by
Argonne National Labs, as a shared library in the default
/usr/local/lib location:
:link(mpich,http://www-unix.mcs.anl.gov/mpi)
./configure --enable-shared
make
make install :pre
You may need to use "sudo make install" in place of the last line if
you do not have write priveleges for /usr/local/lib. The end result
should be the file /usr/local/lib/libmpich.so.
Note that not all of the auxiliary libraries provided with LAMMPS have
shared-library Makefiles in their lib directories. Typically this
simply requires a Makefile.foo that adds a -fPIC switch when files are
compiled and a "-fPIC -shared" switches when the library is linked
with a C++ (or Fortran) compiler, as well as an output target that
ends in ".so", like libatc.o. As we or others create and contribute
these Makefiles, we will add them to the LAMMPS distribution.
See "Section_start 5"_Section_start.html#start_5 for more details.
:line
@ -193,7 +133,7 @@ These include
"maroonmpi"_http://code.google.com/p/maroonmpi/
"mpi4py"_http://code.google.com/p/mpi4py/
"myMPI"_http://nbcr.sdsc.edu/forum/viewtopic.php?t=89&sid=c997fefc3933bd66204875b436940f16
"Pypar"_http://datamining.anu.edu.au/~ole/pypar :ul
"Pypar"_http://code.google.com/p/pypar :ul
All of these except pyMPI work by wrapping the MPI library (which must
be available on your system as a shared library, as discussed above),
@ -229,6 +169,11 @@ sudo python setup.py install :pre
The "sudo" is only needed if required to copy Numpy files into your
Python distribution's site-packages directory.
To install Pypar (version pypar-2.1.0_66 as of April 2009), unpack it
and from its "source" directory, type
@ -268,7 +213,10 @@ and type:
If you get no errors, you're ready to use LAMMPS from Python.
If the load fails, the most common error to see is
"CDLL: asdfasdfasdf"
OSError: Could not load LAMMPS dynamic library
which means Python was unable to load the LAMMPS shared library. This
can occur if it can't find the LAMMMPS library; see the environment

View File

@ -785,15 +785,15 @@ more info on wrapping and running LAMMPS from Python.
make -f Makefile.lib foo
</PRE>
<P>where foo is the machine name. This kind of library is typically used
to statically link a driver application to all of LAMMPS, so that you
can insure all dependencies are satisfied at compile time. Note that
to statically link a driver application to LAMMPS, so that you can
insure all dependencies are satisfied at compile time. Note that
inclusion or exclusion of any desired optional packages should be done
before typing "make makelib". The first "make" command will create a
current Makefile.lib with all the file names in your src dir. The 2nd
"make" command will use it to build LAMMPS as a static library, using
the ARCHIVE and ARFLAGS settings in src/MAKE/Makefile.foo. The build
will create the file liblmp_foo.a which another application can link
to.
current Makefile.lib with all the file names in your src dir. The
second "make" command will use it to build LAMMPS as a static library,
using the ARCHIVE and ARFLAGS settings in src/MAKE/Makefile.foo. The
build will create the file liblmp_foo.a which another application can
link to.
</P>
<P>To build LAMMPS as a shared library (*.so file on Linux), which can be
dynamically loaded, type
@ -806,7 +806,7 @@ wrapping LAMMPS with Python; see <A HREF = "Section_python.html">Section_python<
for details. Again, note that inclusion or exclusion of any desired
optional packages should be done before typing "make makelib". The
first "make" command will create a current Makefile.shlib with all the
file names in your src dir. The 2nd "make" command will use it to
file names in your src dir. The second "make" command will use it to
build LAMMPS as a shared library, using the SHFLAGS and SHLIBFLAGS
settings in src/MAKE/Makefile.foo. The build will create the file
liblmp_foo.so which another application can link to dyamically, as
@ -815,15 +815,87 @@ default.
</P>
<P>Note that for a shared library to be usable by a calling program, all
the auxiliary libraries it depends on must also exist as shared
libraries, and be find-able by the operating system. Else you will
get a run-time error when the shared library is loaded. For LAMMPS,
this includes all libraries needed by main LAMMPS (e.g. MPI or FFTW or
JPEG), system libraries needed by main LAMMPS (e.g. extra libs needed
by MPI), or packages you have installed that require libraries
libraries, and the operating system must be able to find them. For
LAMMPS, this includes all libraries needed by main LAMMPS (e.g. MPI or
FFTW or JPEG), system libraries needed by main LAMMPS (e.g. extra libs
needed by MPI), or packages you have installed that require libraries
provided with LAMMPS (e.g. the USER-ATC package require
lib/atc/libatc.so) or system libraries (e.g. BLAS or Fortran-to-C
libraries) listed in the lib/package/Makefile.lammps file. See the
discussion about the LAMMPS shared library in
libraries) listed in the lib/package/Makefile.lammps file.
</P>
<P>If one of these auxiliary libraries does not exist as a shared
library, the second make command should generate a build error. The
build will not generate an error, if a needed library is simply
missing from the link list; this will generate a run-time error when
the library is loaded, so be sure all needed libraries are listed,
as they would be when building LAMMPS as a stand-alone code.
</P>
<P>Note that if you install them yourself, some libraries, such as MPI,
may not build by default as shared libraries. The build instructions
for the library should tell you how to do this.
</P>
<P>For example, here is how to build and install the <A HREF = "http://www-unix.mcs.anl.gov/mpi">MPICH
library</A>, a popular open-source version of MPI, distributed by
Argonne National Labs, as a shared library in the default
/usr/local/lib location:
</P>
<PRE>./configure --enable-shared
make
make install
</PRE>
<P>You may need to use "sudo make install" in place of the last line if
you do not have write priveleges for /usr/local/lib. The end result
should be the file /usr/local/lib/libmpich.so.
</P>
<P>Also note that not all of the auxiliary libraries provided with LAMMPS
include Makefiles in their lib directories for building them as shared
libraries. Typically this simply requires adding a -fPIC switch when
files are compiled and "-fPIC -shared" switches when the library is
linked with a C++ (or Fortran) compiler, and creating an output target
that ends in ".so", like libatc.o. As we or others create and
contribute these Makefiles, we will add them to the LAMMPS
distribution.
</P>
<P>You must insure that each of these libraries exist in shared library
form (*.so file for Linux systems), or either the LAMMPS shared
library build or the Python load of the library will fail. For the
load to be successful all the shared libraries must also be in
directories that the operating system checks. See the discussion in
the preceding section about the LD_LIBRARY_PATH environment variable
for how to insure this.
</P>
<P>The second is the environment variable LD_LIBRARY_PATH, which is used
by the operating system to find dynamic shared libraries when it loads
them.
</P>
<P>It needs to include the directory where the shared LAMMPS
library will be. Normally this is the LAMMPS src dir, as explained in
the following section.
</P>
<P>For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src
</PRE>
<P>As discussed below, if your LAMMPS build includes auxiliary libraries,
they must also be available as shared libraries for Python to
successfully load LAMMPS. If they are not in default places where the
operating system can find them, then you also have to add their paths
to the LD_LIBRARY_PATH environment variable.
</P>
<P>For example, if you are using the dummy MPI library provided in
src/STUBS, you need to add something like this to your ~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src/STUBS
</PRE>
<P>If you are using the LAMMPS USER-ATC package, you need to add
something like this to your ~/.cshrc file:
</P>
<PRE>setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/lib/atc
</PRE>
<P>See the discussion about the LAMMPS shared library in
<A HREF = "Section_python.html">Section_python</A> for details about how to build
shared versions of these libraries, and how to insure the operating
system can find them, by setting the LD_LIBRARY_PATH environment

View File

@ -779,15 +779,15 @@ make makelib
make -f Makefile.lib foo :pre
where foo is the machine name. This kind of library is typically used
to statically link a driver application to all of LAMMPS, so that you
can insure all dependencies are satisfied at compile time. Note that
to statically link a driver application to LAMMPS, so that you can
insure all dependencies are satisfied at compile time. Note that
inclusion or exclusion of any desired optional packages should be done
before typing "make makelib". The first "make" command will create a
current Makefile.lib with all the file names in your src dir. The 2nd
"make" command will use it to build LAMMPS as a static library, using
the ARCHIVE and ARFLAGS settings in src/MAKE/Makefile.foo. The build
will create the file liblmp_foo.a which another application can link
to.
current Makefile.lib with all the file names in your src dir. The
second "make" command will use it to build LAMMPS as a static library,
using the ARCHIVE and ARFLAGS settings in src/MAKE/Makefile.foo. The
build will create the file liblmp_foo.a which another application can
link to.
To build LAMMPS as a shared library (*.so file on Linux), which can be
dynamically loaded, type
@ -800,7 +800,7 @@ wrapping LAMMPS with Python; see "Section_python"_Section_python.html
for details. Again, note that inclusion or exclusion of any desired
optional packages should be done before typing "make makelib". The
first "make" command will create a current Makefile.shlib with all the
file names in your src dir. The 2nd "make" command will use it to
file names in your src dir. The second "make" command will use it to
build LAMMPS as a shared library, using the SHFLAGS and SHLIBFLAGS
settings in src/MAKE/Makefile.foo. The build will create the file
liblmp_foo.so which another application can link to dyamically, as
@ -809,20 +809,106 @@ default.
Note that for a shared library to be usable by a calling program, all
the auxiliary libraries it depends on must also exist as shared
libraries, and be find-able by the operating system. Else you will
get a run-time error when the shared library is loaded. For LAMMPS,
this includes all libraries needed by main LAMMPS (e.g. MPI or FFTW or
JPEG), system libraries needed by main LAMMPS (e.g. extra libs needed
by MPI), or packages you have installed that require libraries
libraries, and the operating system must be able to find them. For
LAMMPS, this includes all libraries needed by main LAMMPS (e.g. MPI or
FFTW or JPEG), system libraries needed by main LAMMPS (e.g. extra libs
needed by MPI), or packages you have installed that require libraries
provided with LAMMPS (e.g. the USER-ATC package require
lib/atc/libatc.so) or system libraries (e.g. BLAS or Fortran-to-C
libraries) listed in the lib/package/Makefile.lammps file. See the
discussion about the LAMMPS shared library in
libraries) listed in the lib/package/Makefile.lammps file.
If one of these auxiliary libraries does not exist as a shared
library, the second make command should generate a build error. The
build will not generate an error, if a needed library is simply
missing from the link list; this will generate a run-time error when
the library is loaded, so be sure all needed libraries are listed,
as they would be when building LAMMPS as a stand-alone code.
Note that if you install them yourself, some libraries, such as MPI,
may not build by default as shared libraries. The build instructions
for the library should tell you how to do this.
For example, here is how to build and install the "MPICH
library"_mpich, a popular open-source version of MPI, distributed by
Argonne National Labs, as a shared library in the default
/usr/local/lib location:
:link(mpich,http://www-unix.mcs.anl.gov/mpi)
./configure --enable-shared
make
make install :pre
You may need to use "sudo make install" in place of the last line if
you do not have write priveleges for /usr/local/lib. The end result
should be the file /usr/local/lib/libmpich.so.
Also note that not all of the auxiliary libraries provided with LAMMPS
include Makefiles in their lib directories for building them as shared
libraries. Typically this simply requires adding a -fPIC switch when
files are compiled and "-fPIC -shared" switches when the library is
linked with a C++ (or Fortran) compiler, and creating an output target
that ends in ".so", like libatc.o. As we or others create and
contribute these Makefiles, we will add them to the LAMMPS
distribution.
You must insure that each of these libraries exist in shared library
form (*.so file for Linux systems), or either the LAMMPS shared
library build or the Python load of the library will fail. For the
load to be successful all the shared libraries must also be in
directories that the operating system checks. See the discussion in
the preceding section about the LD_LIBRARY_PATH environment variable
for how to insure this.
The second is the environment variable LD_LIBRARY_PATH, which is used
by the operating system to find dynamic shared libraries when it loads
them.
It needs to include the directory where the shared LAMMPS
library will be. Normally this is the LAMMPS src dir, as explained in
the following section.
For the csh or tcsh shells, you could add something like this to your
~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src :pre
As discussed below, if your LAMMPS build includes auxiliary libraries,
they must also be available as shared libraries for Python to
successfully load LAMMPS. If they are not in default places where the
operating system can find them, then you also have to add their paths
to the LD_LIBRARY_PATH environment variable.
For example, if you are using the dummy MPI library provided in
src/STUBS, you need to add something like this to your ~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src/STUBS :pre
If you are using the LAMMPS USER-ATC package, you need to add
something like this to your ~/.cshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/lib/atc :pre
See the discussion about the LAMMPS shared library in
"Section_python"_Section_python.html for details about how to build
shared versions of these libraries, and how to insure the operating
system can find them, by setting the LD_LIBRARY_PATH environment
variable correctly.
Either flavor of library allows one or more LAMMPS objects to be
instantiated from the calling program.

View File

@ -58,6 +58,11 @@ results from a unitless LJ simulation into physical quantities.
<LI>electric field = force/charge, where E* = E (4 pi perm0 sigma epsilon)^1/2 sigma / epsilon
<LI>density = mass/volume, where rho* = rho sigma^dim
</UL>
<P>Note that for LJ units, the default mode of thermodyamic output via
the <A HREF = "thermo_style.html">thermo_style</A> command is to normalize energies
by the number of atoms, i.e. energy/atom. This can be changed via the
<A HREF = "therm_modify.html">thermo_modify norm</A> command.
</P>
<P>For style <I>real</I>, these are the units:
</P>
<UL><LI>mass = grams/mole

View File

@ -55,6 +55,11 @@ dipole = reduced LJ dipole, moment where *mu = mu / (4 pi perm0 sigma^3 epsilon)
electric field = force/charge, where E* = E (4 pi perm0 sigma epsilon)^1/2 sigma / epsilon
density = mass/volume, where rho* = rho sigma^dim :ul
Note that for LJ units, the default mode of thermodyamic output via
the "thermo_style"_thermo_style.html command is to normalize energies
by the number of atoms, i.e. energy/atom. This can be changed via the
"thermo_modify norm"_therm_modify.html command.
For style {real}, these are the units:
mass = grams/mole