Box

The box module keeps the edge lengths of the simulation box, and implements periodic boundary conditions for use in other modules. At present the module supports cuboid box geometries.

Example:

local box = halmd.mdsim.box({length = {100, 100, 10})
class halmd.mdsim.box(args)

Construct box.

Parameters:
  • args (table) – keyword arguments
  • args.edges (table) – sequence of edge vectors (parallelepiped)
  • args.length (table) – sequence of edge lengths (cuboid)
Returns:

instance of box

Warning

Non-cuboid geometries are not implemented, edges must be a diagonal matrix.

dimension

Space dimension of the simulation box as a number.

length

Edge lengths as a sequence.

volume

Box volume.

edges()

Returns the edge vectors as a matrix.

For a cuboid simulation domain, edges is equal to

{{length[1], 0, 0},
 {0, length[2], 0},
 {0, 0, length[3]}}
origin()

Returns the coordinates of the lowest corner of the box.

writer(args)

Write box specification to file.

http://nongnu.org/h5md/h5md.html#simulation-box

Parameters:
  • args (table) – keyword arguments
  • args.writer – instance of group writer (optional)
  • args.file – instance of H5MD file (optional)
  • args.location (string table) – location within file (optional)
Returns:

instance of group writer

If the argument writer is present, a box varying in time is assumed and the box data are written as a time series upon every invocation of writer:write(). Sharing the same writer instance enables hard-linking of the datasets step and time.

Otherwise, a file instance along with a location must be given. The current box information is immediately written to the subgroup "box" as time-independent data.

The argument location specifies a path in a structured file format like H5MD given as a table of strings, the group name "box" is appended.

halmd.mdsim.box.reader(args)

Read edge vectors of simulation domain from H5MD file.

http://nongnu.org/h5md/h5md.html#simulation-box

Parameters:
  • args (table) – keyword arguments
  • args.file – instance of halmd.io.readers.h5md
  • args.location – location of box group within file
Returns:

edge vectors

The argument location specifies a path in a structured file format like H5MD given as a table of strings, the group name "box" is appended.

The return value may be used to restore the domain:

local file = readers.h5md({path = args.trajectory})
local edges = mdsim.box.reader({file = file, location = {"particles", "all"}})
local box = mdsim.box({edges = edges})