Local surface tension calculation

Hi everyone, im tryng to calculate the surface tension for a 2D periodic slab of water. I want to measure the local surface tension on the Z direction.

For this propose i have been using the following script, where the stress/atom it’s used and divided by the binsize. After that, I make a sumatory for all the atoms in the bin slab.
I pretend to calculate the surface tension as "gamma = (Pz - 0.5(Px+Py))*dz, where dz is the bin height (I use 1D bins).
Is this the correct implementation ?
input1.lammps (2.2 KB)

You can double check your results by (1) computing the overall surface tension from the average pressure of the box, and then (2) summing across all the bins from your local surface tension calculation; these two results should match.

Note that using fix ave/chunk gives a rough estimate of the local surface tension, but it is techinically incorrect for the normal pressure (should be constant due to mechanical stability requirement). Using the Irving Kirkwood contour (compute stress/cartesian command — LAMMPS documentation) will give the correct normal pressure, but again for a planar interface it is trivially constant. In contrast, the local tangential pressure is ambiguous/ill-defined, so we cannot say which is correct.

Hi, thanks for the answer.
I tried with the following command

compute pstress all stress/cartesian z 0.5 x 22.12
fix stressfix all ave/time 10 10 1000 c_pstress[*] file stress_cartesian.out mode vector

But, after a few hundred of steps, the simulation stop and I get this message
" segmentation fault "