bug report for pair_style table

I'm having trouble with pair_style table placing two different tables
in the same table file. I've included an example with 3 particles.
The first particle is a container whose position is fixed at the
origin. The other particles are trapped inside of it. I use
pair_style table to describe the interaction between those two
particles and the container particle:

pair_coeff 1 2 table table_container.dat CH_H0_475
pair_coeff 1 3 table table_container.dat CH_H0

The first table is an attractive interaction. Particle 2 should be
attracted to he wall.
The second table is repulsive. Particle 3 should be repelled away
from the wall.

However this is not what happened. When I run the simulation both
particles (2 and 3) stick to the wall.

(See attached figure.
You can also tell that something bad is going on using "pair_write":
pair_write 1 2 1001 r 0.00000000001 5.05 test_container_C-B.dat C-B 0 0
pair_write 1 3 1001 r 0.00000000001 5.05 test_container_C-L.dat C-L 0 0
These two commands print out the same table.)

The work-around is easy (use two different table files).
If that's what we should do, that's fine, (but please change the docs
to warn users).

I don't think there is an error in my table file.
But if there is, it would be better to have LAMMPS report it.

(I found a bug in dihedral_hybrid.cpp, and will post a fix for it later today.)


  As you can tell from this example, the particles can get arbitrarily
close to zero. I've been using using a radius of "0.00000000001" as
my first entry in the table to work around the requirement that radius
(separation distance between two particles) must be strictly positive.
It's not a big deal, but ff you are going to make modifications to
pair_table.cpp, can you change it to allow two particles to have a
separation-distance of zero? (Would a check for if (r<rtiny) (to
prevent divide-by-zero) slow down the code too much? If you don't
want to allow this, it's not a big deal.)

README.TXT (405 Bytes)

run.in.nvt (1.86 KB)

system.data (292 Bytes)

table_container.dat (98.6 KB)

The issue is that your second keyword is a subset of your first keyword. So another easy work-around would be to use two completely different keywords. To do a complete bug fix would require changing line 346 of pair_table.cpp:

    if (strstr(line,keyword) == line) break; // matching keyword

I think that using strcmp (and associated changes) would be a better choice than strstr, but Steve may have a better idea.


Here's a bug fixed version of pair_style table for the case when a keyword is a subset of another keyword (see attached). I've checked in the change to the repository, so it will go out as a patch soon.


pair_table.cpp (30.5 KB)

Thank you!
(Haven't tested it yet. Away from home. Will test soon.)


will be in a patch today ...


From: Crozier, Paul S [mailto:[email protected]]
Sent: Thursday, September 06, 2012 4:59 PM
To: Andrew Jewett; Plimpton, Steven J
Subject: Re: [lammps-users] [EXTERNAL] bug report for pair_style table

changing line 346 of pair_table.cpp:

    if (strstr(line,keyword) == line) break; // matching keyword

I think that using strcmp would be a better choice

Thanks for looking into this.

(and associated changes)

I'm glad you explained it because bug you pointed out effects my
dihedral_table.cpp code as well (and the other tabular styles).

The effected lines are:
bond_table.cpp, line 305
angle_table.cpp, line 382
dihedral_table.cpp, line 706

Please patch these files as well if you haven't already.

done - will be in next patch - thanks for picking up on this