[lammps-users] implementing new potential in LAMMPS

Dear LAMMPS users and developers,

I need to use a potential which is not included in LAMMPS package and I thought
of implementing it myself. Since the potential is similar to an EAM potential,
with some additional angular dependent components I looked on how EAM
potentials are implemented in LAMMPS. I tried to understand by reading parts in
the code but I felt like I need some directions to begin with. I tried to
understand files like pair_eam_alloy.cpp but as far as I understood, they do
not calculate the forces but rather read the tables and prepare the arrays. Is
that true? Where then the forces are calculated from the potential? Any initial
help for how to tackle the problem will be acknowledged.
It is worth mentioning that I write in C or Fortran, and I'm not much familiar
with C++ but I guess that shouldn't be a problem to learn if I will know what I
should do.

Thank you in advance,
Dan

Dear LAMMPS users and developers,

I need to use a potential which is not included in LAMMPS package and I thought
of implementing it myself. Since the potential is similar to an EAM potential,
with some additional angular dependent components I looked on how EAM
potentials are implemented in LAMMPS. I tried to understand by reading parts in
the code but I felt like I need some directions to begin with. I tried to

dan,

the place to start is the documentation about extending LAMMPS,
and my second suggestion is to first try and implement a variant of
pair_lj.cpp. this way it is much easier to understand and to check
how to do this and then you can move on to your real project.

understand files like pair_eam_alloy.cpp but as far as I understood, they do
not calculate the forces but rather read the tables and prepare the arrays. Is
that true? Where then the forces are calculated from the potential? Any initial
help for how to tackle the problem will be acknowledged.
It is worth mentioning that I write in C or Fortran, and I'm not much familiar
with C++ but I guess that shouldn't be a problem to learn if I will know what I
should do.

actually, in this case, you ran into a c++ issue.

please have a look at the pair_eam.cpp code as well.
as explained in the documentation about extending lammps,
forces are computed in the compute() method. the class for
pair/eam/alloy is a derived class from the pair/eam class, and
thus only the code where pair/eam/alloy is different from pair/eam
is (re-)implemented. it is also important to note the difference
between regular and virtual methods.

in short, just base your modified pair potential on pair_eam.cpp
and pair_eam.h and you should be fine.

cheers,
    axel.

As Axel says, pair eam/alloy is derived from eam, which
contains the compute function. The only difference between
eam and eam/alloy is the format of the potential files. Once
they have set things up in internal data structures, the energy/force
computation is done the same way in both, hence they share
a common compute() method.

Steve