Two-Dimensional Rotation with Rigid Bodies

319 views
Skip to first unread message

Jared O'Leary

unread,
Mar 28, 2022, 4:36:13 PM3/28/22
to hoomd-users
Hi All:

I tried to set up a 2D patchy particle MD simulation using the rigid body paradigm in hoomd-blue. 

Interestingly, my particles do not rotate whatsoever. When I extend almost the exact same code to 3D, I see the rotation working fine. Can someone please look at this code snippet and tell me what is wrong? I would really appreciate any feedback. Thank you so much!

###############################################################
# Initialize snapshot
snapshot = gsd.hoomd.Snapshot()
snapshot.particles.N = num_particles
snapshot.particles.position = position[0:num_particles]
snapshot.particles.moment_inertia = [[1,1,0]]*num_particles
snapshot.particles.types = ['B', 'A']
snapshot.configuration.box = [L, L, 0, 0, 0, 0]
snapshot.particles.diameter = [diameter]*num_particles
with gsd.hoomd.open(name='IP.gsd', mode='xb') as f:
    f.append(snapshot)
   
rigid = hoomd.md.constrain.Rigid()
rigid.body['B'] = {
    "constituent_types": ['A'] * 3,
    "positions": [(diameter/2*np.cos(2*np.pi/3), diameter/2*np.sin(2*np.pi/3), 0),
                  (diameter/2*np.cos(np.pi/3), diameter/2*np.sin(np.pi/3), 0),
                  (diameter/2*np.cos(3*np.pi/2), diameter/2*np.sin(3*np.pi/2), 0)],
    "orientations": [(1.0, 0.0, 0.0, 0.0)]*3,
    "charges": [0.0]*3,
    "diameters": [diameter_patch]*3
    }
##############################################################

###############################################################
# Initialize integrator
integrator = hoomd.md.Integrator(dt=0.005, integrate_rotational_dof=True)
integrator.rigid = rigid

cell = hoomd.md.nlist.Cell(buffer=0.4)
lj = hoomd.md.pair.LJ(nlist=cell)
lj.params[('A', 'A')] = dict(epsilon=1, sigma=1)
lj.r_cut[('A', 'A')] = 2.5
lj.params[('B', ('A', 'B'))] = dict(epsilon=0, sigma=0)
lj.r_cut[('B', ('A', 'B'))] = 0
integrator.forces.append(lj)
nvt = hoomd.md.methods.Langevin(kT=1.5, filter=hoomd.filter.Rigid(("center", "free")))
integrator.methods.append(nvt)
###############################################################

###############################################################
# Initialize simulation
gpu = hoomd.device.GPU()
sim = hoomd.Simulation(device=gpu, seed=1)
sim.operations.integrator = integrator
sim.create_state_from_gsd(filename='IP.gsd')
rigid.create_bodies(sim.state)
sim.run(500)

Thanks a lot!

Jared

Jared O'Leary

unread,
Mar 28, 2022, 7:16:19 PM3/28/22
to hoomd-users
Just to clarify -- my issue here is that in 2D (i.e., when Lz = 0 in the simulation box), my rigid bodies do not seem to actually rotate.

In 3D, however, I have no problem with rotations. 

I am not clear why the the particles can rotate over all axes in 3D, whereas they don't seem to be able to rotate over any in 2D. 

Thanks!
Jared

Brandon Butler

unread,
Mar 30, 2022, 4:34:32 PM3/30/22
to hoomd...@googlegroups.com

Hey Jared,

You have no moment of inertia in z-axis which is the only one available for 2D. You need to set you moment of inertia to [0, 0, x] where x is the appropriate value.

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/7426c397-df88-47c4-8c17-7ec1c5e33d2cn%40googlegroups.com.
--
Brandon Butler
MolSSI Fellow
PhD Candidate, Chemical Engineering and Scientific Computing | Glotzer Lab, University of Michigan
Email: butl...@umich.edu

Jared O'Leary

unread,
Mar 31, 2022, 12:13:28 AM3/31/22
to hoomd-users
Hi Brandon:

This fixed the problem -- thank you so much! A few follow-up questions:

(1) How do I have intuition as to how to set my moment of inertia value? Could you possibly provide some example reasoning for similar problems you are aware of?

(2) I have set my orientation parameters as [1,0,0,0] based on a previous example Josh posted. But, I don't really understand that choice.

(3) How do the diameters of my "patches" affect the self-assembly? Do larger diameters of the patches really affect the inter-patch interactions?

Thank you so much for your help!

Best,
Jared

Brandon Butler

unread,
Mar 31, 2022, 10:47:00 AM3/31/22
to hoomd...@googlegroups.com

Hi Jared,

I am glad that helped.

  1. For some more info on rigid bodies and moment of inertia see https://github.com/glotzerlab/hoomd-examples/tree/rigid_body_tutorial. This will be a tutorial on the documentation website eventually. (Keep in mind patch are typically massless)
  2. [1, 0, 0, 0] is the unit quaternion in hoomd's conventions. A quaternion can be used to efficiently represent rotations in 3D. See https://en.wikipedia.org/wiki/Quaternion, for more information.
  3. The diameters in general won't come into play, unless you use a potential that uses them. The effective particle diameters are set by the range of the potential interactions.

Best,

Brandon

Jared O'Leary

unread,
Mar 31, 2022, 10:51:39 AM3/31/22
to hoomd-users
Thank you so much Brandon! I will make sure to look at this tutorial and let you know if I have any other questions!

Thanks again!
Jared

Jared O'Leary

unread,
Mar 31, 2022, 5:44:03 PM3/31/22
to hoomd-users
Hey Brandon:

All of these answers were really helpful, thank you! I have one last question, however:

Does HOOMD-blue support muVT MD simulations? I have seen muVT options for HPMC simulations, but no similar option for MD. If so, could you point me to some helpful resources? If not, why is this is the case?

Thanks again for all your help! I really appreciate it!

Best,
Jared
Reply all
Reply to author
Forward
0 new messages