Data container

class mchammer.DataContainer(atoms, ensemble_name: str, random_seed: int)

Data container class, which serves for storing all information concerned with Monte Carlo simulations performed with mchammer.

Parameters:
  • atoms (ASE Atoms object) – reference atomic structure associated with the data container
  • name_ensemble (str) – name of associated ensemble
  • random_seed (int) – random seed used in random number generator
observables

dict – dictionary of tag-type pair of added observables.

parameters

dict – dictionary of tag-value pair of added parameters.

metadata

dict – dictionary of tag-value pair of added metadata.

data

Pandas data frame object – Runtime data collected during the Monte Carlo simulation.

add_observable(tag: str, obs_type)

Add an observable to the dict with observables.

Parameters:
  • tag (str) – name of observable.
  • obs_type (type) – type of observable parameter.
add_parameter(tag: str, value)

Add parameter of the associated ensemble.

Parameters:
  • tag (str) – parameter name
  • value (int or float or list of int or float) – parameter value
append(mctrial: int, record: dict)

Append data to the data container.

Parameters:
  • mctrial (int) – current Monte Carlo trial step
  • record (dict) – dictionary of tag-value pairs representing observations

Todo

This might be a quite expensive way to add data to the data frame. Testing and profiling to be carried out later.

get_average(start: int, stop: int, tag: str)

Return average of an observable over an interval of trial steps.

Parameters:
  • start (int) – lower limit of trial step interval
  • stop (int) – upper limit of trial step interval
  • tag (str) – tag of field over which to average
get_data(tags=None, interval=None, fill_missing=False)

Returns a list of lists representing the accumulated data for the observables specified via tags.

Parameters:
  • tags (list of str) – tags of the required properties; if None all columns of the data frame will be returned
  • interval (tuple) – range of trial steps values from which data frame will be returned
  • fill_missing (bool) – If True fill missing values forward
metadata

dict – metadata associated with data container

observables

dict – observables

parameters

list – simulation parameters

read(infile)

Read DataContainer object from file.

Parameters:infile (str or FileObj) – file from which to read
reset()

Reset (clear) data frame of data container.

write(outfile)

Write DataContainer object to file.

Parameters:outfile (str or FileObj) – file to which to write