25 views

Skip to first unread message

Mar 31, 2023, 2:41:04 PMMar 31

to hoomd-users

Hi,

I am attempting to change the particle orientation so that they face the point (0,0) in the center of my 2d box, but I am running into issues when y< 0. When y is less than 0, the particles orient toward the left side of the box rather than the center. It works correctly if y>0 which seems even stranger to me. I have attached the custom action I am using to accomplish this.

Apr 3, 2023, 9:27:14 AMApr 3

to hoomd...@googlegroups.com

Benjamin,

The range of the arctangent is [-pi/2, pi/2]. Use arctan2: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html#numpy.arctan2

------

Joshua A. Anderson, Ph.D.

Research Area Specialist, Chemical Engineering, University of Michigan

On Mar 31, 2023, at 2:41 PM, Benjamin Sykes <bb...@email.unc.edu> wrote:

Hi,I am attempting to change the particle orientation so that they face the point (0,0) in the center of my 2d box, but I am running into issues when y< 0. When y is less than 0, the particles orient toward the left side of the box rather than the center. It works correctly if y>0 which seems even stranger to me. I have attached the custom action I am using to accomplish this.

--

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/649a19af-8dfe-45ce-9bdf-74e0ca831d29n%40googlegroups.com.

<rereorient(2).py>

Message has been deleted

Message has been deleted

Apr 12, 2023, 3:41:30 PMApr 12

to hoomd...@googlegroups.com

Benjamin,

I don't know who told you to "point in the direction of the particle's orientation in a 2d sim". You should choose a natural direction for the force in the local reference frame (e.g. +x or +y) unless you have an anisotropic particle with a particular feature in in that direction (e.g. the vertex of a square).

Regardless, the documentation states (https://hoomd-blue.readthedocs.io/en/v3.10.0/module-md-force.html#hoomd.md.force.Active):

Active computes an active force and torque on all particles selected by the filter:\begin{split}\vec{F}_i = \mathbf{q}_i \vec{f}_i \mathbf{q}_i^* \\\vec{\tau}_i = \mathbf{q}_i \vec{u}_i \mathbf{q}_i^*,\end{split}where \vec{f}_i is the active force in the local particle coordinate system (set by `active_force`) and \vec{u}_i is the active torque in the local particle coordinate system (set by `active_torque`.

Given your numbers, the vector f (in the particle reference frame) is pointing up and to the right and you are rotating counterclockwise by ~90 degrees to get a force pointing up and to the left (in the system reference frame). This is the expected behavior given your input.

>>> import rowan

>>> import numpy

>>> v = [1/numpy.sqrt(3), 1/numpy.sqrt(3),0]

>>> q = [0.708042353482036, 0, 0, 0.7061699693952015]

>>> rowan.rotate(q,v)

array([-0.57581945, 0.57887704, 0. ])

>>> rowan.to_axis_angle(q)

(array([[0., 0., 1.]]), array([1.56814838]))

------

Joshua A. Anderson, Ph.D.

Research Area Specialist, Chemical Engineering, University of Michigan

On Apr 11, 2023, at 11:53 AM, Benjamin Sykes <bb...@email.unc.edu> wrote:

Hi,I've attached the main code I am using. I am getting the correct angle as far as I can tell but have issues with either the forces or the quaternion part of my code. I ran the sim with a single particle in the lower left and made the reorientation updater print out the [cos(theta),0,0, sin(theta)] part, and I was getting the quaternion 0.708042353482036 + 0i+ 0j+ 0.7061699693952015k which is pointing in the correct direction. My current active force is added as active.active_force['A'] = (mag/np.sqrt(3), mag/np.sqrt(3),0) as I was told that should point in the direction of the particle's orientation in a 2d sim. Could that be where my problem lies? Thanks for any help you can provide

To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/c5e6faaf-2812-4925-8d3d-7b25a1f9c801n%40googlegroups.com.

<code.py>

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu