Debian Codegraph @

doc/schema-hoomd.rst

raw
1 .. Copyright (c) 2016-2026 The Regents of the University of Michigan
2 .. Part of GSD, released under the BSD 2-Clause License.
3
4 HOOMD Schema
5 ============
6
7 HOOMD-blue supports a wide variety of per particle attributes and properties.
8 Particles, bonds, and types can be dynamically added and removed during
9 simulation runs. The ``hoomd`` schema can handle all of these situations in a
10 reasonably space efficient and high performance manner. It is also backwards
11 compatible with previous versions of itself, as we only add new additional data
12 chunks in new versions and do not change the interpretation of the existing data
13 chunks. Any newer reader will initialize new data chunks with default values
14 when they are not present in an older version file.
15
16 :Schema name: ``hoomd``
17 :Schema version: 2.0
18
19 .. seealso::
20
21 `hoomd.State` for a full description of how HOOMD interprets this
22 data.
23
24 Changes
25 -------
26
27 Version 2.0
28 ^^^^^^^^^^^
29
30 * Each ``float`` data chunk in 2.0 schema files may be either *float32* or *float64*.
31
32 Use-cases
33 ---------
34
35 The GSD schema ``hoomd`` provides:
36
37 #. Every frame of GSD output is viable to restart a simulation
38 #. Support varying numbers of particles, bonds, etc...
39 #. Support varying attributes (type, mass, etc...)
40 #. Support orientation, angular momentum, and other fields.
41 #. Binary format on disk
42 #. High performance file read and write
43 #. Support logging computed quantities
44
45 Data chunks
46 -----------
47
48 Each frame the ``hoomd`` schema may contain one or more data chunks. The layout
49 and names of the chunksmatch that of the binary frame API in HOOMD-blue
50 itself. Data chunks are organized in categories. These categories have no
51 meaning in the ``hoomd`` schema specification, and are simply an organizational
52 tool. Some file writers may implement options that act on categories (i.e. write
53 **attributes** out to every frame, or just frame 0).
54
55 Values are well defined for all fields at all frames. When a data chunk is
56 present in frame *i*, it defines the values for the frame. When it is not
57 present, the data chunk of the same name at frame 0 defines the values for frame
58 *i* (when *N* is equal between the frames). If the data chunk is not present in
59 frame 0, or *N* differs between frames, values are default. Default values allow
60 files sizes to remain small. For example, a simulation with point particles
61 where orientation is always (1,0,0,0) would not write any orientation chunk to
62 the file.
63
64 *N* may be zero. When *N* is zero, an index entry may be written for a data
65 chunk with no actual data written to the file for that chunk.
66
67 ================================= ========= ====== ==== ======= ================
68 Name Category Type Size Default Units
69 ================================= ========= ====== ==== ======= ================
70 **Configuration**
71 :chunk:`configuration/step` uint64 1x1 0 number
72 :chunk:`configuration/dimensions` uint8 1x1 3 number
73 :chunk:`configuration/box` float 6x1 *varies*
74 **Particle data**
75 :chunk:`particles/N` attribute uint32 1x1 0 number
76 :chunk:`particles/types` attribute int8 NTxM ['A'] UTF-8
77 :chunk:`particles/typeid` attribute uint32 Nx1 0 number
78 :chunk:`particles/type_shapes` attribute int8 NTxM UTF-8
79 :chunk:`particles/mass` attribute float Nx1 1.0 mass
80 :chunk:`particles/charge` attribute float Nx1 0.0 charge
81 :chunk:`particles/diameter` attribute float Nx1 1.0 length
82 :chunk:`particles/body` attribute int32 Nx1 -1 number
83 :chunk:`particles/moment_inertia` attribute float Nx3 0,0,0 mass * length^2
84 :chunk:`particles/position` property float Nx3 0,0,0 length
85 :chunk:`particles/orientation` property float Nx4 1,0,0,0 unit quaternion
86 :chunk:`particles/velocity` momentum float Nx3 0,0,0 length/time
87 :chunk:`particles/angmom` momentum float Nx4 0,0,0,0 quaternion
88 :chunk:`particles/image` momentum int32 Nx3 0,0,0 number
89 **Bond data**
90 :chunk:`bonds/N` topology uint32 1x1 0 number
91 :chunk:`bonds/types` topology int8 NTxM UTF-8
92 :chunk:`bonds/typeid` topology uint32 Nx1 0 number
93 :chunk:`bonds/group` topology uint32 Nx2 0,0 number
94 **Angle data**
95 :chunk:`angles/N` topology uint32 1x1 0 number
96 :chunk:`angles/types` topology int8 NTxM UTF-8
97 :chunk:`angles/typeid` topology uint32 Nx1 0 number
98 :chunk:`angles/group` topology uint32 Nx3 0,0,0 number
99 **Dihedral data**
100 :chunk:`dihedrals/N` topology uint32 1x1 0 number
101 :chunk:`dihedrals/types` topology int8 NTxM UTF-8
102 :chunk:`dihedrals/typeid` topology uint32 Nx1 0 number
103 :chunk:`dihedrals/group` topology uint32 Nx4 0,0,0,0 number
104 **Improper data**
105 :chunk:`impropers/N` topology uint32 1x1 0 number
106 :chunk:`impropers/types` topology int8 NTxM UTF-8
107 :chunk:`impropers/typeid` topology uint32 Nx1 0 number
108 :chunk:`impropers/group` topology uint32 Nx4 0,0,0,0 number
109 **Constraint data**
110 :chunk:`constraints/N` topology uint32 1x1 0 number
111 :chunk:`constraints/value` topology float Nx1 0 length
112 :chunk:`constraints/group` topology uint32 Nx2 0,0 number
113 **Special pairs data**
114 :chunk:`pairs/N` topology uint32 1x1 0 number
115 :chunk:`pairs/types` topology int8 NTxM utf-8
116 :chunk:`pairs/typeid` topology uint32 Nx1 0 number
117 :chunk:`pairs/group` topology uint32 Nx2 0,0 number
118 ================================= ========= ====== ==== ======= ================
119
120
121 Configuration
122 -------------
123
124 .. chunk:: configuration/step
125
126 :Type: uint64
127 :Size: 1x1
128 :Default: 0
129 :Units: number
130
131 Simulation time step.
132
133 .. chunk:: configuration/dimensions
134
135 :Type: uint8
136 :Size: 1x1
137 :Default: 3
138 :Units: number
139
140 Number of dimensions in the simulation. Must be 2 or 3.
141
142 .. note::
143 When using `gsd.hoomd.Frame`, the object will try to intelligently default to a
144 dimension. When setting a box with :math:`L_z = 0`, ``dimensions`` will default to
145 2 otherwise 3. Explicit setting of this value by users always takes precedence.
146
147 .. chunk:: configuration/box
148
149 :Type: float32 *or* float64
150 :Size: 6x1
151 :Default: [1,1,1,0,0,0]
152 :Units: *varies*
153
154 Simulation box. Each array element defines a different box property. See the
155 hoomd documentation for a full description on how these box parameters map
156 to a triclinic geometry.
157
158 * ``box[0:3]``: :math:`(l_x, l_y, l_z)` the box length in each direction, in length units
159 * ``box[3:]``: :math:`(xy, xz, yz)` the tilt factors, dimensionless values
160
161 .. versionchanged:: 2.0
162
163
164 Particle data
165 -------------
166
167 Within a single frame, the number of particles *N* and *NT* are fixed for all
168 chunks. *N* and *NT* may vary from one frame to the next. All values are stored
169 in hoomd native units.
170
171 Attributes
172 ^^^^^^^^^^
173
174 .. chunk:: particles/N
175
176 :Type: uint32
177 :Size: 1x1
178 :Default: 0
179 :Units: number
180
181 Define *N*, the number of particles, for all data chunks ``particles/*``.
182
183 .. chunk:: particles/types
184
185 :Type: int8
186 :Size: NTxM
187 :Default: ['A']
188 :Units: UTF-8
189
190 Implicitly define *NT*, the number of particle types, for all data chunks
191 ``particles/*``. *M* must be large enough to accommodate each type name as a
192 null terminated UTF-8 character string. Row *i* of the 2D matrix is the type
193 name for particle type *i*.
194
195 .. chunk:: particles/typeid
196
197 :Type: uint32
198 :Size: Nx1
199 :Default: 0
200 :Units: number
201
202 Store the type id of each particle. All id's must be less than *NT*. A
203 particle with type *id* has a type name matching the corresponding row in
204 :chunk:`particles/types`.
205
206 .. chunk:: particles/type_shapes
207
208 :Type: int8
209 :Size: NTxM
210 :Default: *empty*
211 :Units: UTF-8
212
213 Store a per-type shape definition for visualization. A dictionary is stored
214 for each of the *NT* types, corresponding to a shape for visualization of
215 that type. *M* must be large enough to accommodate the shape definition as
216 a null-terminated UTF-8 JSON-encoded string. See: :ref:`shapes` for
217 examples.
218
219 .. chunk:: particles/mass
220
221 :Type: float32 *or* float64
222 :Size: Nx1
223 :Default: 1.0
224 :Units: mass
225
226 Store the mass of each particle.
227
228 .. versionchanged:: 2.0
229
230 .. chunk:: particles/charge
231
232 :Type: float32 *or* float64
233 :Size: Nx1
234 :Default: 0.0
235 :Units: charge
236
237 Store the charge of each particle.
238
239 .. versionchanged:: 2.0
240
241 .. chunk:: particles/diameter
242
243 :Type: float32 *or* float64
244 :Size: Nx1
245 :Default: 1.0
246 :Units: length
247
248 Store the diameter of each particle.
249
250 .. versionchanged:: 2.0
251
252 .. chunk:: particles/body
253
254 :Type: int32
255 :Size: Nx1
256 :Default: -1
257 :Units: number
258
259 Store the composite body associated with each particle. The value -1
260 indicates no body. The body field may be left out of input files, as hoomd
261 will create the needed constituent particles.
262
263 .. chunk:: particles/moment_inertia
264
265 :Type: float32 *or* float64
266 :Size: Nx3
267 :Default: 0,0,0
268 :Units: mass * length^2
269
270 Store the moment_inertia of each particle :math:`(I_{xx}, I_{yy}, I_{zz})`.
271 This inertia tensor is diagonal in the body frame of the particle. The
272 default value is for point particles.
273
274 .. versionchanged:: 2.0
275
276 Properties
277 ^^^^^^^^^^
278
279 .. chunk:: particles/position
280
281 :Type: float32 *or* float64
282 :Size: Nx3
283 :Default: 0,0,0
284 :Units: length
285
286 Store the position of each particle (*x*, *y*, *z*).
287
288 All particles in the simulation are referenced by a tag. The position data
289 chunk (and all other per particle data chunks) list particles in tag order.
290 The first particle listed has tag 0, the second has tag 1, ..., and the last
291 has tag N-1 where N is the number of particles in the simulation.
292
293 All particles must be inside the box:
294
295 * :math:`-l_x/2 + (xz-xy \cdot yz) \cdot z + xy \cdot y \le x < l_x/2 + (xz-xy \cdot yz) \cdot z + xy \cdot y`
296 * :math:`-l_y/2 + yz \cdot z \le y < l_y/2 + yz \cdot z`
297 * :math:`-l_z/2 \le z < l_z/2`
298
299 Where :math:`l_x`, :math:`l_y`, :math:`l_z`, :math:`xy`, :math:`xz`, and :math:`yz` are the
300 simulation box parameters (:chunk:`configuration/box`).
301
302 .. versionchanged:: 2.0
303
304 .. chunk:: particles/orientation
305
306 :Type: float32 *or* float64
307 :Size: Nx4
308 :Default: 1,0,0,0
309 :Units: unit quaternion
310
311 Store the orientation of each particle. In scalar + vector notation, this is
312 :math:`(r, a_x, a_y, a_z)`,
313 where the quaternion is :math:`q = r + a_xi + a_yj + a_zk`. A unit
314 quaternion has the property: :math:`\sqrt{r^2 + a_x^2 + a_y^2 + a_z^2} = 1`.
315
316 .. versionchanged:: 2.0
317
318 Momenta
319 ^^^^^^^^
320
321 .. chunk:: particles/velocity
322
323 :Type: float32 *or* float64
324 :Size: Nx3
325 :Default: 0,0,0
326 :Units: length/time
327
328 Store the velocity of each particle :math:`(v_x, v_y, v_z)`.
329
330 .. versionchanged:: 2.0
331
332 .. chunk:: particles/angmom
333
334 :Type: float32 *or* float64
335 :Size: Nx4
336 :Default: 0,0,0,0
337 :Units: quaternion
338
339 Store the angular momentum of each particle as a quaternion. See the HOOMD
340 documentation for information on how to convert to a vector representation.
341
342 .. versionchanged:: 2.0
343
344 .. chunk:: particles/image
345
346 :Type: int32
347 :Size: Nx3
348 :Default: 0,0,0
349 :Units: number
350
351 Store the number of times each particle has wrapped around the box
352 :math:`(i_x, i_y, i_z)`. In constant volume simulations, the unwrapped
353 position in the particle's full trajectory is
354
355 * :math:`x_u = x + i_x \cdot l_x + xy \cdot i_y \cdot l_y + xz \cdot i_z \cdot l_z`
356 * :math:`y_u = y + i_y \cdot l_y + yz \cdot i_z \cdot l_z`
357 * :math:`z_u = z + i_z \cdot l_z`
358
359 Topology
360 --------
361
362 .. chunk:: bonds/N
363
364 :Type: uint32
365 :Size: 1x1
366 :Default: 0
367 :Units: number
368
369 Define *N*, the number of bonds, for all data chunks ``bonds/*``.
370
371 .. chunk:: bonds/types
372
373 :Type: int8
374 :Size: NTxM
375 :Default: *empty*
376 :Units: UTF-8
377
378 Implicitly define *NT*, the number of bond types, for all data chunks
379 ``bonds/*``. *M* must be large enough to accommodate each type name as a
380 null terminated UTF-8 character string. Row *i* of the 2D matrix is the type
381 name for bond type *i*. By default, there are 0 bond types.
382
383 .. chunk:: bonds/typeid
384
385 :Type: uint32
386 :Size: Nx1
387 :Default: 0
388 :Units: number
389
390 Store the type id of each bond. All id's must be less than *NT*. A bond with
391 type *id* has a type name matching the corresponding row in
392 :chunk:`bonds/types`.
393
394 .. chunk:: bonds/group
395
396 :Type: uint32
397 :Size: Nx2
398 :Default: 0,0
399 :Units: number
400
401 Store the particle tags in each bond.
402
403 .. chunk:: angles/N
404
405 :Type: uint32
406 :Size: 1x1
407 :Default: 0
408 :Units: number
409
410 Define *N*, the number of angles, for all data chunks ``angles/*``.
411
412 .. chunk:: angles/types
413
414 :Type: int8
415 :Size: NTxM
416 :Default: *empty*
417 :Units: UTF-8
418
419 Implicitly define *NT*, the number of angle types, for all data chunks
420 ``angles/*``. *M* must be large enough to accommodate each type name as a
421 null terminated UTF-8 character string. Row *i* of the 2D matrix is the type
422 name for angle type *i*. By default, there are 0 angle types.
423
424 .. chunk:: angles/typeid
425
426 :Type: uint32
427 :Size: Nx1
428 :Default: 0
429 :Units: number
430
431 Store the type id of each angle. All id's must be less than *NT*. A angle
432 with type *id* has a type name matching the corresponding row in
433 :chunk:`angles/types`.
434
435 .. chunk:: angles/group
436
437 :Type: uint32
438 :Size: Nx3
439 :Default: 0,0,0
440 :Units: number
441
442 Store the particle tags in each angle.
443
444 .. chunk:: dihedrals/N
445
446 :Type: uint32
447 :Size: 1x1
448 :Default: 0
449 :Units: number
450
451 Define *N*, the number of dihedrals, for all data chunks ``dihedrals/*``.
452
453 .. chunk:: dihedrals/types
454
455 :Type: int8
456 :Size: NTxM
457 :Default: *empty*
458 :Units: UTF-8
459
460 Implicitly define *NT*, the number of dihedral types, for all data chunks
461 ``dihedrals/*``. *M* must be large enough to accommodate each type name as a
462 null terminated UTF-8 character string. Row *i* of the 2D matrix is the type
463 name for dihedral type *i*. By default, there are 0 dihedral types.
464
465 .. chunk:: dihedrals/typeid
466
467 :Type: uint32
468 :Size: Nx1
469 :Default: 0
470 :Units: number
471
472 Store the type id of each dihedral. All id's must be less than *NT*. A
473 dihedral with type *id* has a type name matching the corresponding row in
474 :chunk:`dihedrals/types`.
475
476 .. chunk:: dihedrals/group
477
478 :Type: uint32
479 :Size: Nx4
480 :Default: 0,0,0,0
481 :Units: number
482
483 Store the particle tags in each dihedral.
484
485 .. chunk:: impropers/N
486
487 :Type: uint32
488 :Size: 1x1
489 :Default: 0
490 :Units: number
491
492 Define *N*, the number of impropers, for all data chunks ``impropers/*``.
493
494 .. chunk:: impropers/types
495
496 :Type: int8
497 :Size: NTxM
498 :Default: *empty*
499 :Units: UTF-8
500
501 Implicitly define *NT*, the number of improper types, for all data chunks
502 ``impropers/*``. *M* must be large enough to accommodate each type name as a
503 null terminated UTF-8 character string. Row *i* of the 2D matrix is the type
504 name for improper type *i*. By default, there are 0 improper types.
505
506 .. chunk:: impropers/typeid
507
508 :Type: uint32
509 :Size: Nx1
510 :Default: 0
511 :Units: number
512
513 Store the type id of each improper. All id's must be less than *NT*. A
514 improper with type *id* has a type name matching the corresponding row in
515 :chunk:`impropers/types`.
516
517 .. chunk:: impropers/group
518
519 :Type: uint32
520 :Size: Nx4
521 :Default: 0,0,0,0
522 :Units: number
523
524 Store the particle tags in each improper.
525
526 .. chunk:: constraints/N
527
528 :Type: uint32
529 :Size: 1x1
530 :Default: 0
531 :Units: number
532
533 Define *N*, the number of constraints, for all data chunks
534 ``constraints/*``.
535
536 .. chunk:: constraints/value
537
538 :Type: float32 *or* float64
539 :Size: Nx1
540 :Default: 0
541 :Units: length
542
543 Store the distance of each constraint. Each constraint defines a fixed
544 distance between two particles.
545
546 .. versionchanged:: 2.0
547
548 .. chunk:: constraints/group
549
550 :Type: uint32
551 :Size: Nx2
552 :Default: 0,0
553 :Units: number
554
555 Store the particle tags in each constraint.
556
557 .. chunk:: pairs/N
558
559 :Type: uint32
560 :Size: 1x1
561 :Default: 0
562 :Units: number
563
564 Define *N*, the number of special pair interactions, for all data chunks
565 ``pairs/*``.
566
567 .. versionadded:: 1.1
568
569 .. chunk:: pairs/types
570
571 :Type: int8
572 :Size: NTxM
573 :Default: *empty*
574 :Units: UTF-8
575
576 Implicitly define *NT*, the number of special pair types, for all data
577 chunks ``pairs/*``. *M* must be large enough to accommodate each type name
578 as a null terminated UTF-8 character string. Row *i* of the 2D matrix is the
579 type name for particle type *i*. By default, there are 0 special pair types.
580
581 .. versionadded:: 1.1
582
583 .. chunk:: pairs/typeid
584
585 :Type: uint32
586 :Size: Nx1
587 :Default: 0
588 :Units: number
589
590 Store the type id of each special pair interaction. All id's must be less
591 than *NT*. A pair with type *id* has a type name matching the corresponding
592 row in :chunk:`pairs/types`.
593
594 .. versionadded:: 1.1
595
596 .. chunk:: pairs/group
597
598 :Type: uint32
599 :Size: Nx2
600 :Default: 0,0
601 :Units: number
602
603 Store the particle tags in each special pair interaction.
604
605 .. versionadded:: 1.1
606
607 Logged data
608 ------------
609
610 Users may store logged data in ``log/*`` data chunks. Logged data encompasses
611 values computed at simulation time that are too expensive or cumbersome to
612 re-compute in post processing. This specification does not define specific chunk
613 names or define logged data. Users may select any valid name for logged data
614 chunks as appropriate for their workflow.
615
616 For any named logged data chunks present in any frame frame the file: If a chunk
617 is not present in a given frame i != 0, the implementation should provide the
618 quantity as read from frame 0 for that frame. GSD files that include a logged
619 data chunk only in some frames i != 0 and not in frame 0 are invalid.
620
621 By convention, per-particle and per-bond logged data should have a chunk name
622 starting with ``log/particles/`` and ``log/bonds``, respectively. Scalar,
623 vector, and string values may be stored under a different prefix starting with
624 ``log/``. This specification may recognize additional conventions in later
625 versions without invalidating existing files.
626
627 ========================================================== ====== ========= ================
628 Name Type Size Units
629 ========================================================== ====== ========= ================
630 :chunk:`log/particles/user_defined` n/a NxM user-defined
631 :chunk:`log/bonds/user_defined` n/a NxM user-defined
632 :chunk:`log/user_defined` n/a NxM user-defined
633 ========================================================== ====== ========= ================
634
635 .. chunk:: log/particles/user_defined
636
637 :Type: user-defined
638 :Size: NxM
639 :Units: user-defined
640
641 This chunk is a place holder for any number of user defined per-particle
642 quantities. *N* is the number of particles in this frame. *M*, the data
643 type, the units, and the chunk name (after the prefix ``log/particles/``)
644 are user-defined.
645
646 .. versionadded:: 1.4
647
648 .. chunk:: log/bonds/user_defined
649
650 :Type: user-defined
651 :Size: NxM
652 :Units: user-defined
653
654 This chunk is a place holder for any number of user defined per-bond
655 quantities. *N* is the number of bonds in this frame. *M*, the data type,
656 the units, and the chunk name (after the prefix ``log/bonds/``) are
657 user-defined.
658
659 .. versionadded:: 1.4
660
661 .. chunk:: log/user_defined
662
663 :Type: user-defined
664 :Size: NxM
665 :Units: user-defined
666
667 This chunk is a place holder for any number of user defined quantities. *N*,
668 *M*, the data type, the units, and the chunk name (after the prefix
669 ``log/``) are user-defined.
670
671 .. versionadded:: 1.4
672
673 State data
674 ------------
675
676 .. versionremoved:: 2.0
677 ``state/*`` data chunks do not exist in schema versions 2.0 and newer.