Closed cbkerr closed 1 year ago
The linked example code uses gsd.hoomd.Snapshot
. Replace hoomd.Snapshot
with gsd.hoomd.Snapshot
and your code should work.
HOOMD and GSD snapshot objects at mostly duck-type compatible, but not completely. By that, I mean you read quantities like snapshot.particles.types
, snapshot.particles.position
, interchangeably in analysis scripts. However, operations such as changing the size of a snapshot and using them with other HOOMD and GSD API calls is not possible without a Snapshot
of the correct type.
HOOMD provides from_gsd_snapshot
for those cases you need to convert from a gsd.hoomd.Snapshot
to a hoomd.Snapshot
.
Are you requesting a similar from_hoomd_snapshot
in GSD?
Ah that is what I didn't notice!
In my hoomd scripts, I've been building up the snapshot then using create_state_from_snapshot
without the need for gsd. When I wanted to dump the first frame for debugging it felt natural to use the same syntax.
Are you requesting a similar from_hoomd_snapshot in GSD?
I think that would resolve it. Would it cause any problems if gsd could accept either kind of snapshot and convert if needed?
Ah that is what I didn't notice!
In my hoomd scripts, I've been building up the snapshot then using
create_state_from_snapshot
without the need for gsd. When I wanted to dump the first frame for debugging it felt natural to use the same syntax.
The later tutorials use hoomd.write.GSD.write
for this. It natively supports MPI simulations. If you use gsd
itself to do the write, you need to add extra logic to handle MPI appropriately. Additionally, hoomd.write.GSD.write
will be faster as it is all in C++ where as gsd
is written in Python/Cython and accepts a much wider range of inputs.
The first tutorial uses gsd
to write the file as it demonstrates best practices to separate initialization and simulation into separate workflow steps. The initialization step then has no dependence on HOOMD and can be run and examined locally before copying to a cluster, for example.
Are you requesting a similar from_hoomd_snapshot in GSD?
I think that would resolve it. Would it cause any problems if gsd could accept either kind of snapshot and convert if needed?
You can check the implementation, but I don't think it is technically feasible for gsd to directly accept hoomd.Snapshot
objects. If you want to convert hoomd.Snapshot
to gsd.hoomd.Snapshot
, I recommend writing a class method gsd.hoomd.Snapshot.from_hoomd_snapshot
so that users can perform the conversion explicitly when needed. It should make copies of the data buffers so that it does not depend on the lifetime of the C++ managed hoomd.Snapshot
data structure.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This issue has been automatically closed because it has not had recent activity.
Description
Script
Came across this while working but it also fails without anything in the snapshot.
Output
Expected output
This is how the tutorial writes a single frame to a gsd file, so it should work. https://hoomd-blue.readthedocs.io/en/v3.1.0/tutorial/01-Introducing-Molecular-Dynamics/02-Initializing-a-Random-System.html
Configuration
Platform:
Installation method:
Versions:
Developer