Segmentation Fault in LAMMPS Run Command with Pre No Post No

Hi,

I am using LAMMPS as a library within my C++ driver code. The driver code displaces atoms in a loop in a particular fashion and calls LAMMPS using “run 0” statement to calculate the potential energy. To avoid re-initialization in every call of the run statement, I replaced “run 0” by “run 1 pre no post no” (as suggested in one of the previous posts) without defining any fix. This setting invokes a segmentation fault in the LAMMPS call. As a simple test case I built the following input script to displace one atom randomly and call run command in a loop. However, this script invokes a segmentation fault when “run 1 pre no post no” is used. It runs properly when “run 1 pre yes post no” is used. Could you please help me in sorting this issue ?

#Initialization

units real

atom_style full

boundary p p p

newton on on

dimension 3

#Force Fields

angle_style harmonic

bond_style harmonic

dihedral_style none

improper_style none

pair_style lj/cut/coul/cut 9

pair_modify mix arithmetic tail yes

special_bonds amber

#Atom definition

read_data data.System1.Min

#Settings

variable TimeStep equal 1 #fs

timestep ${TimeStep}

group t1 id 567

#Simulation

variable a loop 5

label loop

print “Value of a:$a”

displace_atoms t1 random 0.0001 0 0 55682 units box

thermo_style custom step temp press etotal ke pe

run 1 pre no post no

next a

jump Input.Relaxation loop

Hi,

I am using LAMMPS as a library within my C++ driver code. The driver code
displaces atoms in a loop in a particular fashion and calls LAMMPS using
“run 0” statement to calculate the potential energy. To avoid
re-initialization in every call of the run statement, I replaced "run 0" by
"run 1 pre no post no" (as suggested in one of the previous posts) without
defining any fix. This setting invokes a segmentation fault in the LAMMPS
call. As a simple test case I built the following input script to displace
one atom randomly and call run command in a loop. However, this script
invokes a segmentation fault when “run 1 pre no post no” is used. It runs
properly when “run 1 pre yes post no” is used. Could you please help me in
sorting this issue ?

​there is not enough information here:
- there is no mention of the exact LAMMPS version​ and platform you are
running on
- the data file is missing, so it is impossible to try reproducing the
segfault.
- it would be extremely helpful to have a stack trace indicating where the
segfault is happening, i.e. run the code under the control of a debugger
and request the strack trace after it segfaults.

axel.

Hi,

Thanks for your reply. As pointed out, I have attached the LAMMPS data file for the purpose of reproducing the segfault.

I encountered the segmentation fault error when I ran the input script in the following versions of LAMMPS and platforms

LAMMPS 7 Dec-2015 – Cent OS release 6.2 platform

LAMMPS 10 Feb 2015 – SuSE 11 Linux platform

LAMMPS 7 Jun 2013 – Cent OS release 6.2 platform

I got the following error messages upon running the script.

data.System1.Min (299 KB)

Hi,

Thanks for your reply. As pointed out, I have attached the LAMMPS data
file for the purpose of reproducing the segfault.

​ok. i can reproduce it and i think i see the problem in your input.
with "run pre no"​, you must not make any modifications to computes and
fixes, but you (needlessly) redefine the thermo_style inside your loop.
​this will (re-)​define some computes, which is not allowed. if you move
this line outside the loop, you should not get a segfault.

axel.

Hi,

Thanks for your reply. As pointed out, the script runs properly in a single processor after moving the “thermo_style” command outside the loop while retaining “run 1 pre no post no” command.

1.However, if I increase the number of processors to more than one (say 12 for example), the script doesn’t run throwing an error “Bond atom missing in box size check”. This is not due to bad initial structure as the same data file runs properly if I do re-initialization between every run (run 1 pre yes). This is also confirmed with many data files.

2.The problem seems to originate when I slightly perturb the atoms (using displace_atoms). Irrespective of the displacement I give (even for delx=0, which is equivalent to removing the command), LAMMPS throws me an error saying “Bond atom missing in box size check”. On the other hand if I remove displace_atoms, the script runs fine.

In short, is it a problem to couple displace_atoms in a loop without re-initialization between runs (run 1 pre no post no) and execute them in multiple processors. (The atomic displacements I make are either 0 are extremely small in the order of 1e-3)

It will be really great if you can help me resolve this issue.

Please note that I have attached the LAMMPS script and data file with this mail, if needed.

The script was tested in the following versions of LAMMPS.

LAMMPS 10 Feb 2015 – SuSE 11 Linux platform

LAMMPS 15 May 2015 – CentOS 5.11 Linux platform

Thanks

Sriramvignesh

data.System1.Min (299 KB)

Input.Relaxation (807 Bytes)

In general you can’t use run pre no post no, if you are

changing the system in between runs. There is a long

list of things you can’t do and not re-initialize. If your

loop runs fine when you run with pre yes, then you’re

doing one of the bad things. Why not just live with

pre yes, and not worry about it?

Steve