Using md.angle in HOOMD-Blue 3.X

97 views
Skip to first unread message

Jasper Marcum

unread,
Jun 27, 2022, 5:03:44 PM6/27/22
to hoomd-users
Hi,

I've been attempting to simulate a simple harmonic angle bond in a three particle group but I have been struggling to implement it correctly. All of the available programs I can find online that use `md.angle` (or, more specifically, `md.angle.Harmonic()`) are using HOOMD version 2.X, and the syntax and assignment methods appear to have changed.

I have defined snapshot and hoomd.State attributes such as N_angles, angle_types, etc. (as you can see in the attached script), but I am receiving errors of the following form when I try to run the simulation:

`IncompleteSpecificationError: For <class 'hoomd.md.angle.Harmonic'> in TypeParameter params for key t0 value for key t0 is required`

What do I still need to specify, and how do I do it? Also, am I correctly specifying attributes such as snapshot.angles "group" and "typeid"? Help would be much appreciated. Thank you in advance. 

Best,
Jasper
angle attempt.py

Joshua Anderson

unread,
Jun 28, 2022, 9:33:06 AM6/28/22
to hoomd...@googlegroups.com
Jasper,

See the related example for bonds here: https://hoomd-blue.readthedocs.io/en/v3.2.0/howto/molecular.html . With minimal changes, this example could be modified to include angles.

Thanks for sharing a complete and minimal script that demonstrates the issue and asking specific questions. These changes are needed so the script will run without error:

You are not defining the angle types correctly, Line 38 should be: snapshot.angles.types = ['C-C-C']

Also, remove lines 61-63: 
hoomd.State.N_particles = 3
hoomd.State.N_angles = 1
hoomd.State.angle_types = harmonic.params['C-C-C']

With these lines, you are "monkey patching" and changing the code that the HOOMD-blue developers implemented for the `State` class. These change the expected behavior of `State` and create some of the problems in your script. As discussed in the tutorials, define the properties of your systems state via a Snapshot or a GSD file. An *instance* of `State` (in `sim.state`) provides access to these properties: e.g.:

>>> print(sim.state.angle_types)
['C-C-C']
------
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/642926a4-b409-4955-8788-e248ed958d0an%40googlegroups.com.
<angle attempt.py>

Jasper Marcum

unread,
Jun 28, 2022, 6:55:29 PM6/28/22
to hoomd-users
Joshua,

Thank you so much! I really appreciate it.

Jasper

Reply all
Reply to author
Forward
0 new messages