git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8673 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -55,12 +55,13 @@ operations within LAMMPS, such as running a simulation for a
|
||||
reasonable number of timesteps, then the overhead cost of invoking
|
||||
LAMMPS thru Python will be negligible.
|
||||
|
||||
Before using LAMMPS from a Python script, you have to do two things.
|
||||
You need to set two environment variables. And you need to build
|
||||
LAMMPS as a dynamic shared library, so it can be loaded by Python.
|
||||
Both these steps are discussed below. If you wish to run LAMMPS in
|
||||
parallel from Python, you also need to extend your Python with MPI.
|
||||
This is also discussed below.
|
||||
Before using LAMMPS from a Python script, you need to do two things.
|
||||
You need to build LAMMPS as a dynamic shared library, so it can be
|
||||
loaded by Python. And you need to tell Python how to find the library
|
||||
and the Python wrapper file python/lammps.py. Both these steps are
|
||||
discussed below. If you wish to run LAMMPS in parallel from Python,
|
||||
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)
|
||||
"ctypes" package in Python, which auto-generates the interface code
|
||||
@ -127,7 +128,7 @@ python/lammps.py file.
|
||||
|
||||
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
|
||||
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
|
||||
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
|
||||
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,
|
||||
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
|
||||
% sudo /usr/local/bin/python install.py \[libdir\] \[pydir\] :pre
|
||||
|
||||
You can also invoke install.py from the make command in the src
|
||||
directory as
|
||||
@ -271,8 +272,8 @@ If the load fails, the most common error to see is
|
||||
OSError: Could not load LAMMPS dynamic library :pre
|
||||
|
||||
which means Python was unable to load the LAMMPS shared library. This
|
||||
typically occurs if the system can't find the LAMMMPS shared library
|
||||
or one of the auxiliary shared libraries it depends on.
|
||||
typically occurs if the system can't find the LAMMPS shared library or
|
||||
one of the auxiliary shared libraries it depends on.
|
||||
|
||||
Python (actually the operating system) isn't verbose about telling you
|
||||
why the load failed, so carefully go through the steps above regarding
|
||||
|
||||
Reference in New Issue
Block a user