# Pressure binning in x direction

Dear All,

I have to calculate the pressure profile binned in x direction for a VLE system of water. I am using compute stress/atom followed by the fix ave/spatial . Since the compute gives -(pressure* volume) values, what should the post processing step typically be? Should I divide the stress value by ( number. of atoms in the bin * volume of bin) ?

My inputfile is attached for reference.

I have read mails on this but I am unable to understand.

Sincerely,

Neha

I.I.T Kanpur,India

inputfile.docx (4.71 KB)

See the compute stress/atom doc page for the formulas

and how to convert per-atom stress to pressure.

If you can successfully do it for the entire box as one

volume, you should be able to do it for sub-volumes.

Steve

Dear All,

I have to calculate the pressure profile binned in x direction for a VLE
system of water. I am using compute stress/atom followed by the fix
ave/spatial . Since the compute gives -(pressure* volume) values, what
should the post processing step typically be? Should I divide the stress
value by ( number. of atoms in the bin * volume of bin) ?
My inputfile is attached for reference.

​please always attach input files in plain text and not some format that
may require multiple steps for people to even read them, let alone try them
out.​ the easier it is for people to follow what you are showing them, the
higher the chance to get (good) help.

I have read mails on this but I am unable to understand.

​please always remember, that a prerequisite for ​successful application of
a scientific software is that you are familiar with the underlying science.
you cannot expect that documentation and mailing list have prefabricated
answers for all questions. they provide the pieces and it is *your* task to
assemble them to a complete answer. so you should ask yourself: what
decides whether a property needs to be averaged over the number of
particles or not? what defines the volume for converting stress to
pressure? have you come across the term "intensive" and "extensive"
properties? it is probably a good idea to read up on all of this in a text
book on (statistical) thermodynamics and it also doesn't hurt to discuss

​axel.​

Thanks Steve,

from the stress/atom doc page, I could make out that for pxx binning in x direction, c_peratom[1] is which

((stress/atom)*volume) in x direction is to be multiplied by bin volume for converting it to pressure unit, and dimensionality will

be one in this case.Hope I have understood it right.

Thanks Axel.

You may also find it useful to look at this example simulation, which shows how to obtain stress components for a lipid bilayer, and should be easy to adapt for a water-vapor interface.
Post processing to obtain pressure profiles can be done with this script.

Mario

Thanks Mario,

So I was missing multiplying the number of atoms per bin.

Best Regards.

Depending on how you are aggregating the stress/atom data, you may
need to multiply by the number of atoms in each bin and/or divide by
the volume of the bin. It is not very hard to figure out the correct
formula for any particular situation by simply checking that your
calculation satisfies the volume-extensive nature of the virial. That
is, if a volume is divided into two regions A and B:

V(A) + V(B) = V(A+B)

then:

p(A)V(A) + p(b)V(B) = p(A+B)V(A+B)

This is the same check that is described on the stress/atom doc page,
where the simulation volume is divided in to N regions associated with
the N atoms.

compute peratom all stress/atom NULL
compute p all reduce sum c_peratom[1] c_peratom[2] c_peratom[3]
variable press equal -(c_p[1]+c_p[2]+c_p[3])/(3*vol)
thermo_style custom step temp etotal press v_press

Aidan

Thank a lot Aidan !

Regards,

Neha