pair_style table and use of RSQ

Dear LAMMPS users,

I am using pair_style table to tabulate the potentials of J. Chem. Phys. 131, 014504 (2009) (Eqs. 2-3).

Here are the pair_style and pair_coeff commands I’m using:

pair_style hybrid zero 1.0 table linear 55000
pair_coeff 1 1 table potentials.table INV_POW
pair_coeff 2 2 table potentials.table GEN_GAUSS
pair_coeff 1 2 zero 1.0

where the number of points N=5500 is the same as the number of entries in both sections (INV_POW and GEN_GAUSS) of the .table file.

The distance values appearing in the .table file are uniformly spaced with spacing dr=10^-5 for both potentials.
Here is an extract my .table file:

INV_POW
N 55000 R 0.95 1.5

1 0.9500000000 2.8528500312e+04 6.0060000656e+06
2 0.9500100000 2.8468503803e+04 5.9933061343e+06
3 0.9500200000 2.8408634099e+04 5.9806391653e+06

GEN_GAUSS
N 55000 R 0.00001 0.55

1 0.0000100000 -1.0000000000e+00 -8.0752791445e-36
2 0.0000200000 -1.0000000000e+00 -4.1345429220e-33
3 0.0000300000 -1.0000000000e+00 -1.5894571940e-31

I have tried using the parameters R, RSQ and also no parameter.

With no parameter, everything works “almost” fine, apart from the following warning message:

WARNING: 2283 of 55000 force values in table are inconsistent with -dE/dr.
Should only be flagged at inflection points (…/pair_table.cpp:483)

which doesn’t worry very much since it should come from the inflection point of the GEN_GAUSS potential, and the number of problematic values is small compared to the total number of values (in case I’m wrong and I should be worried about this, please let me know).

When using the R parameter with rlo and rhi values corresponding to the smallest and largest distances appearing in two sections of the .table file, everything is fine, in the sense that I obtain the same warning message reported above.

However, when using RSQ with the same rlo and rhi values, e.g.:

INV_POW
N 55000 RSQ 0.95 1.5

I get more warnings:

WARNING: 54793 of 55000 force values in table are inconsistent with -dE/dr.
WARNING: 54998 of 55000 distance values in table with relative error
WARNING: 24791 of 55000 force values in table are inconsistent with -dE/dr.
WARNING: 54998 of 55000 distance values in table with relative error

My questions are:

  1. Am I using the RSQ parameter in the wrong way? As far as I understood, the same rlo and rhi values can be used with R or RSQ since the manual page says that “For “R”, distances uniformly spaced between rlo and rhi are computed; for “RSQ”, squared distances uniformly spaced between rlorlo and rhirhi are computed.”

  2. Why does the manual suggest to use the RSQ or BITMAP parameter in conjunction with the linear style (“Use N in the pair_style command equal to the “N” in the tabulation file, and use the “RSQ” or “BITMAP” parameter, so additional interpolation is not needed.”)? What is the drawback of using no parameter or the R parameter?

Please excuse me if these questions are trivial, but I started using tabulated potentials in LAMMPS fairly recently.

I also have a minor suggestion: it would be helpful if the warning message LAMMPS gives (force values in table are inconsistent with -dE/dr) would point out at which potential is problematic in cases in which multiple tabulated potentials are used (such as my case).

Thank you in advance.

Best regards,

Valerio

1 Like

Dear LAMMPS users,

I am using pair_style table to tabulate the potentials of J. Chem. Phys. 131, 014504 (2009) (Eqs. 2-3).

[…]

some general remarks about tabulation that may have escaped your attention:

  • when having limited experience with tables, it is a good idea to first practice with the lj/cut potential and use the pair_write command to create a table from it and then compare the results obtained with pair style lj/cut to those of pair style table. that way you can experiment with different settings like the number of points required, style of tabulation used and figure out how to obtain the desired accuracy
  • when reading the file LAMMPS will always create a spline table of energy and force to convert the file data to an internal table with data based on squared distances. thus is is recommended to use the pair_write command to write out the tabulated data to a different file and compare those to make certain there are no artifacts created by the spline interpolation.
  • when you have (too) many data points in your table file, the internal spline interpolation may pick up some noise (depending on the precision of the calculation used to create the table) and then have ondulations resulting in an increasing number of warnings about inconsistent data
  • you may consider using pair style python in combination with pair_write to generate your tables to ensure the file format is what LAMMPS expects. you can also use the pair style to test your potential functions directly. the benefit of using pair style table is its much faster execution over using python function evaluations.

My questions are:

  1. Am I using the RSQ parameter in the wrong way? As far as I understood, the same rlo and rhi values can be used with R or RSQ since the manual page says that “For “R”, distances uniformly spaced between rlo and rhi are computed; for “RSQ”, squared distances uniformly spaced between rlorlo and rhirhi are computed.”

rather than rely on the warning message, you should use the pair_write command and compare the internal table data from LAMMPS to your original table. that is the best way to determine the degree of deviation and identify problems with the (internal) spline interpolation.

  1. Why does the manual suggest to use the RSQ or BITMAP parameter in conjunction with the linear style (“Use N in the pair_style command equal to the “N” in the tabulation file, and use the “RSQ” or “BITMAP” parameter, so additional interpolation is not needed.”)? What is the drawback of using no parameter or the R parameter?

this is to reduce artifacts from the unavoidable internal spline interpolation. RSQ based tables are usually better suited for atomic potentials, since they have more data points at small r where the potential changes more and because LAMMPS computes squared distances internally, anyway.

for reasonably well behaved tables, the spline style can be the most accurate representation of the potential.

axel.

[…]

I also have a minor suggestion: it would be helpful if the warning message LAMMPS gives (force values in table are inconsistent with -dE/dr) would point out at which potential is problematic in cases in which multiple tabulated potentials are used (such as my case).

thanks for the suggestion. it is easy enough to implement and will be available in a future patch release of LAMMPS.

please note that the relevant table can also be easily identified from seeing which “pair_coeff” statement is executed.
to have commands echoed to the screen, you can use the flag -echo screen or -echo both.

axel.

Dear Axel,

Thank you very much for your answer.

For some reason I had thought that the input file could have the same distance values when using the parameter R or RSQ.

I now understand that when using RSQ one must use equally spaced squared distances (pretty obvious, in hindsight…).

The number of points I used might have been indeed too high. Using fewer points (10k) with RSQ gives me a much better result, with only one point being flagged as inconsistent with -dE/dr (which is what we expect, since the potential only has 1 inflection point).

When using R with the same number of points, only 288 points (2.9%) are flagged as inconsistent with -dE/dr, as opposed to the 2283 that were flagged when using 55k values (4.2%). It seems therefore that, as you said, using too many points is not always optimal. Just to be clear, in both cases a simple visual comparison of the .table file and of the file printed by pair_write doesn’t reveal any appreciable difference (when using the R parameter).

Also thanks for the suggestion of trying pair_style python and the spline style. I will look into those.

Best regards,

Valerio