# [lammps-users] Computing stress component

Hi All,

I am trying to calculate the "S_xy" component of stress tensor in two
different ways using the following commands.

variable natoms equal count(flow)
compute peratom flow stress/atom
compute sxy flow reduce sum c_peratom[4] -------------------> I
variable sxy equal c_sxy/\${natoms} ---------------------------> II

I expect the following commands to produce the same results. But I get
different results.
I am doing anything wrong here.

Srikanth

What are the 2 different ways? Variable sxy and what?
If its the thermo value pxy, then you should look at the example on the
compute stress/atom doc page. You are dividing by N and it divides
by volume. In some units those could be close which would yield

Steve

I didn't phrase the question properly. Here is the set of commands I am using

compute ke flow reduce sum c_ske[4]
compute pe flow reduce sum c_spe[4]
variable sum equal c_ke+c_pe

thermo_style custom step temp c_ke c_pe v_sum

I would expect "v_sum" value to be equal to "c_ke + c_pe" but the
values differ order of magnitude.

step temp ke
pe sum
0 1 -0.00022842113
-2.1389967e-17 -1.9187375
1000 0.94004956 -0.0076651828
-0.12053191 -1076.8555
2000 0.79135907 0.0058334427
-0.057779266 -436.34492
3000 1.2197396 -0.029784273
0.087836842 487.64158

Why is that?

Srikanth

A sequence of variable operations can be complicated.
There are intensive and extensive variables, normalizations
by Natoms or not or by volume or not (for pressure vs stress).
You'll need to read the doc pages and print out each variable's
value one by one if you don't understand the values.

Steve

Dear Srikant,
Do you have 8400 atoms in your system. If that is tha case, you need to create a new variable which is normalized by number of atoms (in the flow group).

What you are getting in v_sum is unnormalized value of Sxy while c_ke and c_pe are normalized. (by total number of atoms)

Regards,
Vikas