Unable to access the logged quantities at each timestep.

34 views
Skip to first unread message

Avishek Kumar

unread,
Feb 28, 2023, 5:33:17 AM2/28/23
to hoomd-users
Hi,

I am working on the rheology of sticky polymers where beads are represented by stickers, and they are connected by springs. Now I aim to add an angle between the stuck stickers, which will allow me to modify the persistence length of the chains.
Now my simulation tracks the list of stuck sticker tags, which is saved as an "associations" list in the HOOMD script. 

system=hoomd.init.read_snapshot(snap)
trajWriter=hoomd.dump.gsd(filename= runname + ".gsd", group=all, period=1000, overwrite=True, dynamic=['momentum'])

trajWriter.log['associations']= lambda timestep: nl_functional.cpp_nlist.getNListArray(sticker_tags)

Now, I need to add an angle between the stuck stickers printed in 'associations' array, but I am unable to read the associations array at each timestep in the HOOMD script. For example, I can print the list using the callback function:

def printassoc(timestep):
                global asso
                asso=nl_functional.cpp_nlist.getNListArray(sticker_tags)
                print(asso)
                return  [asso]

hoomd.analyze.callback(callback=printassoc,period=1000)

For example, suppose I have two dumbbells: The "asso" will print the particle tags as [3,2,1,0] at each time step, where particle tag 3 is stuck to 0 and 2 is stuck with 1, etc. But now I need to instruct HOOMD to add angles between the stuck stickers (adding triplets as (0,1,2), (1,2,3) etc.), which can be done by the system.angles.add(....), but how can I instruct HOOMD to read the "asso" list at each timestep outside the function "printassoc" ? How can I access the "asso" list outside the function "printassoc" at each timestep? 

For example, for each timestep, the "asso" array will be read, and the angles will be added and removed at each timestep, and this should continue until the simulation ends. It will be grateful if someone guides me on how I can modify the HOOMD script.

Thanks and Regards,
Avishek

Joshua Anderson

unread,
Feb 28, 2023, 7:39:37 AM2/28/23
to hoomd...@googlegroups.com
Avishek,

PLEASE do not edit your posts in the web interface. Each time you edit, google sends a new e-mail message to all members.

You will find the latest version of HOOMD-blue, v3.9.0 has a vastly improved API over v2. We specifically designed the v3 API to support the type of customizations you are interested in implementing. Specifically:
- There is an official Python API for accessing the neighbor list: https://hoomd-blue.readthedocs.io/en/v3.9.0/module-md-nlist.html#hoomd.md.nlist.NeighborList.pair_list
- Use CustomUpdater as a base class for Python code that modifies the system state when triggered: https://hoomd-blue.readthedocs.io/en/v3.9.0/module-hoomd-update.html#hoomd.update.CustomUpdater

Your CustomUpdater class can store `asso` in a member variable so that it can be accesed from outside.
------
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/2dfdfa6a-dcbc-4f4b-bb63-500940a91a55n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages