The rotation using quaternion in HPMC.

110 views
Skip to first unread message

Xuan Feng

unread,
Jun 19, 2023, 10:30:50 AM6/19/23
to hoomd-users
Dear all,

I am currently studying the use of quaternions to represent rotation in Monte Carlo simulations. As I am unfamiliar with quaternion usage, I have been examining the source code of HPMC in HOOMD for guidance. However, I have encountered a few questions:

1. In the file "hoomd-blue/hoomd/hpmc/Moves.h," specifically in the function "move_rotate(quat<Scalar>& orientation, RNG& rng, Scalar a)," I noticed the line "orientation = orientation * q" when working in 2D. Why is this term used instead of "orientation = q * orientation"?

2. In the case of 3D, the code contains "orientation += a * q" for rotation. Why is the "+=" operator used here instead of "orientation = a * q * orientation"?

3. Is the variable "a" in this context referring to "max_rotation_move"? When I use “tune” to adjust the rotation move size, am I adjusting the value of "a" here? If not, what can I do to implement the adaptive move size of rotations using quaternion?

I would greatly appreciate it if someone could provide answers to these questions. Thank you very much!

Best Regards,
Feng Xuan

Joshua Anderson

unread,
Jun 22, 2023, 2:11:34 PM6/22/23
to hoomd...@googlegroups.com
Feng Xuan,

To learn about quaternions, you can search the internet for resources. There is much literature on the topic in the graphics and game development community, as well as Wikipedia.

1. Order is not important here as the distribution of the rotation angle is symmetric about 0.

2. Please read the references mentioned in the code comments. These explain the algorithm.

3. max_rotation_move is the largest value of 'a' that the tuner will choose. See the Introduction to HOOMD-blue tutorial for a demonstration of the tuner.

Regarding your later questions on constraints: You have read the source code here and seen that these options are not available.
------
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/533fbd1f-265e-44b2-9e45-5a627eadbd75n%40googlegroups.com.

Xuan Feng

unread,
Jun 22, 2023, 10:10:48 PM6/22/23
to hoomd...@googlegroups.com
Hi Anderson,

Thank you so much for your reply. The answer is very helpful to me.

Regards,
Feng Xuan

Joshua Anderson <joaa...@umich.edu> 于2023年6月23日周五 02:11写道:
You received this message because you are subscribed to a topic in the Google Groups "hoomd-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hoomd-users/N0f001OHRZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/EE7550F1-BE3A-4F67-8A38-8FFC4C67122C%40umich.edu.

Xuan Feng

unread,
Jun 23, 2023, 12:35:54 PM6/23/23
to hoomd...@googlegroups.com
Hi Anderson,

I'm so sorry to bother you again. I just wonder is it possible to fix the position and orientation of some (not all) particles in HPMC? 

Thank you so much. Have a nice day!

Best Regards,
Feng Xuan

Xuan Feng <xuan.f...@gmail.com> 于2023年6月23日周五 10:10写道:

Joshua Anderson

unread,
Jun 23, 2023, 12:56:44 PM6/23/23
to hoomd...@googlegroups.com
Feng Xuan,

Yes. Assign the fixed particles their own type and set the move sizes d and a to 0 for that type.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

Xuan Feng

unread,
Jun 23, 2023, 1:34:05 PM6/23/23
to hoomd-users
Hi Anderson,

Ok, I'll try it. Thanks!

Regards,
Feng Xuan

Xuan Feng

unread,
Jun 24, 2023, 3:34:30 AM6/24/23
to hoomd...@googlegroups.com
Hi Anderson,

I tried this method, and it works. Thank you for your help. But I met other questions in my simulation system. My system is shown in the figure below. I construct two cuboid particle as the white wall in the box. I fixed the wall particle using mc.a and mc.d, and also turn off the interaction between wall particles using mc.interaction_matrix.

mc.d['cube'] = 0
mc.a['cube'] = 0
mc.interaction_matrix[('cube','cube')] = False

But when I run the simulate. there'll be a warning "*Warning*: Box size is too small or move size is too large for the minimum image convention.
Testing 117 images per trial move, performance may slow.This message will not be repeated." And the simulation is very slow. How can I improve the simulation performance in my system. 

And is there any way to turn off the periodic of the z direction of the box. I tried sim.state.box.periodic = [(True, True, False)] but it showed that "property 'periodic' of 'Box' object has no setter". And I think maybe I can use the hoomd.wall to restraint the move of particles on the z-direction. But I notice that hoomd.wall is not support  if I use the  ConvexSpheropolyhedronUnion integrate later. Is there any other solution?

Thank you again and I'm looking forward to your answer.

Best Regards,
Feng Xuan
image.png


Joshua Anderson <joaa...@umich.edu> 于2023年6月24日周六 00:56写道:

Brandon Butler

unread,
Jun 26, 2023, 10:35:20 AM6/26/23
to hoomd...@googlegroups.com

Hey Feng Xuan,

As the warning says, you either need a larger box/system or need to shorten your transnational move sizes for at least one type as they can jump far enough currently that HOOMD has to check multiple images. Also, periodic is an immutable property. There is no way in HOOMD to turn off periodicity. You can, however, as you have done, block off a dimension to give the effect of a nonperiodic z dimension.

Best,

Brandon

To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAFq-x5wy3WHxY91VospVqzj1EqTgGdzdORL9fRhoSQ7OXbrNSw%40mail.gmail.com.
--
Brandon Butler
MolSSI Fellow
PhD Candidate, Chemical Engineering and Scientific Computing | Glotzer Lab, University of Michigan
Email: butl...@umich.edu

Joshua Anderson

unread,
Jun 26, 2023, 10:51:11 AM6/26/23
to hoomd...@googlegroups.com
Feng Xuan,

Use smaller cubes.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
On Jun 26, 2023, at 10:35 AM, Brandon Butler <butl...@umich.edu> wrote:

Hey Feng Xuan,

As the warning says, you either need a larger box/system or need to shorten your transnational move sizes for at least one type as they can jump far enough currently that HOOMD has to check multiple images. Also, periodic is an immutable property. There is no way in HOOMD to turn off periodicity. You can, however, as you have done, block off a dimension to give the effect of a nonperiodic z dimension.

Best,

Brandon

On 6/24/23 03:34, Xuan Feng wrote:
Hi Anderson,

I tried this method, and it works. Thank you for your help. But I met other questions in my simulation system. My system is shown in the figure below. I construct two cuboid particle as the white wall in the box. I fixed the wall particle using mc.a and mc.d, and also turn off the interaction between wall particles using mc.interaction_matrix.

mc.d['cube'] = 0
mc.a['cube'] = 0
mc.interaction_matrix[('cube','cube')] = False

But when I run the simulate. there'll be a warning "*Warning*: Box size is too small or move size is too large for the minimum image convention.
Testing 117 images per trial move, performance may slow.This message will not be repeated." And the simulation is very slow. How can I improve the simulation performance in my system. 

And is there any way to turn off the periodic of the z direction of the box. I tried sim.state.box.periodic = [(True, True, False)] but it showed that "property 'periodic' of 'Box' object has no setter". And I think maybe I can use the hoomd.wall to restraint the move of particles on the z-direction. But I notice that hoomd.wall is not support  if I use the  ConvexSpheropolyhedronUnion integrate later. Is there any other solution?

Thank you again and I'm looking forward to your answer.

Best Regards,
Feng Xuan
Reply all
Reply to author
Forward
0 new messages