Implementing pair potential: How to pass the energy out of the "compute" ?

Dear Lammps Mailing list,

I have implemented a new potential in a pair_*.cpp file.

When testing it with a cg minimization I noticed a problem.

It correctly reads the forces, but not the energy.

And the energy is correctly computed inside the “compute” method.

The output I see for a simple test system:
«Step Temp E_pair E_mol TotEng Press
0 0 0 0 0 -27389.416
1 0 0 0 0 -27389.416
Loop time of 0.0313971 on 1 procs for 1 steps with 8 atoms

Minimization stats:
Stopping criterion = linesearch alpha is zero
Energy initial, next-to-last, final =
0 0 0
Force two-norm initial, final = 18.0897 18.0897
Force max component initial, final = 3.69255 3.69255
Final line search alpha, max atom move = 2.52217e-11 9.31323e-11
Iterations, force evaluations = 1 31
»

My questions (whose answer I couldn’t find in the manual so far) are:

  1. How can I communicate the energy of the system stored in a local variable in the “compute” method outside of it ?

Do I need to set a variable ?

I haven’t seen (or better understood) it from the “compute” of Tersoff potential and similar pair potentials …

What is missing ?

Is it evdwl ? But it does not work even if I set it …

  1. What are the meaning of eflag and vflag ?

I couldn’t figure that out …

Thank you very much in advance for your explanation

Best regards,

Daniele Scopece

Dear Lammps Mailing list,

I have implemented a new potential in a pair_*.cpp file.
When testing it with a cg minimization I noticed a problem.
It correctly reads the forces, but not the energy.
And the energy is correctly computed inside the "compute" method.

The output I see for a simple test system:
«Step Temp E_pair E_mol TotEng Press
       0 0 0 0 0 -27389.416
       1 0 0 0 0 -27389.416
Loop time of 0.0313971 on 1 procs for 1 steps with 8 atoms

Minimization stats:
  Stopping criterion = linesearch alpha is zero
  Energy initial, next-to-last, final =
                     0 0 0
  Force two-norm initial, final = 18.0897 18.0897
  Force max component initial, final = 3.69255 3.69255
  Final line search alpha, max atom move = 2.52217e-11 9.31323e-11
  Iterations, force evaluations = 1 31
»

My questions (whose answer I couldn't find in the manual so far) are:

1) How can I communicate the energy of the system stored in a local variable
in the "compute" method outside of it ?
    Do I need to set a variable ?
    I haven't seen (or better understood) it from the "compute" of Tersoff
potential and similar pair potentials ...
    What is missing ?
    Is it evdwl ? But it does not work even if I set it ...

please look at pair_lj_cut.cpp. it doesn't get any simpler than that.
it is impossible to comment on code that we cannot see. if you do
things right, it works. if it doesn't work, you must be doing
something wrong.

2) What are the meaning of eflag and vflag ?
    I couldn't figure that out ...

o dear... have you heard of grep? quite a useful tool...

please see min.h/min.cpp and particularly the ev_set() and ev_setup()
methods. similarly in integrate.h/integrate.cpp

axel.