Hi all,
I’m trying to get python interface to lammps working on my machine. Basically, based on LAMMPS manual I chose second option for using LAMMPS from python which is:
(2) Use LAMMPS in parallel, where each processor runs Python, but your Python program does not use MPI.
I followed the manual and I created a shared MPI library (I use MPICH2) which I have it installed under ~/packages/mpich2-1.4.1p1_Shared
Next I edited the setup.py of LAMMPS such that I have :
library_dirs = ["~/packages/mpich2-1.4.1p1_Shared/lib"]
libraries = [“mpich”,“mpl”,“pthread”]
however for include_dirs = ["…/src"] I changed it to include_dirs = ["/home/kasra/packages/mpich2-1.4.1p1_Shared/include"] because it couldn’t find mpi.h otherwise and I assumed I need to feed in the mpi include location not the lammps source files location, am I right?
So with all the changes I made I was able to build and install LAMMPS under /usr/local/lib/python2.5/site-packages which created following files under:
-rwxr-xr-x 1 root staff 11564946 2012-04-12 11:54 _lammps.so
-rw-r–r-- 1 root staff 5859 2012-04-12 15:32 lammps.py
-rw-r–r-- 1 root staff 5345 2012-04-12 16:06 lammps.pyc
-rw-r–r-- 1 root staff 254 2012-04-12 16:06 lammps-28Nov11.egg-info
I can import lammps module as : from lammps import lammps
and by dir(lammps) I get:
[‘del’, ‘doc’, ‘init’, ‘module’, ‘close’, ‘command’, ‘extract_atom’, ‘extract_compute’, ‘extract_fix’, ‘extract_global’, ‘extract_variable’, ‘file’, ‘get_coords’, ‘get_natoms’, ‘put_coords’]
which I assume lammps module has been imported successfully (?)
However, when I want to create a LAMMPS object by lmp = lammps() I get following error:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.6/dist-packages/lammps.py”, line 37, in init
raise OSError,“Could not load LAMMPS dynamic library”
OSError: Could not load LAMMPS dynamic library
Would you please tell me what is going wrong? And how can I handle this problem?
Best,
Kasra.