removing writer from simulation in hoomd v3

Skip to first unread message

Ali Ehlen

Aug 24, 2021, 1:43:24 PMAug 24
Hello! I am playing around with switching one of my projects over to hoomd v3 to test it out and came up on a question.

What is the right way to remove a writer from a simulation and replace it with a new one? Based on the current documentation, it seems that this should be
```sim.operations.writers.remove(writer_object)```, but that does not give me the behavior I expect.

For context, I am trying to run a simulation which has an equilibration phase and a production phase (as usual). I'd like to write simulation progress to stdout the whole time, but save a log file and a gsd file for the equilibration phase, then close those and start a new log file and a new gsd file for the production phase. Base on my tests, it seems that the command that should remove the writer of the equilibration log file is actually removing the stdout writer of simulation progress.

Apologies if this is a repeat---I've looked in open issues to see if this has been discussed but I haven't seen anything similar. I've attached a script that reproduces the behavior.

Thank you!


PS. I really like a lot of the new structures in hoomd v3! Thanks for all the work you're putting in to make this happen!

Brandon Butler

Aug 25, 2021, 11:25:20 AMAug 25

Hey Ali,

You have found a real bug. In essence, one of the `__eq__` methods is incorrectly returning `True` leading to remove removing the wrong object. For now, clearing the list and adding the desired writers back, or simply setting `sim.operations.writers = new_writers` to a new list should work. (I am going to work on merging the appropriate fix soon, but in the current beta release my suggestions will be required.)

Also, thanks for the complement on the new v3 API. :)


Brandon Butler
MolSSI Fellow
PhD Candidate, Chemical Engineering and Scientific Computing | Glotzer Lab, 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
To view this discussion on the web visit

Aug 25, 2021, 11:49:18 AMAug 25
to hoomd-users
Hi Brandon,

Ah, got it, that makes sense. And yep, that workaround will be fine for now. Thank you!!

Reply all
Reply to author
0 new messages