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
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

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 (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
get_standard_deviation(tag, start=None, stop=None)[source]

Returns standard deviation of a scalar observable, calculated using numpy.

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

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)[source]

Reads DataContainer object from file.

Parameters:

infile (Union[str, Binaryio, Textio]) – file from which to read

Raises:
reset()[source]

Resets (clears) data frame of data container.

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