tabulating potentials

Dear all,

I am learning how to use the pair_style table command and now I am slightly confused as to how I produce the file format that is needed for this command to function properly. Having read the documentation I realise I need to use the following format:

#mypotential
potential
N 500 R 1.0 10.0

1 1.0 25.5 102.34
2 1.02 23.4 98.5

500 10.0 0.001 0.003

I am attaching the plotted potential (with the data file) as I have designed it, but am not sure whether I could automatically write a data file that LAMMPS uses to produce the correct output or whether I need to do this manually.

Any help is greatly appreciated, thanks in advance!

with best wishes,
Anna

pot005.dat (23.8 KB)

potential.jpeg

Tabular potentials are somewhat tricky because you also have to
specify the negative derivative of the potential you want to use. You
omitted this from the file you attached. (See comment below.)

Also: "awk" is your friend.

(Ironically I just posted a message saying "I think people who don't
know how to write scripts should be able to use lammps".)

Open up your .DAT file with a text editor (like vi emacs, notepad, or
textedit, -not word).

---- Here are some problems with your file: -----

First of all, why does your table contain entries for negative r
(negative radius)?
Delete those. Your table should contain 500 "r" values (first column)
ranging from "1.0" to "10.0" (because that's what you told it when you
said "N 500 R 1.0 10.0")

Then delete the non-numeric comments at the end of the file.

Your file has only 2 columns. Presumably, the radius and the
potential. You need a third column containing the NEGATIVE derivative
of the potential with respect to r (ie the force). pair_style table
does not attempt to infer this for you (I suppose somebody could add
this feature, but you would lose accuracy).

I will assume that you have a 3rd column with this information in your
pot005.dat file. In that you could use AWK to convert the data to
LAMMPS table format this way:

awk '{print NR" "$1" "$2" "$3}' < pot005.datt >> pot005.table

Then you could edit the file with a text editor, and add these 3 lines
to the top

Dear all,

I am learning how to use the pair_style table command and now I am slightly
confused as to how I produce the file format that is needed for this command
to function properly. Having read the documentation I realise I need to use
the following format:

the best way to get started with using tabulated potentials
is to try to reproduce a potential that is available analytically
in LAMMPS. for those, using the pair_write command is a
big help. you can then first tweak the pair_write parameters
until you get a good match, then adjust your script/program
to generate the table until you reproduce the file and finally
try out the potential that you want.

mind you, the potential that you want to model is going to
be very tricky since it has a very high gradients and is
very steep in parts. that will require using a very short
timestep and high resolution. is your intention to approximate
a hard sphere? in that case, you may be better off using
a granular potential.

cheers,
     axel.