Skip to content
Snippets Groups Projects
Commit 5c588814 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8673 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 2e7bd336
No related branches found
No related tags found
No related merge requests found
...@@ -58,12 +58,13 @@ operations within LAMMPS, such as running a simulation for a ...@@ -58,12 +58,13 @@ operations within LAMMPS, such as running a simulation for a
reasonable number of timesteps, then the overhead cost of invoking reasonable number of timesteps, then the overhead cost of invoking
LAMMPS thru Python will be negligible. LAMMPS thru Python will be negligible.
</P> </P>
<P>Before using LAMMPS from a Python script, you have to do two things. <P>Before using LAMMPS from a Python script, you need to do two things.
You need to set two environment variables. And you need to build You need to build LAMMPS as a dynamic shared library, so it can be
LAMMPS as a dynamic shared library, so it can be loaded by Python. loaded by Python. And you need to tell Python how to find the library
Both these steps are discussed below. If you wish to run LAMMPS in and the Python wrapper file python/lammps.py. Both these steps are
parallel from Python, you also need to extend your Python with MPI. discussed below. If you wish to run LAMMPS in parallel from Python,
This is also discussed below. you also need to extend your Python with MPI. This is also discussed
below.
</P> </P>
<P>The Python wrapper for LAMMPS uses the amazing and magical (to me) <P>The Python wrapper for LAMMPS uses the amazing and magical (to me)
"ctypes" package in Python, which auto-generates the interface code "ctypes" package in Python, which auto-generates the interface code
...@@ -131,7 +132,7 @@ python/lammps.py file. ...@@ -131,7 +132,7 @@ 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 <B>libdir</B> <B>pydir</B> <PRE>% python install.py [libdir] [pydir]
</PRE> </PRE>
<P>The optional libdir is where to copy the LAMMPS shared library to; the <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 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 ...@@ -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 need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
accordingly, as above. accordingly, as above.
</P> </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, 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 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 run. E.g. you may need to do something like
</P> </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> </PRE>
<P>You can also invoke install.py from the make command in the src <P>You can also invoke install.py from the make command in the src
directory as directory as
...@@ -275,8 +276,8 @@ If the load fails, the most common error to see is ...@@ -275,8 +276,8 @@ If the load fails, the most common error to see is
<PRE>OSError: Could not load LAMMPS dynamic library <PRE>OSError: Could not load LAMMPS dynamic library
</PRE> </PRE>
<P>which means Python was unable to load the LAMMPS shared library. This <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 typically occurs if the system can't find the LAMMPS shared library or
or one of the auxiliary shared libraries it depends on. one of the auxiliary shared libraries it depends on.
</P> </P>
<P>Python (actually the operating system) isn't verbose about telling you <P>Python (actually the operating system) isn't verbose about telling you
why the load failed, so carefully go through the steps above regarding why the load failed, so carefully go through the steps above regarding
......
...@@ -55,12 +55,13 @@ operations within LAMMPS, such as running a simulation for a ...@@ -55,12 +55,13 @@ operations within LAMMPS, such as running a simulation for a
reasonable number of timesteps, then the overhead cost of invoking reasonable number of timesteps, then the overhead cost of invoking
LAMMPS thru Python will be negligible. LAMMPS thru Python will be negligible.
Before using LAMMPS from a Python script, you have to do two things. Before using LAMMPS from a Python script, you need to do two things.
You need to set two environment variables. And you need to build You need to build LAMMPS as a dynamic shared library, so it can be
LAMMPS as a dynamic shared library, so it can be loaded by Python. loaded by Python. And you need to tell Python how to find the library
Both these steps are discussed below. If you wish to run LAMMPS in and the Python wrapper file python/lammps.py. Both these steps are
parallel from Python, you also need to extend your Python with MPI. discussed below. If you wish to run LAMMPS in parallel from Python,
This is also discussed below. 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) The Python wrapper for LAMMPS uses the amazing and magical (to me)
"ctypes" package in Python, which auto-generates the interface code "ctypes" package in Python, which auto-generates the interface code
...@@ -127,7 +128,7 @@ python/lammps.py file. ...@@ -127,7 +128,7 @@ 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 [libdir] [pydir] :pre % python install.py \[libdir\] \[pydir\] :pre
The optional libdir is where to copy the LAMMPS shared library to; the 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 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 ...@@ -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 need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
accordingly, as above. 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, 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 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 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 You can also invoke install.py from the make command in the src
directory as directory as
...@@ -271,8 +272,8 @@ If the load fails, the most common error to see is ...@@ -271,8 +272,8 @@ If the load fails, the most common error to see is
OSError: Could not load LAMMPS dynamic library :pre OSError: Could not load LAMMPS dynamic library :pre
which means Python was unable to load the LAMMPS shared library. This which means Python was unable to load the LAMMPS shared library. This
typically occurs if the system can't find the LAMMMPS shared library typically occurs if the system can't find the LAMMPS shared library or
or one of the auxiliary shared libraries it depends on. one of the auxiliary shared libraries it depends on.
Python (actually the operating system) isn't verbose about telling you Python (actually the operating system) isn't verbose about telling you
why the load failed, so carefully go through the steps above regarding why the load failed, so carefully go through the steps above regarding
......
...@@ -850,7 +850,7 @@ should be the file /usr/local/lib/libmpich.so. ...@@ -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 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 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 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 current version of the shared library is always available to programs
that use it. that use it.
</P> </P>
......
...@@ -844,7 +844,7 @@ The operating system finds shared libraries to load at run-time using ...@@ -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 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 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 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 current version of the shared library is always available to programs
that use it. that use it.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment