[lammps-users] A problem when using mpirun to run python script of lammps

Dear all:
I want to loop the lammps program in a python script.

from lammps import lammps
for i in range(10):
lmp = lammps()
lmp.file(infile)
lmp.close()


When I use serial syntax, the loop can be executed. However, an error occurred when using the parallel syntax. The lammps program cannot be executed completely in the second loop.

Reading data file …
orthogonal box = (-16 -16 -16) to (16 16 16)
1 by 2 by 2 MPI processor grid
WARNING: Angle style in data file differs from currently defined angle style (…/read_data.cpp:559)
reading atoms …
1421 atoms
reading velocities …
1421 velocities
scanning bonds …
6 = max bonds/atom
scanning angles …
5 = max angles/atom
scanning dihedrals …
6 = max dihedrals/atom
reading bonds …
2077 bonds
reading angles …
1311 angles
reading dihedrals …
1545 dihedrals
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 0
special bond factors coul: 0 0 0
7 = max # of 1-2 neighbors
34 = max # of 1-3 neighbors
203 = max # of 1-4 neighbors
40 = max # of special neighbors
Reading data file …
orthogonal box = (-16 -16 -16) to (16 16 16)
1 by 2 by 2 MPI processor grid
reading atoms …
5473 atoms
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 0
special bond factors coul: 0 0 0
7 = max # of 1-2 neighbors
34 = max # of 1-3 neighbors
203 = max # of 1-4 neighbors
40 = max # of special neighbors
480 atoms in group rbc
1421 atoms in group cell
5473 atoms in group pipette
0 atoms in group water


The next message should be :Neighbor list information, But it has been stopped here and no longer continues to run. What could be the cause of this?

Shuai Zhang
Nankai University

there is no need to create a new LAMMPS instance for every iteration. what happens if you do this:

from lammps import lammps
lmp = lammps()
for i in range(10):
lmp.command(‘clear’)
lmp.file(infile)

lmp.close()

Axel

Thanks for your immediate answer.

After adopting your program, the result is the same as before. Only when np = 1 can be traversed completely.
In other cases, it is still stuck in the same position during the second execution.

Axel Kohlmeyer <[email protected]> 于2021年4月28日周三 下午8:23写道:

I cannot reproduce that behavior with the latest LAMMPS (patch) release version (8 April 2021).

i can run the following simplified script in the examples/peptide folder with mpirun -np 4 python test.py to completion. So my conclusion is that you are either using a LAMMPS version with a bug or - more likely - that there is something in your input that produces an error when run a second time in the same location.

Axel.

infile = ‘in.peptide’

from lammps import lammps

lmp = lammps()
for i in range(2):
lmp.command(‘clear’)
lmp.file(infile)
lmp.close()

for i in range(2):
lmp = lammps()
lmp.file(infile)
lmp.close()