H5MD Writer¶
This module provides a file writer for the H5MD format.
-
class
halmd.io.writers.
h5md
(args)¶ Construct H5MD writer.
Parameters: - args (table) – keyword arguments
- args.path (string) – pathname of output file
- args.email (string) – email address of file author (optional)
- args.overwrite (boolean) – if true, overwrite existing file (default: false)
Returns: instance of file writer
Create the output file and writes the H5MD metadata.
http://nongnu.org/h5md/h5md.html#h5md-metadata
The author name is retrieved from the password file entry for the real user id of the calling process.
Warning
The output file will be truncated if it exists.
The file may be flushed to disk by sending the USR2 signal to the process:
killall -USR2 halmd
This yields a consistent snapshot on disk (until the next sample is written), which is useful to peek at output data during the simulation.
-
writer
(self, args)¶ Construct a group writer.
Parameters: - args (table) – keyword arguments
- args.location (table) – sequence with group’s path
- args.mode (string) – write mode (“append” or “truncate”)
Returns: instance of group writer
Example for creating and using a truncate writer:
local writer = file:writer({location = {"particles", "box"}, mode = "truncate"}) writer:on_write(box.lowest_corner, {"offset"}) writer:on_write(box.edges, {"edges"}) local sampler = require("halmd.observables.sampler") sampler:on_start(writer.write)
Example for creating and using an append writer:
local writer = file:writer({location = {"observables"}, mode = "append"}) writer:on_prepend_write(observable.sample) writer:on_write(observable.en_pot, {"potential_energy"}) writer:on_write(observable.en_kin, {"kinetic_energy"}) writer:on_write(observable.en_tot, {"internal_energy"}) local sampler = require("halmd.observables.sampler") sampler:on_start(writer.write)
-
flush
()¶ Flush the output file to disk.
-
root
¶ HDF5 root group of the file.
-
path
¶ Filename of the file.
-
halmd.io.writers.h5md.
version
()¶ Returns sequence of integers with major and minor H5MD version.