Dear LAMMPS developers and users,

I hope you are all fine.

I encountered an issue on a very simple problem and I would appreciate your help.

I have a boxed system of 8000 atoms and I want to calculate the total energy for the lower part (~4000 atoms), for which I use the following commands as suggested in the documentation:

compute peratom group2 pe/atom

compute pe all reduce sum c_peratom

compute ke group2 ke

variable TEgroup2 equal “c_pe + c_ke”

as I plot all of them in the thermo output, I would expect to get the sum. However, what I get is completely different (units real):

c_pe c_ke TEgroup2 | etotal

0.93036943 0.46288194 -31448.341 | -7.8126787

I have also plotted the etotal thermo as a comparison.

Despite experimentation with the variable definition, I cannot see why I get this. I obviously do something wrong on the last variable, but what? Any ideas/corrections/comments?

Have a nice weekend,

Michail

Dear LAMMPS developers and users,

I hope you are all fine.

I encountered an issue on a very simple problem and I would appreciate your

help.

I have a boxed system of 8000 atoms and I want to calculate the total energy

for the lower part (~4000 atoms), for which I use the following commands as

suggested in the documentation:

compute peratom group2 pe/atom

compute pe all reduce sum c_peratom

compute ke group2 ke

variable TEgroup2 equal "c_pe + c_ke"

as I plot all of them in the thermo output, I would expect to get the sum.

However, what I get is completely different (units real):

c_pe c_ke TEgroup2 | etotal

0.93036943 0.46288194 -31448.341 | -7.8126787

I have also plotted the etotal thermo as a comparison.

Despite experimentation with the variable definition, I cannot see why I get

this. I obviously do something wrong on the last variable, but what? Any

ideas/corrections/comments?

it is difficult to comment on such incomplete input. the numbers you

have in your output suggest, that you are using

thermo_modify norm yes (norm no is the default for units real, only

with units lj the default is norm yes)

while for your pe and ke compute, it can be detected for over how many

atoms this is computed and thus the thermo output will normalize it

accordingly, after the equal style variable operation, that

information is lost and thus the sum cannot not be normalized.

axel.

Yes! Yes, you are of course right Axel, I totally forgot to divide the total energy by the number of atoms.

Thank you very much, I can now continue my work in peace (and shame)!

Best,

Michail