mstk.ommhelper.reporter.StateDataReporter

class mstk.ommhelper.reporter.StateDataReporter(file, reportInterval, step=True, time=False, potentialEnergy=True, kineticEnergy=False, totalEnergy=False, temperature=True, volume=False, box=True, density=True, progress=False, remainingTime=False, speed=True, elapsedTime=False, separator='\t', systemMass=None, totalSteps=None, append=False, pressure=True, pxx=False, pyy=False, pzz=False, forceGroups=None, cvs=None, extra=None)

StateDataReporter outputs information about a simulation, such as energy and temperature, to a file.

This reporter is modified from the StateDataReporter shipped with OpenMM python API. It adds support for reporting pressure, energy contribution of individual force group, collective variables and box size.

To use it, create a StateDataReporter, then add it to the Simulation’s list of reporters. The set of data to write is configurable using boolean flags passed to the constructor. By default the data is written in comma-separated-value (CSV) format, but you can specify a different separator to use.

Parameters:
  • file (string or file) – The file to write to, specified as a file name or file object

  • reportInterval (int) – The interval (in time steps) at which to write frames

  • step (bool=False) – Whether to write the current step index to the file

  • time (bool=False) – Whether to write the current time to the file

  • potentialEnergy (bool=False) – Whether to write the potential energy to the file

  • kineticEnergy (bool=False) – Whether to write the kinetic energy to the file

  • totalEnergy (bool=False) – Whether to write the total energy to the file

  • temperature (bool=False) – Whether to write the instantaneous temperature to the file

  • volume (bool=False) – Whether to write the periodic box volume to the file

  • box (bool=True) – Whether to write the periodic box size to the file

  • density (bool=False) – Whether to write the system density to the file

  • progress (bool=False) – Whether to write current progress (percent completion) to the file. If this is True, you must also specify totalSteps.

  • remainingTime (bool=False) – Whether to write an estimate of the remaining clock time until completion to the file. If this is True, you must also specify totalSteps.

  • speed (bool=False) – Whether to write an estimate of the simulation speed in ns/day to the file

  • elapsedTime (bool=False) – Whether to write the elapsed time of the simulation in hours to the file.

  • separator (string=',') – The separator to use between columns in the file

  • systemMass (mass=None) – The total mass to use for the system when reporting density. If this is None (the default), the system mass is computed by summing the masses of all particles. This parameter is useful when the particle masses do not reflect their actual physical mass, such as when some particles have had their masses set to 0 to immobilize them.

  • totalSteps (int=None) – The total number of steps that will be included in the simulation. This is required if either progress or remainingTime is set to True, and defines how many steps will indicate 100% completion.

  • forceGroups (list=[]) – Write the energy contribution of each force group in this list separately

  • cvs (list=[]) – Write the value of each collective variable in this list separately. Each element is a CustomCVForce object

  • extra (dict={}) – Write extra data from a dictionary. The keys will be used as header names. The values can change during the simulation.

Methods

__init__(file, reportInterval[, step, time, ...])

describeNextReport(simulation)

Get information about the next report this object will generate.

getBoxSizeAverage([timeFraction])

Get the averaged box size of the simulated system since this reporter was added.

report(simulation, state)

Generate a report.

describeNextReport(simulation)

Get information about the next report this object will generate.

Parameters:

simulation (Simulation) – The Simulation to generate a report for

Returns:

A five element tuple. The first element is the number of steps until the next report. The remaining elements specify whether that report will require positions, velocities, forces, and energies respectively.

Return type:

tuple

report(simulation, state)

Generate a report.

Parameters:
  • simulation (Simulation) – The Simulation to generate a report for

  • state (State) – The current state of the simulation

getBoxSizeAverage(timeFraction=0.5)

Get the averaged box size of the simulated system since this reporter was added.

Parameters:

timeFraction (float) – The fraction of data (in the end) used to calculate the average. e.g. If set to 0.5, then the last half of the box size data will be used for average. If larger than 1, then so many data points at the end will be used for average.

Returns:

  • lx (float)

  • ly (float)

  • lz (float)