Description
When I run Rigid.create_bodies() a second time on the same simulation state with different and nested body definitions (A has B constintuents, B has C constituents), I get unexpected results. Specifically, all particles except for the top-level type (A in the example code) are removed, and all A particles are set to free (their body values are -1). I was surprised, because I expected that I would merely have doubled the number of B particles. The problem seems to be somewhere in hoomd/md/ForceComposite.cc.
Script
import hoomd
sim = hoomd.util.make_example_simulation(particle_types=["A", "B", "C"])
rigid = hoomd.md.constrain.Rigid()
rigid.body["A"] = {
"constituent_types": ["B", "B"],
"positions": [[0,-1,0], [0,1,0]],
"orientations": [(1,0,0,0), (1,0,0,0)]
}
rigid.create_bodies(sim.state)
rigid.body["B"] = {
"constituent_types": ["C", "C"],
"positions": [[0,0,-1], [0,0,1]],
"orientations": [(1,0,0,0), (1,0,0,0)]
}
rigid.create_bodies(sim.state)
print("Types:")
print([sim.state.get_snapshot().particles.types[i] for i in sim.state.get_snapshot().particles.typeid])
print("\nPositions:")
print(sim.state.get_snapshot().particles.position)
print("\nBodies:")
print(sim.state.get_snapshot().particles.body)
Input files
No response
Output
Types:
['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']
Positions:
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Bodies:
[-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
Expected output
No response
Platform
Linux
Installation method
Conda-forge package
HOOMD-blue version
5.4.0
Python version
3.14.0
Description
When I run
Rigid.create_bodies()a second time on the same simulation state with different and nested body definitions (AhasBconstintuents,BhasCconstituents), I get unexpected results. Specifically, all particles except for the top-level type (Ain the example code) are removed, and allAparticles are set to free (their body values are-1). I was surprised, because I expected that I would merely have doubled the number ofBparticles. The problem seems to be somewhere in hoomd/md/ForceComposite.cc.Script
Input files
No response
Output
Expected output
No response
Platform
Linux
Installation method
Conda-forge package
HOOMD-blue version
5.4.0
Python version
3.14.0