Data container

class mchammer.DataContainer(atoms, ensemble_name, random_seed)

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
  • name_ensemble (str) – name of associated ensemble
  • random_seed (int) – seed used in random number generator
add_observable(tag)

Adds observable name.

Parameters:tag (str) – name of observable
Raises:TypeError – if input parameter has the wrong type
add_parameter(tag, value)

Adds parameter associated with underlying ensemble.

Parameters:
Raises:

TypeError – if input parameters have the wrong type

append(mctrial, record)

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
get_average(tag, start=None, stop=None)

Returns average and standard deviation 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
  • TypeError – if requested observable is not of a scalar data type
Return type:

Tuple[float, float]

get_data(tags=None, start=None, stop=None, interval=1, fill_method=None, apply_to=None)

Returns the accumulated data for the requested observables.

Parameters:
  • tags (Optional[List[str]]) – tags of the requested properties; by default all columns of the data frame will be returned in lexicographical order.
  • 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
  • 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 observables are requested that are not in data container
  • ValueError – if fill method is unknown
Return type:

Union[list, Tuple[list, list]]

get_number_of_entries(tag=None)

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_trajectory(start=None, stop=None, interval=1, scalar_property=None)

Returns a trajectory in the form of a list of ASE Atoms and optionally a corresponding list with values of the property with the given label. Configurations with non properties will be skipped in the trajectory if the property is requested.

Parameters:
  • 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.
  • scalar_property (Optional[str]) – tag of observable to be returned along with trajectory
Return type:

Union[List[Atoms], Tuple[List[Atoms], list]]

metadata

metadata associated with data container

Return type:dict
observables

observable names

Return type:List[str]
parameters

parameters associated with Monte Carlo simulation

Return type:dict
static read(infile)

Reads DataContainer object from file.

Parameters:

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

Raises:
reset()

Resets (clears) data frame of data container.

write(outfile)

Writes DataContainer object to file.

Parameters:outfile (Union[str, Binaryio, Textio]) – file to which to write
write_trajectory(outfile)

Save 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