Skip to main content

通用仿真数据文件格式。

项目描述

GSD

GSD文件格式是HOOMD-blue的原生文件格式。 GSD文件将HOOMD-blue系统状态的轨迹存储在一个二进制文件中,可以有效地随机访问帧。GSD允许所有粒子和拓扑属性从一帧到下一帧变化。使用GSD Python API 指定HOOMD-blue模拟的初始条件或使用脚本分析轨迹输出。使用可视化工具读取 GSD轨迹以探索模拟行为。

资源

HOOMD 示例

创建一个 hoomd gsd 文件。

>>> s = gsd.hoomd.Snapshot()
>>> 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='wb')
>>> traj.append(s)

将帧附加到 gsd 文件:

>>> def create_frame(i):
...     s = gsd.hoomd.Snapshot();
...     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', 'ab') as t:
...     t.extend( (create_frame(i) for i in range(10)) )
...     print(len(t))
11

随机索引帧:

>>> with gsd.hoomd.open('test.gsd', 'rb') as t:
...     snap = t[5]
...     print(snap.configuration.step)
4
...     print(snap.particles.N)
8
...     print(snap.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 ]]

切片帧:

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

文件层示例

with gsd.fl.open(name='file.gsd', mode='wb') 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='rb') as f:
    for i in range(1,f.nframes):
        position = f.read_chunk(frame=i, name='position');
        do_something(position);

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

gsd-2.6.0.tar.gz (138.7 kB 查看哈希

已上传 source

内置发行版

gsd-2.6.0-cp310-cp310-win_amd64.whl (89.1 kB 查看哈希

已上传 cp310

gsd-2.6.0-cp310-cp310-macosx_11_0_arm64.whl (97.2 kB 查看哈希

已上传 cp310

gsd-2.6.0-cp310-cp310-macosx_10_9_x86_64.whl (105.5 kB 查看哈希

已上传 cp310

gsd-2.6.0-cp39-cp39-win_amd64.whl (89.6 kB 查看哈希

已上传 cp39

gsd-2.6.0-cp39-cp39-macosx_11_0_arm64.whl (94.9 kB 查看哈希

已上传 cp39

gsd-2.6.0-cp39-cp39-macosx_10_9_x86_64.whl (102.9 kB