Fixing TABLE potential and LAMMPS pair_write differences

I have been using pair_style table for some of the interactions in my simulation. As the manual suggested, I wrote the potential that LAMMPS reads from the table using the pair_write command. When I plot the energy/forces values obtained from pair_write with the original one from the table file, I see huge differences at low values of separation. The log file has a count of exactly how many of the values are mismatched (WARNING: 1501 of 5000 force values in table BP_OO are inconsistent with -dE/dr.).

I have tried increasing/decreasing the number of points at which the energy/force values are calculated which did not really help a lot.
Can you suggest anything that I should be trying?

Thank you.

This suggests that there is an inconsistency in your table file.
Please provide the ‘before’ and ‘after’ table files.

When I try to upload it says “Sorry, new users can not upload attachments.”
I have added the head of the files here:
pair_write output file head:

DATE: 2022-12-06 UNITS: metal Created by pair_write

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

BP_OO
N 5000 R 0.001 10

1 0.001 737071828331.592 2.50751832539613e+15
2 0.003000200040008 737012891328.764 7.52245508539568e+15
3 0.005000400080016 736895031656.598 1.25355874074102e+16
4 0.007000600120024 736718242731.955 1.75457122737938e+16
5 0.00900080016003201 736482523823.441 2.25516266773591e+16
6 0.01100100020004 736187874731.587 2.75521276113859e+16
7 0.013001200240048 735834295379.679 3.254601206923e+16
8 0.015001400280056 735421785731.913 3.75320770442677e+16
9 0.017001600320064 734950345769.339 4.25091195298816e+16
10 0.019001800360072 734419975480.98 4.74759365194574e+16

Tabulated potential file head

DATE: 2022-11-30 UNITS: metal Created by pair_write

Pair potential buck for atom types 3 3: i,r,energy,force

BP_OO
N 5000

1 0.0010000 737071813931.947144 2507518310996485.000000
2 0.0030000 17552674338.767441 19904732700162.269531
3 0.0050000 3087548931.927466 2100768293283.438965
4 0.0070000 982847804.137704 477664032810.911743
5 0.0090000 418000486.003241 158004183709.209045
6 0.0110000 211199015.264775 65318095448.231590
7 0.0130000 119639480.699351 31308731795.299053
8 0.0150000 73527083.633930 16675942568.148451
9 0.0170000 48031104.469995 9611871612.141392
10 0.0190000 32899557.248502 5890752303.092365

You can always upload the files elsewhere (e.g. google drive, dropbox or similar) and provide a link to that place. The partial files only help a little.

I would also like to see your LAMMPS input file. There are also potential issues from that.

Hi akolhmey,
I have added a link to my google drive that contains the pre and post potential files.

https://drive.google.com/drive/folders/1IadHqbXUkDqvxR9ju-LotEeasVC3o3Bj?usp=sharing

The input file is also added for reference.

Thank you

1 Like

That input file contains the explanation. The potential energy and force must be different with pair_write since you are applying a different potential. You are using pair style hybrid/overlay to add a coulomb force to the interactions of all atoms. That will, of course, be included into the potential that pair_write will write to the table. If you remove the coul/cut pair style from the pair_style and pair_coeff commands, the table will be quite different.

The point you have made is absolutely correct. The pair_write file is writing out the energy/forces values for a combination from the Coulomb and Buck terms. I tried setting up the simulation with just the Buck potential and checked how the pre and post potential for O-O interaction look. I see almost negligible difference between the energy forces values at low separation computed with and without the Coulomb term (less than 10^-6 % ) for the O-O pair. This is because the correction function that I have applied to the Buck potential at low separation is a very strong repulsion that is much much higher than the O-O repulsion. However, at large distances, the Coulomb contribution is designed to be dominant over the Buck.
I still see the value mismatch warning (WARNING: 1501 of 5000 force values in table BP_OO are inconsistent with -dE/dr.) even when the Coul pair_style is removed.
The issue I see is that there is a huge discrepancy between LAMMPS written values and supplied tabulated values at low separation.

This is due to a combination of three factors:

  • you have created a table with many data points down to a very short distance
  • LAMMPS uses an r**2 spacing table internally and then spline interpolation to redistribute the tabulated data
  • you do not provide the derivatives of the force at the edges of the table

The major issue is the r**2 spacing. In the internal table there are only two data points between the start of the table and a distance of 0.1. in combination with the crude approximation of the data at the edges, the first couple of spline coefficients are way off and thus also the data when writing out the potential back out. So the block of data that is has the “huge discrepancy” is derived from the same couple of “bad” coefficients.

FWIW, to confirm my explanation, I have created a modified pair style table that uses linear instead opf quadratic spacing internally and the bogus data at very low r is gone with that.

The good news is that atoms should not get this close for any reasonable use case, so the undesired energy and force values can be ignored.