building external force based on position

112 views
Skip to first unread message

Louis PERRIN

unread,
Sep 17, 2021, 3:38:04 AM9/17/21
to hoomd-users

Hello,
I am currently using HOOMD-Blue for some basic molecular dynamics. In my last project, I wanted to add some external force based on y position of each particle over time : if y(t)>=0, F(t)=(1,0,0), else, F(t)=(-1,0,0). In order to do that, I want to create two groups containing respectively particles with y position above 0, and particles with y position under 0.
There are two questions that I couldn't answer when I tried to do that : firstly, how can I access position of each particle at every time-step to update the groups ? Secondly, Are the group structures built to contain the same particles tags over the whole simulation or can the tags be modified at each time step ?

Thank you for reading my message.
Louis Perrin

Joshua Anderson

unread,
Sep 17, 2021, 8:55:30 AM9/17/21
to hoomd...@googlegroups.com
Louis,

1) Use the local snapshot API to access particle positions efficiently: https://hoomd-blue.readthedocs.io/en/latest/package-hoomd.html#hoomd.State.cpu_local_snapshot

2) Define a custom filter to select your particles: https://hoomd-blue.readthedocs.io/en/latest/module-hoomd-filter.html

3) Selected particle tags are cached for performance. You can force an update of that cache when needed: https://hoomd-blue.readthedocs.io/en/latest/module-hoomd-update.html#hoomd.update.FilterUpdater

------
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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/dd97a755-7102-4c10-a537-adacb8a176dcn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages