Accumulator

This module accumulates values (e.g., the pressure) over the course of the simulation and returns statistical measures (e.g., sum, mean, and variance).

class halmd.observables.utility.accumulator(args)

Construct accumulator module.

Parameters:
  • args – keyword arguments
  • args.acquire – callable that returns a number
  • args.every (number) – interval for aquiring the value
  • args.start (number) – start step for aquiring the value (default: 0)
  • args.desc (string) – profiling description
sample()

Sample next value by calling args.acquire.

sum()

Sum of accumulated values. Calculated as mean × count.

mean()

Mean of accumulated values.

error_of_mean()

Standard error of mean of accumulated values.

variance()

Variance of accumulated values.

count()

Number of samples accumulated.

reset()

Reset the accumulator.

disconnect()

Disconnect accumulator from core.

desc

Profiler description.

writer(file, args)

Write statistical measures to a file.

Parameters:
  • args (table) – keyword arguments
  • args.file – instance of file writer
  • args.location (string table) – location within file
  • args.fields (table) – data fields to be written (optional)
  • args.every (number) – sampling interval
  • args.reset (boolean) – Reset accumulator after writing if true (disabled by default).
Returns:

instance of group writer

The argument location specifies a path in a structured file format like H5MD given as a table of strings, for example {"observables", group label}.

The table fields specifies which statistical measures are written, It may either be passed as an indexed table, e.g. {"mean", "error_of_mean"}, or as a dictionary, e.g., {mu = "mean", sigma = "variance"}; the table form is interpreted as {mean = "mean", ...}. The keys denote the field names in the file and are appended to location. The values specify the data slots, i.e, the methods of the accumulator module, valid values are sum, mean, error_of_mean, variance, and count. Defaults to {"mean", "error_of_mean", "count"}.