Particle type initialization problem

167 views
Skip to first unread message

Yuchen Xi

unread,
Mar 29, 2022, 4:51:14 PM3/29/22
to hoomd-users
Hi all

I was trying to initializing a simple 3D box with two particle types A and B using the hoomd.init.create_lattice method. However I constantly received errors telling me "Number of particle types must remain the same".

Below I attached the minimal script associated with my problem, any help would be greatly appreciated! 

Thanks
Lawrence

Screen Shot 2022-03-29 at 1.50.41 PM.png

antoni...@googlemail.com

unread,
Mar 30, 2022, 11:24:41 AM3/30/22
to hoomd-users
Dear Lawrence,

It is easiest to figure out what is happening if you can provide a minimal example script that reproduces your problem. The screenshot is not showing your full script. Without more information,I would do something like this (hoomd v2): 

hoomd.context.initialize()
sim = hoomd.context.SimulationContext()
snapshot = hoomd.data.make_snapshot(N=N, particle_types=['A','B'] box=data.boxdim(Lx=L,Ly=L,Lz=L))

# set positions, types, velocities,.. here

system = hoomd.init.read_snapshot(snapshot)
# run your simulation 


You might also want to check out hoomd v3, especially if you are starting a new project since this is the stable version now.

Best,
Antonia

Joshua Anderson

unread,
Apr 4, 2022, 6:09:14 AM4/4/22
to hoomd...@googlegroups.com
Lawrence,

v3 has the same limitation, see the documentation for set_snapshot: https://hoomd-blue.readthedocs.io/en/v3.0.0/package-hoomd.html#hoomd.State.set_snapshot

`set_snapshot` is designed to restore previous copies of the current system state (from `get_snapshot`), such as for use in umbrella sampling or other MC/MD methods. You can use it to create new particles of a type that didn't exist before as long as that type name is already in `sim.state.particle.types`. Modify the `typeid` array to change the types of particles.
------
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/3f397f4c-298f-49a0-b112-56e1ef022c6en%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages