H5MD Writer

This module provides a file writer for the H5MD format.

http://nongnu.org/h5md/

class halmd.io.writers.h5md(args)

Construct H5MD writer.

Parameters:
  • args (table) – keyword arguments
  • args.path (string) – pathname of output file
Returns:

instance of file writer

Create the output file and writes the H5MD attribute group.

http://nongnu.org/h5md/draft.html#global-attributes

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 = {"trajectory", "box"}, mode = "truncate"})
writer:on_write(box.origin, {"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, {"total_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.