"bond_style table" problem: Segmentation fault (core dumped)

Dear lammps users,
I confront the error, “Segmentation fault (core dumped)”, when I use the bond_style table command. Besides,it is found that the computation is stopped at the line, “bond_coeff 1 bondLength.table bondHAM”. The help is really needed to find the solution to the problem, because the same error always appears in spite of my carrying out the simple test, whose bond tabulated potential, input file and data file in use could be downloaded from the attachment. And they are (a)bondLength.table, (b)in.BondTableTest, ©testModel.data, respectively, and shown briefly as follow,

(a) bondLength.table

Bond potential for harmonic

bondHAM
N 760

1 0.01 288.3872 152.2996
2 0.02 286.8662 151.8991
3 0.03 285.3492 151.4986
4 0.04 283.8363 151.0981
5 0.05 282.3273 150.6977


759 7.59 284.4983 -151.2735
760 7.60 286.0130 -151.6740

(b)in.BondTableTest
units real
boundary p p p
atom_style full
log log.testModel.txt

bond_style table linear 760
kspace_style none

read_data testModel.data

bond_coeff 1 bondLength.table bondHAM

neighbor 2.0 bin
neigh_modify delay 5 check yes

compute new3d all temp
compute my_pressure all pressure new3d

fix 1 all nvt temp 298.0 298.0 100.0

thermo 500
thermo_modify temp new3d
thermo_style custom mass lx ly lz temp pxx pyy pzz

reset_timestep 0
timestep 1
run 20000

print “all done”

©testModel.data
LAMMPS data file

2 atoms
1 atom types
1 bonds
1 bond types
0 angles
0 angle types
0 dihedrals
0 dihedral types
0 impropers
0 improper types

1.084406 51.598243 xlo xhi
-0.556915 49.956922 ylo yhi
1.551852 52.065690 zlo zhi

Masses

1 68.1198

Atoms

1 1 1 0.000000 28.312627 4.731786 41.196543 0 0 0
2 1 1 0.000000 28.892508 1.482578 39.845297 0 0 0

Bonds

1 1 1 2

bondLength.table (20 KB)

in.BondTableTest (498 Bytes)

testModel.data (397 Bytes)

Dear lammps users,
      I confront the error, "Segmentation fault (core dumped)", when I use
the bond_style table command. Besides,it is found that the computation is
stopped at the line, "bond_coeff 1 bondLength.table bondHAM". The help is
really needed to find the solution to the problem, because the same error
always appears in spite of my carrying out the simple test, whose bond
tabulated potential, input file and data file in use could be downloaded
from the attachment. And they are (a)bondLength.table, (b)in.BondTableTest,
(c)testModel.data, respectively, and shown briefly as follow,

the problem seems to be due to using a DOS format text file on a Linux machine.
this sould be to work around by using the dos2unix command on the
table and the segfault should go away.

alternately, you can also apply the following tiny change to the
source and it should be working, without the proper conversion.

axel.

forgot to copy the patch. here we are:

diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp
index cdccf6e..99d0bb2 100644
--- a/src/MOLECULE/bond_table.cpp
+++ b/src/MOLECULE/bond_table.cpp
@@ -304,7 +304,7 @@ void BondTable::read_table(Table *tb, char *file,
char *keyword)
   while (1) {
     if (fgets(line,MAXLINE,fp) == NULL)
       error->one(FLERR,"Did not find keyword in table file");
- if (strspn(line," \t\n") == strlen(line)) continue; // blank line
+ if (strspn(line," \t\n\r") == strlen(line)) continue; // blank line
     if (line[0] == '#') continue; // comment
     char *word = strtok(line," \t\n\r");
     if (strcmp(word,keyword) == 0) break; // matching keyword

axel.

not to mention that there are several problems with your input and
require correction.
before using a tabluated potential, i would absolutely start by
experimenting with a simple analytical bond model,
especially, since your tabulated bond potential very much seems to be
such a simple potential, i.e. harmonic one.

why use tabulation for this???

axel.

Dear Axel,

Thank you, Axel. You are absolutely right. The “segmentation fault” have vanished after using the dos2unix command to adjust the carriage return character.

My purpose of using the simple harmonic bond potential is just to search the reason for the error, and more complex potential is waiting for me.

Besides, the other mistakes of my input file have been corrected, and all the files are attached again as a special example, which is expected to be useful for other lammps users. The example could be carried out successfully on the LAMMPS (10 Feb 2015 version)


[bondLength.table|attachment](upload://ffIvEZ6lYS2eSUjFoyVMuT5yLhn.table) (20 KB)



[in.BondTableTest|attachment](upload://8auRbStKvA1zJt36qK61RTXV4mD.BondTableT) (520 Bytes)



[testModel.data|attachment](upload://sPGoRCfwp1FPsM15oJkcSQbKV3u.data) (351 Bytes)