Reading gsd file in c

155 views
Skip to first unread message

jude vishnu

unread,
Dec 8, 2020, 6:13:31 PM12/8/20
to hoomd-users

Hi guys,
Is there a way to make c language read the trajectory.gsd files. Wish to do some analysis of the trajectory which includes a sort of neighbor list calculation (with some specific conditions). But python code is very slow in this regard and I wish to write a c code for the same. Is it possible to read gsd file? Please let me know how. If some one could provide me an example it would really be helpful.

Thanks,
Jude

Brandon Butler

unread,
Dec 9, 2020, 9:07:58 AM12/9/20
to hoomd...@googlegroups.com
Hello Jude,

The gsd package (docs) has a back end written in C for the fl and hoomd submodules and should be fast. You could directly use the C API if you wish as well. The header and source file can be found in the git repository on GitHub (repo). If you want the most speed in Python you should use the fl module and only read chunks that you need.

Best,

Brandon

--
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/350d672e-dd53-4f8d-be01-08c35296e87bn%40googlegroups.com.


--
Brandon Butler
PhD Candidate Glotzer Lab
Department of Chemical Engineering
University of Michigan, Ann Arbor

Remya Ann

unread,
Sep 9, 2022, 12:18:28 PM9/9/22
to hoomd-users
Deal all,
I am trying to analyse the trajectories for multiple quantities. However, python is really slow. And I have already generated the .gsd files (without the fl specification).

So now I would like to do the analysis using a c++ code.

I'm trying to do the same as the topic in this thread - read a .gsd file from a .cpp file. Is this possible with a .gsd file generated with the latest version of HOOMD as well?
If yes, could anyone post a minimal tutorial or example of how to open a .gsd file with c++ and access the particle coordinates from it?

Any help is highly appreciated.

Thanks and Regards,
Remya

Joshua Anderson

unread,
Sep 14, 2022, 7:46:53 AM9/14/22
to hoomd...@googlegroups.com
Remya,

I don't have any tutorials that demonstrate what you are looking for. You can use the C API documentation and the HOOMD schema to determine how to write it yourself:

Most researchers use the gsd Python API to read files, then pass the numpy arrays to analysis routines implemented in C++, such as those in the freud package: https://freud.readthedocs.io/
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

tom...@umich.edu

unread,
Sep 14, 2022, 9:06:54 AM9/14/22
to hoomd-users
Remya,

I would recommend using the freud library. If you would like help getting started, please refer to the documentation Josh has linked in his last message. There is also a mailing list (https://groups.google.com/g/freud-users) for further support if you need it.

- Tommy
Reply all
Reply to author
Forward
0 new messages