How to define the loop setting a series of LJ potential parameters

Dear LAMMPS community,

I plan to set a series of LJ potential parameters (sigma and epsilon) to calculate their corresponding system values, such as system density. For example, sigma varies in the range of (0.1, 0.5), and epsilon in the range of (100, 150). Since we can only define one set of parameters in pair_coeff during one run, but my goal is to define it once and run such loop automatically, my question is how to realize it in LAMMPS?

If I only do it in LAMMPS input file, is there any command can realize such loop and update the values of sigma and epsilon automatically?

Besides, is there any other available script (such as python) to update and substitute the parameters in LAMMPS input file firstly and then run LAMMPS?

Best wishes,

MC

1 Like

Besides, is there any other available script (such as python) to update and substitute the parameters in LAMMPS input file firstly and then run LAMMPS?

Sure there is. If you know a little bit of shell scripting then you can write a loop in any of those languages, and then pass a variable that is looped over to LAMMPS with the handy β€œ-var” switch.

In bash it would be something like this:

for sigma in 0.1 0.2 0.3 0.4 0.5

do

run lammps here, e.g. with lmp_mpi -var $sigma

done

You can nest loops too, so you can just loop over sigma and epsilon at the same time.

Dear LAMMPS community,

I plan to set a series of LJ potential parameters (sigma and epsilon) to
calculate their corresponding system values, such as system density. For
example, sigma varies in the range of (0.1, 0.5), and epsilon in the range
of (100, 150). Since we can only define one set of parameters in pair_coeff
during one run, but my goal is to define it once and run such loop
automatically, my question is how to realize it in LAMMPS?

you can reissue the pair_coeff command between runs and assign new values.
those new values can be input to LAMMPS in a large variety of ways.

If I only do it in LAMMPS input file, is there any command can realize such
loop and update the values of sigma and epsilon automatically?

yes, there are commands to do loops, there are commands to assign a
sequence of numbers to a variable and iterate through them. there are
commands to compute the value of a variable based on conditions (.e.g.
timestep number), there are commands to assign lists of values to
variables from files. you can do nested loops.
please read the documentation for the "variable", "next", "label" and
"jump" commands. some of the examples provided with LAMMPS make use of
those.

there even is the fix adapt command that can change supported
parameters, e.g. epsilon and sigma of lj/cut *during* a run according
to functions defined as equal style variables.

Besides, is there any other available script (such as python) to update and
substitute the parameters in LAMMPS input file firstly and then run LAMMPS?

those scripts are trivial to write yourself. you can use the LAMMPS
python interface directly or you can write a script/program to
generate a whole set of input files any process them one by one.

...and i probably still left out some possible ways to do the same.
study the LAMMPS manual, check out the examples and you'll see.

axel.