OpenMM
Simulation Class Reference

Simulation provides a simplified API for running simulations with OpenMM and reporting results. More...

List of all members.

Public Member Functions

def __init__
 Create a Simulation.
def minimizeEnergy
 Perform a local energy minimization on the system.
def step
 Advance the simulation by integrating a specified number of time steps.
def runForClockTime
 Advance the simulation by integrating time steps until a fixed amount of clock time has elapsed.
def saveCheckpoint
 Save a checkpoint of the simulation to a file.
def loadCheckpoint
 Load a checkpoint file that was created with saveCheckpoint().
def saveState
 Save the current state of the simulation to a file.
def loadState
 Load a State file that was created with saveState().

Public Attributes

 topology
 The Topology describing the system being simulated.
 system
 The System being simulated.
 integrator
 The Integrator used to advance the simulation.
 currentStep
 The index of the current time step.
 reporters
 A list of reporters to invoke during the simulation.
 context
 The Context containing the current state of the simulation.

Detailed Description

Simulation provides a simplified API for running simulations with OpenMM and reporting results.

A Simulation ties together various objects used for running a simulation: a Topology, System, Integrator, and Context. To use it, you provide the Topology, System, and Integrator, and it creates the Context automatically.

Simulation also maintains a list of "reporter" objects that record or analyze data as the simulation runs, such as writing coordinates to files or displaying structures on the screen. For example, the following line will cause a file called "output.pdb" to be created, and a structure written to it every 1000 time steps:

simulation.reporters.append(PDBReporter('output.pdb', 1000))


Constructor & Destructor Documentation

def __init__ (   self,
  topology,
  system,
  integrator,
  platform = None,
  platformProperties = None 
)

Create a Simulation.

Parameters:
topology(Topology) A Topology describing the the system to simulate
system(System) The OpenMM System object to simulate
integrator(Integrator) The OpenMM Integrator to use for simulating the System
platform(Platform=None) If not None, the OpenMM Platform to use
platformProperties(map=None) If not None, a set of platform-specific properties to pass to the Context's constructor

Member Function Documentation

def loadCheckpoint (   self,
  file 
)

Load a checkpoint file that was created with saveCheckpoint().

Parameters:
file(string or file) a File-like object to load the checkpoint from, or alternatively a filename
def loadState (   self,
  file 
)

Load a State file that was created with saveState().

Parameters:
file(string or file) a File-like object to load the state from, or alternatively a filename
def minimizeEnergy (   self,
  tolerance = 10*unit.kilojoule/unit.mole,
  maxIterations = 0 
)

Perform a local energy minimization on the system.

Parameters:
tolerance(energy=10*kilojoules/mole) The energy tolerance to which the system should be minimized
maxIterations(int=0) The maximum number of iterations to perform. If this is 0, minimization is continued until the results converge without regard to how many iterations it takes.
def runForClockTime (   self,
  time,
  checkpointFile = None,
  stateFile = None,
  checkpointInterval = None 
)

Advance the simulation by integrating time steps until a fixed amount of clock time has elapsed.

This is useful when you have a limited amount of computer time available, and want to run the longest simulation possible in that time. This method will continue taking time steps until the specified clock time has elapsed, then return. It also can automatically write out a checkpoint and/or state file before returning, so you can later resume the simulation. Another option allows it to write checkpoints or states at regular intervals, so you can resume even if the simulation is interrupted before the time limit is reached.

Parameters:
time(time) the amount of time to run for. If no units are specified, it is assumed to be a number of hours.
checkpointFile(string or file=None) if specified, a checkpoint file will be written at the end of the simulation (and optionally at regular intervals before then) by passing this to saveCheckpoint().
stateFile(string or file=None) if specified, a state file will be written at the end of the simulation (and optionally at regular intervals before then) by passing this to saveState().
checkpointInterval(time=None) if specified, checkpoints and/or states will be written at regular intervals during the simulation, in addition to writing a final version at the end. If no units are specified, this is assumed to be in hours.
def saveCheckpoint (   self,
  file 
)

Save a checkpoint of the simulation to a file.

The output is a binary file that contains a complete representation of the current state of the Simulation. It includes both publicly visible data such as the particle positions and velocities, and also internal data such as the states of random number generators. Reloading the checkpoint will put the Simulation back into precisely the same state it had before, so it can be exactly continued.

A checkpoint file is highly specific to the Simulation it was created from. It can only be loaded into another Simulation that has an identical System, uses the same Platform and OpenMM version, and is running on identical hardware. If you need a more portable way to resume simulations, consider using saveState() instead.

Parameters:
file(string or file) a File-like object to write the checkpoint to, or alternatively a filename
def saveState (   self,
  file 
)

Save the current state of the simulation to a file.

The output is an XML file containing a serialized State object. It includes all publicly visible data, including positions, velocities, and parameters. Reloading the State will put the Simulation back into approximately the same state it had before.

Unlike saveCheckpoint(), this does not store internal data such as the states of random number generators. Therefore, you should not expect the following trajectory to be identical to what would have been produced with the original Simulation. On the other hand, this means it is portable across different Platforms or hardware.

Parameters:
file(string or file) a File-like object to write the state to, or alternatively a filename
def step (   self,
  steps 
)

Advance the simulation by integrating a specified number of time steps.


Member Data Documentation

The Context containing the current state of the simulation.

The index of the current time step.

The Integrator used to advance the simulation.

A list of reporters to invoke during the simulation.

The System being simulated.

The Topology describing the system being simulated.


The documentation for this class was generated from the following file:
 All Classes Functions Variables