# [lammps-users] calculation of pressure tensor in a fixed group

Hi everyone,

I would like to calculate the pressure tensor in a fixed group of atoms in the none-periodic boundary conditions. The calculation process is described as follows. I have used the compute stress/atom command to obtain the stress tensor for each atoms in the given group. I first wrote a code to sum up all the stress per atoms to obtain the total value. Then I have calculated the total length along x, y, z direction in this group according to the coordinate of atoms. In this way I can get the volume of this group. According to the relationship between the average pressure tensor and the sum of the stress tensor per atoms (Pij=sum(Sij)/volume), where Pij, Sij , volume are pressure tensor of in the fixed group, stress tensor per atom and group volume. Thus, I can obtain the pressure tensor for the given group.
For the above words, I have three problems. First, I want to verify whether the calculation process is correct. Second, if it is correct, I think the calculation for volume is quite rough, especially for the simulation with none-periodic boundary condition, since the the shape of the sample will become quite irregular during the deformation. Thus, we can not simply using the box volume with a orthogonal shape to replace the real deformed shape. Third, can LAMMPS output the pressure tensor directly just like the pxx, pyy, pzz… in thermo_style command?
Thank you very for your help.

Best Regards,
Suzhi Li

LAMMPS can do all of this except the volume normalization, which
as you say, is ill-defined, so LAMMPS doesn't attempt it. You
can use compute reduce to sum per-atom stress over atoms in
a group or geometric region. You can use variable formulas to massage
that quantity, then output with thermo. If you just use pxx, pyy, etc
you will get the pressure tensor for the entire system.

Steve