git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8657 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -107,11 +107,11 @@ system.
|
|||||||
<P>For Python to invoke LAMMPS, there are 2 files it needs to have:
|
<P>For Python to invoke LAMMPS, there are 2 files it needs to have:
|
||||||
</P>
|
</P>
|
||||||
<UL><LI>python/lammps.py
|
<UL><LI>python/lammps.py
|
||||||
<LI>src/liblmp.so
|
<LI>src/liblammps.so
|
||||||
</UL>
|
</UL>
|
||||||
<P>Lammps.py is the Python wrapper on the LAMMPS library interface.
|
<P>Lammps.py is the Python wrapper on the LAMMPS library interface.
|
||||||
Liblmp.so is the shared LAMMPS library that Python loads, as described
|
Liblammps.so is the shared LAMMPS library that Python loads, as
|
||||||
above.
|
described above.
|
||||||
</P>
|
</P>
|
||||||
<P>You can insure Python can find these files in one of two ways:
|
<P>You can insure Python can find these files in one of two ways:
|
||||||
</P>
|
</P>
|
||||||
@ -125,32 +125,38 @@ this to your ~/.cshrc file, one line for each of the two files:
|
|||||||
<PRE>setenv PYTHONPATH $<I>PYTHONPATH</I>:/home/sjplimp/lammps/python
|
<PRE>setenv PYTHONPATH $<I>PYTHONPATH</I>:/home/sjplimp/lammps/python
|
||||||
setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src
|
setenv LD_LIBRARY_PATH $<I>LD_LIBRARY_PATH</I>:/home/sjplimp/lammps/src
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>If you run the python/install.py script, you need to rerun it every
|
<P>If you use the python/install.py script, you need to invoke it every
|
||||||
time you rebuild LAMMPS (as a shared library) or make changes to the
|
time you rebuild LAMMPS (as a shared library) or make changes to the
|
||||||
python/lammps.py file.
|
python/lammps.py file.
|
||||||
</P>
|
</P>
|
||||||
<P>You can invoke install.py from the python directory as
|
<P>You can invoke install.py from the python directory as
|
||||||
</P>
|
</P>
|
||||||
<PRE>% python install.py
|
<PRE>% python install.py <B>libdir</B> <B>pydir</B>
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>Prefix this command with "sudo" if it does not allow you to copy files
|
<P>The optional libdir is where to copy the LAMMPS shared library to;
|
||||||
into the Python site-packages directory. If you do this, make sure
|
the default is /usr/local/lib. The optional pydir is where to copy
|
||||||
that the Python run by root is the same as the Python you run.
|
the lammps.py file to; the default is the site-packages directory
|
||||||
E.g. you may need to do something like
|
of the Python running the install script.
|
||||||
</P>
|
</P>
|
||||||
<PRE>% sudo /usr/local/bin/python install.py
|
<P>Prefix the python command with "sudo" if it does not allow you to copy
|
||||||
|
files into system directories. 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>
|
</PRE>
|
||||||
<P>You can also invoke install.py from the src directory as
|
<P>You can also invoke install.py from the src directory as
|
||||||
</P>
|
</P>
|
||||||
<PRE>% make install-python
|
<PRE>% make install-python
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>Again, you may need to prefix this with "sudo". In this mode you
|
<P>In this mode you cannot append optional arguments. Again, you may
|
||||||
cannot control which Python root invokes.
|
need to prefix this with "sudo". In this mode you cannot control
|
||||||
|
which Python is invoked by root.
|
||||||
</P>
|
</P>
|
||||||
<P>Note that if you want Python to be able to load different versions of
|
<P>Note that if you want Python to be able to load different versions of
|
||||||
the LAMMPS shared library (see <A HREF = "#py_5">this section</A> below), you will
|
the LAMMPS shared library (see <A HREF = "#py_5">this section</A> below), you will
|
||||||
need to manually copy files like lmplmp_g++.so into the site-packages
|
need to manually copy files like lmplammps_g++.so into the appropriate
|
||||||
directory as well. This is not needed if you set the LD_LIBRARY_PATH
|
system directory. This is not needed if you set the LD_LIBRARY_PATH
|
||||||
environment variable as described above.
|
environment variable as described above.
|
||||||
</P>
|
</P>
|
||||||
<HR>
|
<HR>
|
||||||
@ -368,8 +374,8 @@ at the file src/library.cpp you will see that they correspond
|
|||||||
one-to-one with calls you can make to the LAMMPS library from a C++ or
|
one-to-one with calls you can make to the LAMMPS library from a C++ or
|
||||||
C or Fortran program.
|
C or Fortran program.
|
||||||
</P>
|
</P>
|
||||||
<PRE>lmp = lammps() # create a LAMMPS object using the default liblmp.so library
|
<PRE>lmp = lammps() # create a LAMMPS object using the default liblammps.so library
|
||||||
lmp = lammps("g++") # create a LAMMPS object using the liblmp_g++.so library
|
lmp = lammps("g++") # create a LAMMPS object using the liblammps_g++.so library
|
||||||
lmp = lammps("",list) # ditto, with command-line args, e.g. list = ["-echo","screen"]
|
lmp = lammps("",list) # ditto, with command-line args, e.g. list = ["-echo","screen"]
|
||||||
lmp = lammps("g++",list)
|
lmp = lammps("g++",list)
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|||||||
@ -103,11 +103,11 @@ system.
|
|||||||
For Python to invoke LAMMPS, there are 2 files it needs to have:
|
For Python to invoke LAMMPS, there are 2 files it needs to have:
|
||||||
|
|
||||||
python/lammps.py
|
python/lammps.py
|
||||||
src/liblmp.so :ul
|
src/liblammps.so :ul
|
||||||
|
|
||||||
Lammps.py is the Python wrapper on the LAMMPS library interface.
|
Lammps.py is the Python wrapper on the LAMMPS library interface.
|
||||||
Liblmp.so is the shared LAMMPS library that Python loads, as described
|
Liblammps.so is the shared LAMMPS library that Python loads, as
|
||||||
above.
|
described above.
|
||||||
|
|
||||||
You can insure Python can find these files in one of two ways:
|
You can insure Python can find these files in one of two ways:
|
||||||
|
|
||||||
@ -121,32 +121,38 @@ this to your ~/.cshrc file, one line for each of the two files:
|
|||||||
setenv PYTHONPATH ${PYTHONPATH}:/home/sjplimp/lammps/python
|
setenv PYTHONPATH ${PYTHONPATH}:/home/sjplimp/lammps/python
|
||||||
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src :pre
|
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src :pre
|
||||||
|
|
||||||
If you run the python/install.py script, you need to rerun it every
|
If you use the python/install.py script, you need to invoke it every
|
||||||
time you rebuild LAMMPS (as a shared library) or make changes to the
|
time you rebuild LAMMPS (as a shared library) or make changes to the
|
||||||
python/lammps.py file.
|
python/lammps.py file.
|
||||||
|
|
||||||
You can invoke install.py from the python directory as
|
You can invoke install.py from the python directory as
|
||||||
|
|
||||||
% python install.py :pre
|
% python install.py [libdir] [pydir] :pre
|
||||||
|
|
||||||
Prefix this command with "sudo" if it does not allow you to copy files
|
The optional libdir is where to copy the LAMMPS shared library to;
|
||||||
into the Python site-packages directory. If you do this, make sure
|
the default is /usr/local/lib. The optional pydir is where to copy
|
||||||
that the Python run by root is the same as the Python you run.
|
the lammps.py file to; the default is the site-packages directory
|
||||||
E.g. you may need to do something like
|
of the Python running the install script.
|
||||||
|
|
||||||
% sudo /usr/local/bin/python install.py :pre
|
Prefix the python command with "sudo" if it does not allow you to copy
|
||||||
|
files into system directories. 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
|
||||||
|
|
||||||
You can also invoke install.py from the src directory as
|
You can also invoke install.py from the src directory as
|
||||||
|
|
||||||
% make install-python :pre
|
% make install-python :pre
|
||||||
|
|
||||||
Again, you may need to prefix this with "sudo". In this mode you
|
In this mode you cannot append optional arguments. Again, you may
|
||||||
cannot control which Python root invokes.
|
need to prefix this with "sudo". In this mode you cannot control
|
||||||
|
which Python is invoked by root.
|
||||||
|
|
||||||
Note that if you want Python to be able to load different versions of
|
Note that if you want Python to be able to load different versions of
|
||||||
the LAMMPS shared library (see "this section"_#py_5 below), you will
|
the LAMMPS shared library (see "this section"_#py_5 below), you will
|
||||||
need to manually copy files like lmplmp_g++.so into the site-packages
|
need to manually copy files like lmplammps_g++.so into the appropriate
|
||||||
directory as well. This is not needed if you set the LD_LIBRARY_PATH
|
system directory. This is not needed if you set the LD_LIBRARY_PATH
|
||||||
environment variable as described above.
|
environment variable as described above.
|
||||||
|
|
||||||
:line
|
:line
|
||||||
@ -363,8 +369,8 @@ at the file src/library.cpp you will see that they correspond
|
|||||||
one-to-one with calls you can make to the LAMMPS library from a C++ or
|
one-to-one with calls you can make to the LAMMPS library from a C++ or
|
||||||
C or Fortran program.
|
C or Fortran program.
|
||||||
|
|
||||||
lmp = lammps() # create a LAMMPS object using the default liblmp.so library
|
lmp = lammps() # create a LAMMPS object using the default liblammps.so library
|
||||||
lmp = lammps("g++") # create a LAMMPS object using the liblmp_g++.so library
|
lmp = lammps("g++") # create a LAMMPS object using the liblammps_g++.so library
|
||||||
lmp = lammps("",list) # ditto, with command-line args, e.g. list = \["-echo","screen"\]
|
lmp = lammps("",list) # ditto, with command-line args, e.g. list = \["-echo","screen"\]
|
||||||
lmp = lammps("g++",list) :pre
|
lmp = lammps("g++",list) :pre
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user