pressure profile along z

71 views
Skip to first unread message

jude vishnu

unread,
Mar 20, 2023, 10:39:11 AM3/20/23
to hoomd-users
Dear all,
I wanted to used hoomdv3.7 to calculate the pressure tensor along the z direction of the simulation box. Is it possible to implement a on the fly calculation for this?
If so how should I approach this ? Any suggestions would be appreciated.

Regards,
Jude

Brandon Butler

unread,
Mar 21, 2023, 1:50:55 PM3/21/23
to hoomd...@googlegroups.com

Dear Jude,

You can get the pressure tensor from the thermodynamic quantities compute as the document says. https://hoomd-blue.readthedocs.io/en/v3.10.0/module-md-compute.html#hoomd.md.compute.ThermodynamicQuantities.pressure_tensor

Best,

Brandon

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/b04651ad-4a21-438c-b358-2b0a8d8e85c8n%40googlegroups.com.
--
Brandon Butler
MolSSI Fellow
PhD Candidate, Chemical Engineering and Scientific Computing | Glotzer Lab, University of Michigan
Email: butl...@umich.edu

jude vishnu

unread,
Mar 22, 2023, 5:28:35 AM3/22/23
to hoomd-users
Dear Brandon,
I think I may not have been clear in my previous mail. 
I want to divide my simulation box into thin slabs and calculate pressure tensor within these slabs. In hoomdv2 there was a grouping method which groups the particles based on positions and we were able to calculate the pressure for each of these groups. In v3 how can I implement the same so that I can plot pressure components as a function of z positions.

Regards,
Jude

Joshua Anderson

unread,
Mar 22, 2023, 8:23:42 AM3/22/23
to hoomd...@googlegroups.com
Jude,

I would not advise using filters and many ThermodynamicQuantities objects to do this. There is a lot of overhead in maintaining and updating so many groups of particles and the associated objects. Instead, access the virials and particle positions with the Python API and write your own binning/averaging method for the slabs using numpy.histogram. If this does not perform well enough, then implement it in C++ (and possibly on the GPU). 

This method is often mentioned on the mailing list, I would consider accepting a contribution to include in future HOOMD releases. However, I would only accept code based on a rigorously derived method documented in a peer reviewed publication. I say this because virials HOOMD calculates are pairwise, taking into account the periodic boundary conditions so that the sum of virials over the all pairwise interactions in the box is valid for computing the virial pressure on the entire system. Only that total sum is well defined, the individual terms in the sum can be arbitrarily chosen and rearranged to achieve it. I do not see how any arbitrary separation of terms (with positions somehow assigned) could ever lead to a correct "local virial pressure" like you ask for. That term is also not well defined. Pressure is an **intensive** thermodynamic variable. Perhaps you are interested in the local stress tensor?
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

jude vishnu

unread,
Mar 22, 2023, 11:59:43 AM3/22/23
to hoomd-users
Dear Joshua,
Sorry, I meant the local stress tensor.
I am attaching the article where this is mentioned. It looks like a manual. In section 6.1 one of this article they talk about calculating local pressure elements. They use this to calculate P_N(z) -P_T(z) in each slab (where P_N is normal and P_T parallel components of pressure elements).
Finally they integrate over z to get interfacial tension as a function of z. Interfacial tension everywhere except the interfaces will have non zero value.


Can I still calculate the local stress-tensor in each of these slabs. Would this be possible if I write a custom writer which creates groups of particles in each subbox then use property pressure tensor to get the pressure tensor in each of these subboxes?. But does the pressure tensor which I am getting for each of these subboxes normalized by simulation box volume of subbox volume?
Or are you suggesting that this is not the best way to do this?

Regards,
Jude



Joshua Anderson

unread,
Mar 22, 2023, 12:50:03 PM3/22/23
to hoomd...@googlegroups.com
Jude,

HOOMD-blue documents how it computes the virial and breaks the sum into per-particle terms:


You can confirm this by looking at the code: https://github.com/glotzerlab/hoomd-blue/search?q=virial.data+%3D

Use these along with the particle positions and numpy.histogram (or equivalent code) as I said previously to implement equation 27 of the article you linked to. This should be achievable in a few lines of Python code.

I would hesitate to implement the method as documented in that article blindly in a HOOMD release. It does not rigorously derive the property from first principles. The article also casually introduces the force between particle i and j as a function of z: f_ij(z). Forces are vectors and do not have a position in space. You could use the particle's positions, but what do you do when the two particles in the pair are in different slabs? What if they are in non-adjacent slabs? What about long range interactions where all particles interact with all other particles in all slabs? This expression may be accurate in some continuum limit, but the article includes no discussion of this fact or under what conditions the assumptions are violated.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.

Joshua Anderson

unread,
Mar 22, 2023, 12:55:47 PM3/22/23
to hoomd...@googlegroups.com
FYI: The documentation for the pairwise virial is missing a 1/2. HOOMD's assigns 1/2 of the computed virial each to particle i and j.

I'll fix this in the next release.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
Message has been deleted

Joshua Anderson

unread,
Apr 7, 2023, 9:23:07 AM4/7/23
to hoomd...@googlegroups.com
Jude,

Excellent, now you have all the information you need so that you can implement the method most appropriate to your model of interest.

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
On Apr 6, 2023, at 11:54 AM, jude vishnu <mohms...@gmail.com> wrote:

Dear Joshua,
I found few papers on the implementation of local pressure tensor. From what I understand from this they do take virial from the particles interacting with other particles in neighboring slabs. They weigh their contribution by a factor. There are many implementations of local pressure tensor calculations in GROMACs and LAAMPS using several methods like method of planes , Irwin Kirkwood1. It might be good to have this in hoomd's future releases. I am attaching few of the papers I found here.

Irving-Kirkwood method: https://doi.org/10.1063/1.1747782
This shows how to compute pressure profiles for mesh-based Ewald methodshttps://pubs.acs.org/doi/abs/10.1021/acs.jctc.6b00576
I hope these references can help.
Regards,
Jude
Reply all
Reply to author
Forward
0 new messages