I am trying to calculate the stress tensor of a system of particles in 3d.
I want to precisely measure the 1st element of stress tensor, i.e
stress[1].I am using the following command.
"
compute stress all stress/atom virial
compute stress1 all reduce sum c_stress[1]
"
My question is, whether c_stress[1] produces the value of 1st element of
stress tensor averaged over no of particles or it calculates the sum of the
1st element of stress tensor of all the atoms?
I have gone through the doc page before applying this compute command. But
the value it produces is not matching with the analytic result.

The result produced by compute stress/atom is a per-atom value.
Obviously one atom’s value is not summed over atoms.

The result produced by compute reduce is stated on its doc page:

All the scalar or vector values calculated by this compute are “intensive”, except when the sum mode is used on per-atom or local vectors, in which case the calculated values are “extensive”.

So for you is it extensive, i.e. the sum over all atoms.

The result produced by compute stress/atom is a per-atom value.
Obviously one atom's value is not summed over atoms.

The result produced by compute reduce is stated on its doc page:

All the scalar or vector values calculated by this compute are
"intensive",
except when the *sum* mode is used on per-atom or local vectors, in which
case the calculated values are "extensive".

So for you is it extensive, i.e. the sum over all atoms.

In accordance with you feed back, lets say I have two atoms in a group
called 'mid'. Now once I am simulating and trying to measure c_stress1 of
that very group using the command
"
compute stress mid stress/atom
compute stress1 mid reduce sum c_stress[1]
"
I am getting the value averaged over the no of atoms, i.e by 2 in my case.
Whereas, when the group 'mid' contains one atom only I got the same value
of c_stress1 which I got for '2 atoms in group mid'.
This is where I am struck.

i’m not sure if this will resolve your issue, but at least for my simulations lammps typically normalizes the thermo output by the number of particles in the system.
use “thermo_modify norm no” to make your stress tensor scale with the particle number you compute it for.

This is correct and whether the normalization takes place
depends on the thermo_modify norm setting, and the default

depends on what units you are using, e.g. LJ units is normalized.

This is an output choice, but has nothing to do with what
compute reduce and compute stress/atom produce as their
result, which is as I indicated in my previous email.