Issue regarding pair_style table output values being incorrect

Dear LAMMPS users,
I am using LAMMPS(23 June 2022) version.

I want to implement a pair style as follows: a LJ 100-50 for a ‘5 sigma’ particle (So, I want a LJ 100-50 shifted with delta 4}) plus a Yukawa (also shifted by delta 4)) with some cutoff. Firstly, I realize that for 1 sigma particle, I can use hybrid overlay with pair_style mie cut and pair_style yukawa. So, it looks something like this “pair_style hybrid/overlay mie/cut 1.2 yukawa 1 5.0”.

To create my pair table for 5sigma particle, I use the above pair style and then pair_write with high number of points (around 10000 {I have tried going from small to large values but it doesn’t help}) with ‘rsq’ and a cutoffs of 0.82 and 5.0 to get my pair table.
It looks something like this

DATE: 2022-11-11 UNITS: lj Created by pair_write

Pair potential hybrid/overlay for atom types 1 1: i,r,energy,force

N 10000 RSQ 0.82 5

1 0.82 1662085833.19649 202698366140.986
2 0.821482199016102 1387461603.58881 168901876920.852
3 0.82296172851516 1158965684.67622 140832761546.345
4 0.824438602869243 968724357.237045 117504866788.195
5 0.825912836321921 810229181.073469 98104498494.8233

Then I simply add my delta r (delta = 4) to the ‘distance’ column inside this pair table. So, now the table I have corresponds to the pair style I need (For the 5sigma particle {Correct me if this doesn’t make sense})
This is how my table looks now:

#DATE: 11-11-2022 UNITS: lj CONTRIBUTOR: Sameer Kalghatgi
#SALR potential between particles of 5 sigma size

N 10000 RSQ 4.82 9

1 4.820000000000000 1662085833.19649004936218262 202698366140.98599243164062500
2 4.821482199016102 1387461603.58880996704101562 168901876920.85198974609375000
3 4.822961728515160 1158965684.67621994018554688 140832761546.34500122070312500
4 4.824438602869243 968724357.23704504966735840 117504866788.19500732421875000
5 4.825912836321921 810229181.07346904277801514 98104498494.82330322265625000

I maintain the decimal places for distance, potential energy and forces to 15,17 and 17 respectively.

Then, I use this table as the input table in my simulations. Now, I write out the pair table in the simulations to see what LAMMPS uses as the potential enregy and force. I use ‘pair_style table linear 10000’ , also I use RSQ with ‘Nfile=Ntable’ which means LAMMPS does not effectively interpolate anything extra and uses the table values as they are(which I want). However, when I plot the input table with the output table (Potential Energy vs r), here is what I observe:


There is a clear difference between what I give LAMMPS as the input and what it writes out as output. Any suggestions regarding same?

This is documented behavior! Please study the documentation of pair style table with more care. I’d like to particularly point out the following, highlighted “Note” section:

If you use “R” or “RSQ”, the tabulated distance values in the file are effectively ignored, and replaced by new values as described in the previous paragraph. If the distance value in the table is not very close to the new value (i.e. round-off difference), then you will be assigning energy/force values to a different distance, which is probably not what you want. LAMMPS will warn if this is occurring.

Thank you for your reply Axel.

I figured out the problem was using RSQ in the pair table when using it as an input in the simulation. Just changing it from “N 10000 RSQ 4.82 9” to “N 10000” did the job. The output table was much well behaved and only 4 values out of 10000 were flagged as inconsistent with -dE/dr. Thanks again.