Skip to main content

General simulation data file format.

Project description

GSD

The GSD file format is the native file format for HOOMD-blue. GSD files store trajectories of the HOOMD-blue system state in a binary file with efficient random access to frames. GSD allows all particle and topology properties to vary from one frame to the next. Use the GSD Python API to specify the initial condition for a HOOMD-blue simulation or analyze trajectory output with a script. Read a GSD trajectory with a visualization tool to explore the behavior of the simulation.

Resources

HOOMD examples

Create a hoomd gsd file.

>>> s = gsd.hoomd.Frame()
>>> s.particles.N = 4
>>> s.particles.types = ['A', 'B']
>>> s.particles.typeid = [0,0,1,1]
>>> s.particles.position = [[0,0,0],[1,1,1], [-1,-1,-1], [1,-1,-1]]
>>> s.configuration.box = [3, 3, 3, 0, 0, 0]
>>> traj = gsd.hoomd.open(name='test.gsd', mode='w')
>>> traj.append(s)

Append frames to a gsd file:

>>> def create_frame(i):
...     s = gsd.hoomd.Frame();
...     s.configuration.step = i;
...     s.particles.N = 4+i;
...     s.particles.position = numpy.random.random(size=(4+i,3))
...     return s;
>>> with gsd.hoomd.open('test.gsd', 'a') as t:
...     t.extend( (create_frame(i) for i in range(10)) )
...     print(len(t))
11

Randomly index frames:

>>> with gsd.hoomd.open('test.gsd', 'r') as t:
...     frame = t[5]
...     print(frame.configuration.step)
4
...     print(frame.particles.N)
8
...     print(frame.particles.position)
[[ 0.56993282  0.42243481  0.5502916 ]
 [ 0.36892486  0.38167036  0.27310368]
 [ 0.04739023  0.13603486  0.196539  ]
 [ 0.120232    0.91591144  0.99463677]
 [ 0.79806316  0.16991436  0.15228257]
 [ 0.13724308  0.14253527  0.02505   ]
 [ 0.39287439  0.82519054  0.01613089]
 [ 0.23150323  0.95167434  0.7715748 ]]

Slice frames:

>>> with gsd.hoomd.open('test.gsd', 'r') as t:
...     for s in t[5:-2]:
...         print(s.configuration.step, end=' ')
4 5 6 7

File layer examples

with gsd.fl.open(name='file.gsd', mode='w') as f:
    f.write_chunk(name='position', data=numpy.array([[1,2,3],[4,5,6]], dtype=numpy.float32));
    f.write_chunk(name='angle', data=numpy.array([0, 1], dtype=numpy.float32));
    f.write_chunk(name='box', data=numpy.array([10, 10, 10], dtype=numpy.float32));
    f.end_frame()
with gsd.fl.open(name='file.gsd', mode='r') as f:
    for i in range(1,f.nframes):
        position = f.read_chunk(frame=i, name='position');
        do_something(position);

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsd-3.2.1.tar.gz (180.5 kB view hashes)

Uploaded Source

Built Distributions

gsd-3.2.1-cp312-cp312-win_amd64.whl (250.1 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

gsd-3.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (648.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

gsd-3.2.1-cp312-cp312-macosx_11_0_arm64.whl (256.8 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

gsd-3.2.1-cp312-cp312-macosx_10_9_x86_64.whl (260.1 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

gsd-3.2.1-cp311-cp311-win_amd64.whl (253.0 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

gsd-3.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (642.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

gsd-3.2.1-cp311-cp311-macosx_11_0_arm64.whl (257.9 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

gsd-3.2.1-cp311-cp311-macosx_10_9_x86_64.whl (263.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gsd-3.2.1-cp310-cp310-win_amd64.whl (252.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

gsd-3.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

gsd-3.2.1-cp310-cp310-macosx_11_0_arm64.whl (257.8 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

gsd-3.2.1-cp310-cp310-macosx_10_9_x86_64.whl (262.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gsd-3.2.1-cp39-cp39-win_amd64.whl (252.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

gsd-3.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gsd-3.2.1-cp39-cp39-macosx_11_0_arm64.whl (257.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

gsd-3.2.1-cp39-cp39-macosx_10_9_x86_64.whl (262.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gsd-3.2.1-cp38-cp38-win_amd64.whl (253.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

gsd-3.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (633.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

gsd-3.2.1-cp38-cp38-macosx_11_0_arm64.whl (257.3 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

gsd-3.2.1-cp38-cp38-macosx_10_9_x86_64.whl (262.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page