[lammps-users] compute reduce command

Dear Steve,
I have a quick question.

In LJ units, all the quantities are printed out in (per units) in the log file. So, when we calculate any quantity by a compute and reduce it as a sum using reduce style, we get the per unit quantity. Here I was hoping that reduce style sums up the array and divides up with the no of elements in the array. However, when I am calculating a quantity for a group ( which is part of the system), it is dividing the summation by total no of atoms instead of no. of atoms in the group. Is it intended this way? I will put my example to clarify the situation better.

I was printing out the Szz component of the stress for my system. I was also printing out the values of Szz in the dump file for some other calculations for all atoms. I summed up the stress from the dump file for a snapshot in order to observe this behavior.

Summation of Szz for whole system is -2168 (over 18610 atoms). So average stress ( in energy units) should be ~ -0.1165. I am getting this correct in the log file. However for a group that I am interested in, the summation of Szz is -4785 (over 2160 atoms). So, average stress for group temp should be -4785/2160 = -2.21. However, in the output I am getting -4875/18610 = -0.26. Here, I tried compute reduce command two ways
#1.
compute str all stress/atom
compute savg temp reduce sum c_str[3]

#2

compute str temp stress/atom
compute savg temp reduce sum c_str[3]

I got the same output ( in the log file) both times.

Please advice.
Regards,
Vikas

The normalization by total number of atoms is done by thermo output
(it can be turned on or off). It really doesn't know anything about what
computes were used to compute things, nor would it know how to
divide by the number of atoms in a group that was peculiar to the compute.

So I suggest you create a variable that uses the result from the compute
and normalizes the quantity however you like. Then print out the variable
with thermo instead of the compute. Note that variables can access group
properties, e.g. count(group).

Steve

Dear Steve,
Thanks for the clarification. I will use what you suggested. It should print out output as I wanted.

Many regards,
Vikas