Data container

class mchammer.DataContainer(atoms, ensemble_parameters, metadata={})[source]

Data container for storing information concerned with Monte Carlo simulations performed with mchammer.

Parameters:
  • atoms (ASE Atoms object) – reference atomic structure associated with the data container
  • ensemble_parameters (dict) – parameters associated with the underlying ensemble
  • metadata (dict) – metadata associated with the data container
analyze_data(tag, start=None, stop=None, max_lag=None)[source]

Returns detailed analysis of a scalar observerable.

Parameters:
  • tag (str) – tag of field over which to average
  • start (Optional[int]) – minimum value of trial step to consider; by default the smallest value in the mctrial column will be used.
  • stop (Optional[int]) – maximum value of trial step to consider; by default the largest value in the mctrial column will be used.
  • max_lag (Optional[int]) – maximum lag between two points in data series, by default the largest length of the data series will be used. Used for computing autocorrelation
Raises:
  • ValueError – if observable is requested that is not in data container
  • ValueError – if observable is not scalar
  • ValueError – if observations is not evenly spaced
Returns:

calculated properties of the data including mean, standard_deviation, correlation_length and error_estimate (95% confidence)

Return type:

dict

append(mctrial, record)[source]

Appends data to data container.

Parameters:
  • mctrial (int) – current Monte Carlo trial step
  • record (Dict[str, Union[int, float, list]]) – dictionary of tag-value pairs representing observations
Raises:

TypeError – if input parameters have the wrong type

data

pandas data frame (see pandas.DataFrame)

Return type:DataFrame
ensemble_parameters

parameters associated with Monte Carlo simulation

Return type:dict
get_average(tag, start=None, stop=None)[source]

Returns average of a scalar observable.

Parameters:
  • tag (str) – tag of field over which to average
  • start (Optional[int]) – minimum value of trial step to consider; by default the smallest value in the mctrial column will be used.
  • stop (Optional[int]) – maximum value of trial step to consider; by default the largest value in the mctrial column will be used.
Raises:
  • ValueError – if observable is requested that is not in data container
  • ValueError – if observable is not scalar
Return type:

float

get_data(*tags, start=None, stop=None, interval=1, fill_method='skip_none', apply_to=None)[source]

Returns the accumulated data for the requested observables.

Parameters:
  • tags – tuples of the requested properties
  • start (Optional[int]) – minimum value of trial step to consider; by default the smallest value in the mctrial column will be used.
  • stop (Optional[int]) – maximum value of trial step to consider; by default the largest value in the mctrial column will be used.
  • interval (int) – increment for mctrial; by default the smallest available interval will be used.
  • fill_method ({'skip_none', 'fill_backward', 'fill_forward',) – ‘linear_interpolate’, None} method employed for dealing with missing values; by default uses ‘skip_none’.
  • apply_to (Optional[List[str]]) – tags of columns for which fill_method will be employed; by default parse all columns with fill_method.
Raises:
  • ValueError – if tags is empty
  • ValueError – if observables are requested that are not in data container
  • ValueError – if fill method is unknown
  • ValueError – if trajectory is requested and fill method is not skip_none
Return type:

Union[ndarray, List[Atoms], Tuple[ndarray, List[Atoms]]]

get_number_of_entries(tag=None)[source]

Returns the total number of entries with the given observable tag.

Parameters:tag (Optional[str]) – name of observable; by default the total number of rows in the data frame will be returned.
Raises:ValueError – if observable is requested that is not in data container
Return type:int
last_state

last state to be used to restart Monte Carlo simulation

Return type:Dict[str, Union[int, List[int]]]
metadata

metadata associated with data container

Return type:dict
observables

observable names

Return type:List[str]
static read(infile, old_format=False)[source]

Reads DataContainer object from file.

Parameters:
  • infile (Union[str, Binaryio, Textio]) – file from which to read
  • old_format (bool) – If true use old json format to read runtime data; default to false
Raises:
  • FileNotFoundError – if file is not found (str)
  • ValueError – if file is of incorrect type (not a tarball)
reset()[source]

Resets (clears) internal data list of data container.

update_from_observer(observer)[source]

Adds observer data from observer to data container.

The observer will only be run for the mctrials for which the trajectory have been saved.

The interval of the observer is ignored.

Parameters:observer (BaseObserver) – observer to be used
write_trajectory(outfile)[source]

Saves trajectory to a file along with the respectives values of the potential field for each configuration. If the file exists the trajectory will be appended. Use ase gui to visualize the trajectory with values of the potential for each frame.

Parameters:outfile (Union[str, Binaryio, Textio]) – output file name or file object