Vertex shape move: vertices not changing

146 views
Skip to first unread message

oyin

unread,
Sep 13, 2022, 10:10:46 PM9/13/22
to hoomd-users
Hi,
I've been working on a vertex shape move code however,  the vertices are not changing. I am wondering if there's something missing in my code.  Below is a sample of the code I run after importing the modules and creating the state.

hoomd.hpmc.shape_move.Vertex(default_step_size=1, vertex_move_probability=1) 
nselect =1

mc = hoomd.hpmc.integrate.ConvexPolyhedron(23456)
cube_verts = [(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)]
mc.shape["A"] = dict(vertices=numpy.asarray(cube_verts) / 2)
vertex_move = hoomd.hpmc.shape_move.Vertex()
vertex_move.volume["A"] = 1 

updater = hoomd.hpmc.update.Shape(shape_move=vertex_move, trigger=hoomd.trigger.Periodic(1))

    
tune = hoomd.hpmc.tune.MoveSize.scale_solver(moves=['a', 'd'],
                                             target=0.2,
                                             trigger= hoomd.trigger.Periodic(10),
                                             max_translation_move=0.2,
                                             max_rotation_move=0.2) 


I'd appreciate your suggestion.
Thanks

Joshua Anderson

unread,
Sep 14, 2022, 7:53:07 AM9/14/22
to hoomd...@googlegroups.com
Oyin,

Check the contents of `updater.shape_moves` (https://hoomd-blue.readthedocs.io/en/v3.4.0/module-hpmc-update.html#hoomd.hpmc.update.Shape.shape_moves). I would guess that all the proposed moves are rejected.

Your vertices have values around 0.05 and you set the step size to 1, so the trial moves are 20 times larger than the shape itself. Use a step size much smaller than the particle size.
------
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/69871c93-ebcd-48f9-9e89-5a437edf7596n%40googlegroups.com.

oyin

unread,
Sep 15, 2022, 12:22:45 AM9/15/22
to hoomd-users
Hi,
I followed the documentation example but I got this error  " TypeError: __init__() got an unexpected keyword argument "
I also used the initial code and reduced the step size but the vertices are still not changing
Please find attached some screenshots.

Thanks,
Oyin
h1.png
h3.png
h2.png

Joshua Anderson

unread,
Sep 15, 2022, 8:13:12 AM9/15/22
to hoomd...@googlegroups.com
Oyin,

You didn't share the values of `shape_moves` you obtain after running the simulation, nor do you share the value of the `default_step_size` you set, so I have no new information to help you with. The suggestions I made in my original reply are still relevant.

Regarding your screenshots (please, post text text time, it is much easier to read) - you are getting expected behavior.  The documentation for Vertex does `param_ratio` at all, nor does it document `stepsize` as a constructor argument: https://hoomd-blue.readthedocs.io/en/v3.4.0/module-hpmc-shape_move.html . 
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/bc868613-1dcb-4a1e-bf07-bec237bea731n%40googlegroups.com.
<h1.png><h3.png><h2.png>

oyin alabi

unread,
Sep 15, 2022, 2:01:22 PM9/15/22
to hoomd...@googlegroups.com

 Hi, 
Please find below the code, I set the stepsize to 0.0005
 
nselect =1
mc = hoomd.hpmc.integrate.ConvexPolyhedron(23456)
cube_verts = [(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)]

mc.shape['cube'] = dict(vertices=numpy.asarray([(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)])) 

vertex_move = hoomd.hpmc.shape_move.Vertex(default_step_size=0.0005,
                                           vertex_move_probability=1)
vertex_move.param_ratio=0.2
vertex_move.volume['cube']=1.0 
 
                                           

updater = hoomd.hpmc.update.Shape(shape_move=vertex_move, 
                                  trigger=hoomd.trigger.Periodic(1),
                                  type_select=1,
                                  nsweeps=1)

 
    
tune = hoomd.hpmc.tune.MoveSize.scale_solver(trigger= hoomd.trigger.Trigger(),
                                             moves=['a', 'd'],
                                             target=0.5,
                                             max_translation_move=0.2,
                                             max_rotation_move=0.2)    
 
render(sim.state.get_snapshot()) 


hoomd.write.GSD.write(state=sim.state, mode='wb', filename='sm9.gsd')   

After which I equlibrated the system and analyzed the trajectory, the cube moves around but the vertices are not changing. For the shape move values, I am not sure how to get those. 

The full code has a compression part to it and that works well, is there something wrong with the way I am defining the shape moves? 

Thanks,
Oyin 



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/XDwYmHLixIk/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/6BD39701-166F-4DAB-9C51-60D16D855897%40umich.edu.

Joshua Anderson

unread,
Sep 15, 2022, 2:37:55 PM9/15/22
to hoomd...@googlegroups.com
Oyin,

As I said, you should check the value of `updater.shape_moves` to see how many moves are accepted and rejected.

You set the volume of the 'cube' type to 1.0, so every vertex move will rescale the particle to a volume of 1.0. That is 1000 time larger than the volume of your initial cube, so I would guess that every vertex move results in an overlap and is rejected.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

oyin alabi

unread,
Sep 16, 2022, 5:14:42 PM9/16/22
to hoomd...@googlegroups.com
Hi,
I have 
changed the volume to 0.001 but the vertices is still not changing. I used 
the updater.shape_moves as suggested but i keep getting this error even 
after running the simulation for 100 steps
"DataAccessError: The property shape_moves is 
unavailable until the simulation runs for 0 or more steps"
Please 
find below the edited code

cube_verts = [(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),

        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)]

mc.shape['cube'] = dict(vertices=numpy.asarray([(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),

        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)])) 


vertex_move = hoomd.hpmc.shape_move.Vertex(default_step_size=0.0005,

                                           vertex_move_probability=1)

vertex_move.param_ratio=0.2

vertex_move.volume['cube']=0.001 

 

updater = hoomd.hpmc.update.Shape(shape_move=vertex_move, 

                                  trigger=hoomd.trigger.Periodic(1),

                                  type_select=1,

                                  nsweeps=1)

 

tune = hoomd.hpmc.tune.MoveSize.scale_solver(trigger= hoomd.trigger.Trigger(),

                                             moves=['a', 'd'],

                                             target=0.5,

                                             max_translation_move=0.2,

                                             max_rotation_move=0.2)    

sim.run(100) 

updater.shape_moves

render(sim.state.get_snapshot()) 

Thanks,




Luis Rivera-Rivera

unread,
Sep 16, 2022, 5:59:58 PM9/16/22
to hoomd...@googlegroups.com
Oyin,

For the updater to actually operate on the particles you need to add it explicitly to your list of operations as:

sim.operations.updaters.append(updater)
OR
sim.operations += updater

Joshua's suggestions are still very relevant, so keep them in mind.

Luis






--
Luis Y. Rivera-Rivera, PhD
(787) 806-7512
University of Michigan
Chemical Engineering and 
Scientific Computing

oyin alabi

unread,
Sep 22, 2022, 2:52:59 PM9/22/22
to hoomd...@googlegroups.com
Hi, 

The "updater.shape_moves" value is (10, 0 ), however, the vertices are still not changing.
Please find below the updated code.

Thanks.


nselect =0.0005
 
cube_verts = [(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)]
mc.shape['cube'] = dict(vertices=numpy.asarray([(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)])) 

vertex_move = hoomd.hpmc.shape_move.Vertex(default_step_size=0.0005,
                                           vertex_move_probability=1)
vertex_move.param_ratio=0.2
vertex_move.volume['cube']=0.001 
 
updater = hoomd.hpmc.update.Shape(shape_move=vertex_move, 
                                  trigger=hoomd.trigger.Periodic(1),
                                  type_select=1,
                                  nsweeps=1)

 
sim.operations.updaters.append(updater)

    
tune = hoomd.hpmc.tune.MoveSize.scale_solver(trigger= hoomd.trigger.Trigger(),
                                             moves=['a', 'd'],
                                             target=0.5,
                                             max_translation_move=0.2,
                                             max_rotation_move=0.2)
sim.run(10)
sim.operations.tuners.append(tune)
  
shapemove= updater.shape_moves
print("shape moves=",shapemove)

oyin

unread,
Sep 26, 2022, 11:40:35 AM9/26/22
to hoomd-users
Hi, 
Can someone please tell me what I am doing wrong, I have followed all the suggestions above and the "updater.shape_moves" value is (10, 0 ), however, the vertices are still not changing.

Joshua Anderson

unread,
Sep 26, 2022, 11:58:15 AM9/26/22
to hoomd...@googlegroups.com
Oyin,

Per the output you share, there are 10 accepted shape moves that changed the vertices. Your script doesn't indicate how you are observing the vertices, so no one has enough information to tell you what you are doing wrong.

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

oyin alabi

unread,
Sep 26, 2022, 12:19:01 PM9/26/22
to hoomd...@googlegroups.com
Hi,
I am using render_movie (using fresnel) in jupyter to see if the vertices are changing.
I am using "analyzing the trajectory " example on github.

Thanks,




Joshua Anderson

unread,
Sep 26, 2022, 12:31:27 PM9/26/22
to hoomd...@googlegroups.com
Oyin,

There is your problem. Look at the code for `render_movie`, it uses hard-coded vertices.

To confirm in your case that the vertices are changing, you can inspect the value of `mc.shape['cube']`.

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

oyin alabi

unread,
Sep 26, 2022, 4:51:30 PM9/26/22
to hoomd...@googlegroups.com
Hi,
I am not quite sure how to inspect the value of mc.shape['cube'] using render movie, I'd appreciate any suggestions. I have included the mc.shape['cube'] into my code and it gives the following output:
_HOOMDDict{'vertices': 
[(0.05000000074505806, 0.05000000074505806, 0.05000000074505806), 
                        (0.05000000074505806, 
-0.05000000074505806, 0.05000000074505806), 
                        (0.05000000074505806, 
0.05000000074505806, -0.05000000074505806), 
                        (0.05000000074505806, 
-0.05000000074505806, -0.05000000074505806), 
                        (-0.05000000074505806, 
0.05000000074505806, 0.05000000074505806), 
                        (-0.05000000074505806, 
-0.05000000074505806, 0.05000000074505806), 
                        (-0.05000000074505806, 
0.05000000074505806, -0.05000000074505806), 
                        (-0.05000000074505806, 
-0.05000000074505806, -0.05000000074505806)], 
'ignore_statistics': False, 'sweep_radius': 0.0}
Please find below a sample of the code:
nselect =0.0005
 
cube_verts = [(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)]
mc.shape['cube'] = dict(vertices=numpy.asarray([(0.05, 0.05, 0.05), (0.05, -0.05, 0.05), (0.05, 0.05, -0.05), (0.05, -0.05, -0.05),
        (-0.05, 0.05, 0.05),(-0.05, -0.05, 0.05),(-0.05, 0.05, -0.05),(-0.05, -0.05, -0.05)])) 

"VERTEX MOVES" 
#mc.shape['cube'] = dict(vertices=numpy.asarray(cube_verts) / 2) 
vertex_move = hoomd.hpmc.shape_move.Vertex(default_step_size= 0.0005, vertex_move_probability = 0.0005)
vertex_move.volume['cube'] = 0.001
updater = hoomd.hpmc.update.Shape(shape_move=vertex_move, trigger=hoomd.trigger.Periodic(1))
updater.shape_move = vertex_move
sim.operations.updaters.append(updater) 

tune = hoomd.hpmc.tune.MoveSize.scale_solver(moves=['a', 'd'],
                                             target=0.2,
                                             trigger= hoomd.trigger.Periodic(10),
                                             max_translation_move=0.2,
                                             max_rotation_move=0.2)

#add tune operation to simulation
sim.operations.tuners.append(tune)
sim.run(10)

shapemove = updater.shape_moves
print(shapemove)

vertex_sm= mc.shape['cube'] 
print (vertex_sm)


Thanks,

Brandon Butler

unread,
Sep 28, 2022, 10:56:02 AM9/28/22
to hoomd...@googlegroups.com

Hey Oyin,

  1. Josh was saying the function you are using render_movie hard codes (explicitly sets) the vertices to be that of the perfect cube. To visualize the shape changing, you would need to modify the function to take in the current vertices.
  2. For verifying the shape changes moves work, it would be better to compare (either programmatically or manually) the vertices (mc.shape["cube"].vertices) at different timesteps.

Best,

Brandon

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

oyin

unread,
Sep 29, 2022, 2:16:24 PM9/29/22
to hoomd-users
Ok, I'll try that. Thanks
Reply all
Reply to author
Forward
0 new messages