Getting the energy from a GSD file

97 views
Skip to first unread message

Ramon Crehuet

unread,
Apr 12, 2021, 6:41:43 AM4/12/21
to hoomd-users
Dear all,
I would like to get the energy of a configuration, read from a GSD file. Some time ago I asked a similar question (https://groups.google.com/g/hoomd-users/c/jWviW0HW0As/m/gk8lucHlCAAJ) but the answer Joshua gave me was for v. 3.0. Unfortunately we can still not use version 3 because we use tabulated potentials, which are not implemented in the latest beta version of v. 3.
So following what was also described in this thread (https://groups.google.com/g/hoomd-users/c/mVX1f4n9uNE) I wrote the following script:

hoomd.context.initialize("--mode=gpu")
    
hoomd.option.set_notice_level(1)
system = hoomd.init.read_gsd(filename = '/home/tobias/extbox_290_15_hoomd.gsd', frame=-1)
integrator_mode = hoomd.md.integrate.mode_standard(dt=0.0);
integrator = hoomd.md.integrate.langevin(group=hoomd.group.all(),
        kT=3.4, seed=np.random.randint(100))
        
logger=hoomd.analyze.log(filename=None, quantities=['potential_energy'],period=1)

hoomd.run(1)
pe = logger.query('potential_energy')
print("PE = ", pe)

The simulation runs but prints an energy equal to 0, as if bonds and non-bonded interactions were not defined. But the documentation states that init.read_gsd defines all terms saved in the gsd, so what am I missing?

Thanks.

Ramon

Joshua Anderson

unread,
Apr 12, 2021, 10:25:50 AM4/12/21
to hoomd...@googlegroups.com
Ramon,

In your script, a potential energy of 0 is correct. You do not define any interaction potentials in the system (e.g. md.pair.lj). GSD files do store the state of the system, which does not include interaction potentials, operations, or parameters.
------
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/3481d418-420e-4bf4-b7a0-a431bae962fan%40googlegroups.com.

Ramon Crehuet

unread,
Apr 13, 2021, 2:50:48 AM4/13/21
to hoomd-users
Dear Joshua,
Thanks for your message. If the GSD file do not include interaction potentials, I think the documentation is a bit misleading when it says: "All particles, bonds, angles, dihedrals, impropers, constraints, and box information are read from the given GSD file at the given frame index." I think bonds, angles, etc could be considered interaction potentials.  This is from https://hoomd-blue.readthedocs.io/en/stable/module-hoomd-init.html#hoomd.init.read_gsd

And for the sake of completeness, I assume create_state_from_gsd in v.3 has the same behaviour, right? I also have to redefine the interaction potentials.

Best regards,

Ramon


El dia dilluns, 12 d’abril de 2021 a les 16:25:50 UTC+2, Joshua A. Anderson va escriure:

Joshua Anderson

unread,
Apr 13, 2021, 12:42:17 PM4/13/21
to hoomd...@googlegroups.com
Ramon,

GSD defines the bonding topology system with the number of bonds, types, the type id of each bond, and the ids of the particles that participate in each bond: https://gsd.readthedocs.io/en/stable/schema-hoomd.html#topology

In the language of thermodynamics, think of the GSD file as defining the microstate of the system. It includes all of the degrees of freedom in the system. Reading a GSD file (either with HOOMD v2 or v3) only reads in that microstate. The operations that you specify in your script determine the equations of motion of the system, including the integration method and the Hamiltonian. So, while the GSD file defines which particles are bonded to each other in the topology, the bond potential you specify in your script determines how energies are evaluated on those bonds.

Regarding documentation improvements, the new tutorials explain this separation between state and operations using the same concepts as above: https://hoomd-blue.readthedocs.io/en/latest/tutorial/00-Introducing-HOOMD-blue/00-index.html

Are you are looking for a way to read operations from a file that is not a script? This is something we are planning in a future v3 beta release. Operations will be picklable so that you save a set of operations from one script and read them in another. We have no plans to store operations in GSD files - there needs to be a clear separation in concepts between the state of the system and the operations that you apply to that state. If they were coupled, one could not conceptually consider using the final state of a MC simulation as the initial condition for an MD one, continue running a simulation at a lower temperature, or many other common use-cases.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/4e99feb9-7703-4324-83ae-d09ae1171e26n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages