How to calculate stress from bulk pressure

Dear All
Good day.

I have calculated the pressure tensor as per LAMMPS from compute pressure pxx, pyy pzz value. I want to calculate the stress in y direction of monolayer 2D material. And there X nm vacuum in (+ve) and (-ve) z direction. If the theoretical thickness of the monolayer material is Y nm. Computed pressure in y direction is pyy Mpa.

So stress in y direction.

Stress = (pyy*(X+X))/Y Mpa

Is this calculation is correct way to calculate stress.