Periodically save particle positions

83 views
Skip to first unread message

Pavel Baláž

unread,
Jul 21, 2022, 4:06:31 AM7/21/22
to hoomd-users
Hello,

I am trying to save all particles positions into a gsd file during a simulation after each num_out steps.
As I understood setting dynamic=["properties"] in hoomd.write.GSD should be enough. I used this code:

logger = hoomd.logging.Logger()
logger.add(thermodynamic_properties)
logger.add(sim, quantities=["timestep", "walltime"])

gsd_writer = hoomd.write.GSD(filename=log_file,
                              trigger=hoomd.trigger.Periodic(num_out),
                              mode="wb",
                              dynamic=["property"],
                              filter=hoomd.filter.Null())
sim.operations.writers.append(gsd_writer)
gsd_writer.log = logger
sim.run(num_steps)

Unfortunately, when I read the log file and look for traj[i].particles.position it is empty. Do you have any idea where might be the problem?

Thanks, Pavel

Joshua Anderson

unread,
Jul 21, 2022, 7:32:40 AM7/21/22
to hoomd...@googlegroups.com
Pavel,

You are selecting no particles for output with `filter=hoomd.filter.Null()`. Use `filter=hoomd.filter.All()` to include all particles in the GSD file.
------
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/0a67dae8-2b09-4396-abc8-dca2fe80f642n%40googlegroups.com.

Pavel Baláž

unread,
Jul 21, 2022, 11:18:40 AM7/21/22
to hoomd-users
Dear Joshua,

thank you. Probably I misunderstood the meaning of that filter. Now it works.

Best,
Pavel

Joshua Anderson

unread,
Jul 21, 2022, 11:25:08 AM7/21/22
to hoomd...@googlegroups.com
Pavel,

It looks like you copied that from the logging example where it demonstrates how to make a GSD file that only contains the log quantities and no particles: 

The following tutorial shows how to combine particles and logged quantities in the same file:
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
Reply all
Reply to author
Forward
0 new messages