Data container

class mchammer.DataContainer(atoms, ensemble_name, random_seed)

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)

Add an observable to the dict with observables.

Parameters:tag (str) – name of observable.
add_parameter(tag, 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, record)

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.

data

Pandas data frame.

get_average(tag, start=None, stop=None)

Return average and standard deviation of an scalar observable over an interval of trial steps.

Parameters:
  • tag (str) – tag of field over which to average
  • start (int) – minimum value of trial step to consider. If None, lowest value in the mctrial column will be used.
  • stop (int) – maximum value of trial step to consider. If None, highest value in the mctrial column will be used.
get_data(tags=None, start=None, stop=None, interval=1, fill_method=None)

Returns a list or a tuple with 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 in lexigraphical order.
  • start (int) – minimum value of trial step to consider. If None, lowest value in the mctrial column will be used.
  • stop (int) – maximum value of trial step to consider. If None, highest value in the mctrial column will be used.
  • interval (int) – incremental step for mctrial index. Default to lowest interval between trial steps values.
  • fill_method ({'skip_none', 'fill_backward', 'fill_forward',) – ‘linear_interpolate’, None} method to fill missing values. Default is None.
Returns:

values in the columns of the data frame

Return type:

list or tuple with lists

get_number_of_entries(tag=None)

Return the total number of entries in the column labeled with the given observable tag.

Parameters:tag (str) – name of observable. If None the total number of rows in the Pandas data frame will be returned.
metadata

dict – metadata associated with data container

observables

dict – observables

parameters

list – simulation parameters

static 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