A problem of "minor revised version of examples" about rigid-body

58 views
Skip to first unread message

Jinyuan Mao

unread,
Aug 23, 2021, 10:41:07 AM8/23/21
to hoomd...@googlegroups.com
Hi all,

I am testing an example in the manual, shown as below:
Screenshot from 2021-08-23 22-24-53.png

However, when I make a little change of this script like this:

uc = hoomd.lattice.unitcell(N=1,
                            a1 = [30, 0,0],
                            a2 = [0,30, 0],
                            a3 = [0,0,30],
                            dimensions=3,
                            position =[[1, 1/3, 0]],
                            type_name = ['R'],
                            mass = [1.0],
                            moment_inertia = [[1,1,1]],
                            orientation = [[1,0,0,0]]);
system = hoomd.init.create_lattice(unitcell=uc, n=[1,1,1]);
system.particles.types.add('A');
rigid = hoomd.md.constrain.rigid();
rigid.set_param('R',
                types=['A']*3,
                positions=[(0,0,0),(1,1,0),(2,0,0)]);
rigid.create_bodies()

I just got a undesired result performed in OVITO, the coordination of particle type R same as one of the particle type A, however my script gives different coordination. I didn't know what happened?
Screenshot from 2021-08-23 22-31-24.png

I am looking forward to your advice.
Best,
Jinyuan

Joshua Anderson

unread,
Aug 23, 2021, 4:21:12 PM8/23/21
to hoomd...@googlegroups.com
Jinyuan,

What happened is that HOOMD created a rigid body with the constituent particle positions you specified, then translated it to the position of the central particle in the box. All the particle positions and types in the OVITO screenshot are consistent with the positions you set in your script.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> On Aug 23, 2021, at 10:40 AM, Jinyuan Mao <maojin...@gmail.com> wrote:
>
> Hi all,
>
> I am testing an example in the manual, shown as below:
> <Screenshot from 2021-08-23 22-24-53.png>
>
> However, when I make a little change of this script like this:
>
> uc = hoomd.lattice.unitcell(N=1,
> a1 = [30, 0,0],
> a2 = [0,30, 0],
> a3 = [0,0,30],
> dimensions=3,
> position =[[1, 1/3, 0]],
> type_name = ['R'],
> mass = [1.0],
> moment_inertia = [[1,1,1]],
> orientation = [[1,0,0,0]]);
> system = hoomd.init.create_lattice(unitcell=uc, n=[1,1,1]);
> system.particles.types.add('A');
> rigid = hoomd.md.constrain.rigid();
> rigid.set_param('R',
> types=['A']*3,
> positions=[(0,0,0),(1,1,0),(2,0,0)]);
> rigid.create_bodies()
>
> I just got a undesired result performed in OVITO, the coordination of particle type R same as one of the particle type A, however my script gives different coordination. I didn't know what happened?
> <Screenshot from 2021-08-23 22-31-24.png>
>
> I am looking forward to your advice.
> Best,
> Jinyuan
>
>
> --
> 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/CAMai1Eryb3sNEvgz2eHgEdNozGZtbpW2G5geWV9JJ35KWYvrOQ%40mail.gmail.com.

Jinyuan Mao

unread,
Aug 24, 2021, 3:37:15 AM8/24/21
to hoomd-users
Hi Anderson,

As shown in OVITO, the coordination of three type A change to the (1,0.3333,0), (2,1.3333,0), (3,0.3333,0) respectively.However in my script it was (0,0,0), (1,1,0), (2,0,0). I don't know why it changed, cause the coordination of R is exactly the center of these three positions of A.

Then I make another test as below, in this test, I set the position R as (0,0,0), and set the three type A as (-1,-1,0), (1,-1,0), (0,2,0) respectively. Finally, I got an correct position matched with that in my script as shown in OVITO. So I am confused if I must set the position of center particle as (0,0,0)?

uc = hoomd.lattice.unitcell(N=1,
                            a1 = [30, 0,0],
                            a2 = [0,30, 0],
                            a3 = [0,0,30],
                            dimensions=3,
                            position =[[0, 0, 0]],
                            type_name = ['R'],
                            mass = [1.0],
                            moment_inertia = [[1,1,1]],
                            orientation = [[1,0,0,0]]);
system = hoomd.init.create_lattice(unitcell=uc, n=[1,1,1]);
system.particles.types.add('A');
rigid = hoomd.md.constrain.rigid();
rigid.set_param('R',
                types=['A']*3,
                positions=[(-1,-1,0),(1,-1,0),(0,2,0)]);
rigid.create_bodies()

Screenshot from 2021-08-24 15-22-12.png

Best,
Jinyuan

Joshua Anderson

unread,
Aug 24, 2021, 5:53:46 AM8/24/21
to hoomd...@googlegroups.com
Jinyuan,

As I said, the positions and types displayed by OVITO in your first message are consistent with your inputs.
Particle 0: [1, 0.333333, 0] == [1, 1/3, 0] + [0, 0, 0]
Particle 1: [1, 0.333333, 0] == [1, 1/3, 0] + [0, 0, 0]
Particle 2: [2, 1.333333, 0] == [1, 1/3, 0] + [1, 1, 0]
Particle 3: [3, 0.333333, 0] == [1, 1/3, 0] + [2, 0, 0]

As I said in my original message, HOOMD translated (by vector addition) the positions of the particles in the local reference frame of the body to the global reference frame of the simulation. If this concept is unfamiliar to you, I suggest you review vector addition in a textbook.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> On Aug 24, 2021, at 3:37 AM, Jinyuan Mao <maojin...@gmail.com> wrote:
>
> Hi Anderson,
>
> As shown in OVITO, the coordination of three type A change to the (1,0.3333,0), (2,1.3333,0), (3,0.3333,0) respectively.However in my script it was (0,0,0), (1,1,0), (2,0,0). I don't know why it changed, cause the coordination of R is exactly the center of these three positions of A.
>
> Then I make another test as below, in this test, I set the position R as (0,0,0), and set the three type A as (-1,-1,0), (1,-1,0), (0,2,0) respectively. Finally, I got an correct position matched with that in my script as shown in OVITO. So I am confused if I must set the position of center particle as (0,0,0)?
>
> uc = hoomd.lattice.unitcell(N=1,
> a1 = [30, 0,0],
> a2 = [0,30, 0],
> a3 = [0,0,30],
> dimensions=3,
> position =[[0, 0, 0]],
> type_name = ['R'],
> mass = [1.0],
> moment_inertia = [[1,1,1]],
> orientation = [[1,0,0,0]]);
> system = hoomd.init.create_lattice(unitcell=uc, n=[1,1,1]);
> system.particles.types.add('A');
> rigid = hoomd.md.constrain.rigid();
> rigid.set_param('R',
> types=['A']*3,
> positions=[(-1,-1,0),(1,-1,0),(0,2,0)]);
> rigid.create_bodies()
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/50df42c7-0315-48bf-bd84-8b40142ed574n%40googlegroups.com.
> <Screenshot from 2021-08-24 15-22-12.png>

Jinyuan Mao

unread,
Aug 25, 2021, 2:02:33 AM8/25/21
to hoomd-users
Thanks a lot, I got your detailed explain now.

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