This is basically a port of the webapp. It doesn't (yet) include some of the features that Lee-Ping has implemented, like saving restart files and adding new reporters. If we want to include those things with the openmm app, they should probably go in the library anyways.
Here's what it looks like running. Python code showing its interaction with the OpenMM API is printed out in real-time, as it's executed. There are some log messages too.
rmcgibbo@vspm9 ~/local/openmm_build/python
$ openmm --coords=~/local/openmm_tests/input.pdb
[Script] >>> import sys
[Script] >>> from simtk.unit import *
[Script] >>> import simtk.openmm as mm
[Script] >>> from simtk.openmm import app
[Script] >>>
[Script] >>> pdb = app.PDBFile('/home/rmcgibbo/local/openmm_tests/input.pdb')
[Script] >>> positions = pdb.positions
[Script] >>> topology = pdb.topology
[OpenMM] Topology is contains periodic boundary conditions
[Script] >>> forcefield = app.ForceField('amber99sbildn.xml', 'tip3p.xml')
[Script] >>> system = forcefield.createSystem(topology, nonbondedMethod=PME, nonbondedCutoff=1.0*nanometer, constraints=HBonds, rigidWater=True, ewaldErrorTolerance=0.0005)
[Script] >>> integrator = mm.LangevinIntegrator(300*kelvin, 1.0/picosecond, 2*femtosecond)
[Script] >>> platform = None
[Script] >>> platformProperties = None
[Script] >>> similation = app.Simulation(topology, system, integrator,platform, platformProperties)
[Script] >>> simulation.context.setPositions(positions)
[OpenMM] Minimizing...
[Script] >>> simulation.minimizeEnergy()
... more...
Here's the -h
output:
rmcgibbo@vspm9 ~/local/openmm_build/python
$ openmm -h
OpenMM: GPU Accelerated Molecular Dynamics
==========================================
Run a molecular simulaton using the OpenMM toolkit. Options can be either
specified on the command line, or in an input file, conventionally named
openmm_config.py. If a single option is specified in both places, the command
line value will take precidence.
For example, to override your input configuration file to change the barostat
pressure to 200 kilopasals, you would add the flag
`--Integrator.pressure=200*kilopascals` to your command line invocation. Use
`--help-all` for details.
Subcommands
-----------
make_config
Make a template input configuration file
Options
-------
--config=<String>
Default: openmm_config.py
Path to a configuration file to load from (or to save to, if using `make_config`).
--coords=<Unicode> (General.coords)
Default: u''
OpenMM can take a pdb...
--log_level=<Enum> (General.log_level)
Default: 'INFO'
Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
Set the log level by value or name.
To see all available configurables, use `--help-all`
The rest of the options are hiding under --help-all
. They're organizing following the same structure that I used for
the tabs on the webapp.
$ openmm --help-all
OpenMM: GPU Accelerated Molecular Dynamics
==========================================
Run a molecular simulaton using the OpenMM toolkit. Options can be either
specified on the command line, or in an input file, conventionally named
openmm_config.py. If a single option is specified in both places, the command
line value will take precidence.
For example, to override your input configuration file to change the barostat
pressure to 200 kilopasals, you would add the flag
`--Integrator.pressure=200*kilopascals` to your command line invocation. Use
`--help-all` for details.
Subcommands
-----------
make_config
Make a template input configuration file
Options
-------
--config=<String>
Default: openmm_config.py
Path to a configuration file to load from (or to save to, if using `make_config`).
--coords=<Unicode> (General.coords)
Default: u''
OpenMM can take a pdb...
--log_level=<Enum> (General.log_level)
Default: 'INFO'
Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
Set the log level by value or name.
General options
---------------
--General.coords=<Unicode>
Default: u''
OpenMM can take a pdb...
--General.forcefield=<CaselessStrEnum>
Default: 'amber99sb-ildn'
Choices: ['amber96', 'amber99sb', 'amber99sb-ildn', 'amber99sb-nmr', 'amber03', 'amber10']
Forcefield to use for the protein atoms. For details, consult the
literature.
--General.log_level=<Enum>
Default: 'INFO'
Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
Set the log level by value or name.
--General.platform=<CaselessStrEnum>
Default: None
Choices: ['Reference', 'OpenCL', 'CUDA']
OpenMM runs simulations on three platforms: Reference, CUDA, and OpenCL. If
not specified, the fastest available platform will be selected
automatically.
--General.precision=<CaselessStrEnum>
Default: None
Choices: ['Single', 'Mixed', 'Double']
Level of numeric precision to use for calculations.
--General.water=<CaselessStrEnum>
Default: 'TIP3P'
Choices: ['SPC/E', 'TIP3P', 'TIP4-Ew', 'TIP5P', 'Implict']
Forcefield to use for water in the simulation.
System options
--------------
--System.constraints=<CaselessStrEnum>
Default: 'HBonds'
Choices: ['None', 'HBonds', 'AllBonds', 'HAngles']
Applying constraints to some of the atoms can enable you to take longer
timesteps.
--System.cutoff=<Quantity>
Default: 1.0*nanometer
Cutoff for long-range non-bonded interactions. This option is usef for all
non-bonded methods except for "NoCutoff".
--System.ewald_tol=<Float>
Default: 0.0005
The error tolerance is roughly equal to the fractional error in the forces
due to truncating the Ewald summation. Only applicable when nonbonded ==
Ewald or nonbonded == PME.
--System.gen_temp=<Quantity>
Default: 300*kelvin
Temperature used for generating initial velocities. This option is only used
if rand_vels == True.
--System.nb_method=<CaselessStrEnum>
Default: 'PME'
Choices: ['NoCutoff', 'CutoffNonPeriodic', 'CutoffPeriodic', 'Ewald', 'PME']
Method for calculating long range non-bondend interactions. Refer to the
user guide for a detailed discussion.
--System.rand_vels=<Bool>
Default: True
Initialize the system with random initial velocities, drawn from the Maxwell
Boltzmann distribution.
--System.rigid_water=<Bool>
Default: True
Keep water rigid. Be aware that flexible water may require you to further
reduce the integration step size, typically to about 0.5 fs.
Integrator options
------------------
--Integrator.barostat=<CaselessStrEnum>
Default: 'None'
Choices: ['MonteCarlo', 'None']
Activate a barostat for pressure coupling. The MC barostat requires
temperature control (stochastic integrator or Andersen thermostat) to be in
effect as well.
--Integrator.barostat_interval=<Int>
Default: 25
The frequency (in time steps) at which Monte Carlo pressure changes should
be attempted. This option is only invoked when barostat == MonteCarlo.
--Integrator.collision_rate=<Quantity>
Default: 1.0/picosecond
Friction coefficient, for use with stochastic integrators or the Anderson
thermostat.
--Integrator.dt=<Quantity>
Default: 2*femtosecond
Timestep for fixed-timestep integrators.
--Integrator.kind=<CaselessStrEnum>
Default: 'Langevin'
Choices: ['Langevin', 'Verlet', 'Brownian', 'VariableLangevin', 'VariableVerlet']
OpenMM offers a choice of several different integration methods. Refer to
the user guide for details.
--Integrator.pressure=<Quantity>
Default: 1*atmosphere
Pressure target, used by a barostat.
--Integrator.temp=<Quantity>
Default: 300*kelvin
Temperature of the heat bath, used either by a stochastic integrator or the
Andersen thermostat to maintain a constant temperature ensemble.
--Integrator.thermostat=<CaselessStrEnum>
Default: 'None'
Choices: ['Andersen', 'None']
Activate a thermostat to maintain a constant temperature simulation.
--Integrator.tolerance=<Float>
Default: 0.0001
Tolerance for variable timestep integrators ('VariableLangevin',
'VariableVerlet'). Smaller values will produce a smaller average step size.
Simulation options
------------------
--Simulation.equil_steps=<Int>
Default: 100
Number of steps of equilibration to run, prior to attaching reporters and
running production.
--Simulation.minimize=<Bool>
Default: True
First perform local energy minimization, to find a local potential energy
minimum near the starting structure.
--Simulation.prod_steps=<Int>
Default: 1000
Number of steps of production simulation to run.
--Simulation.statedata_freq=<Int>
Default: 1000
Frequency, in steps, to print summary statistics on the state of the
simulation.
--Simulation.traj_file=<Unicode>
Default: 'output.dcd'
Filename to save the resulting trajectory to, in DCD format.
--Simulation.traj_freq=<Int>
Default: 1000
Frequency, in steps, to save the state to disk in the DCD format.
Specifying all of those options on the command line would be a nightmare. How about the config file?
It's prety easy to make.
rmcgibbo@vspm9 ~/local/openmm_build/python
$ openmm make_config
Saving new template config file to openmm_config.py
Everything is commented out, showing the default options. It's pretty convenient to have the help text right there too. This is pure python, but it's not general purpose -- we're basically just using python for its lexer/parser. The only "python" aspect of it is that we can use units. All of the options are typechecked statically when the config file loaded up.
rmcgibbo@vspm9 ~/local/openmm_build/python
$ cat openmm_config.py
# Configuration file for openmm.
from simtk.unit import *
c = get_config()
#------------------------------------------------------------------------------
# General configuration
#------------------------------------------------------------------------------
# Set the log level by value or name.
# c.General.log_level = 'INFO'
# Level of numeric precision to use for calculations.
# c.General.precision = None
# Forcefield to use for water in the simulation.
# c.General.water = 'TIP3P'
# OpenMM runs simulations on three platforms: Reference, CUDA, and OpenCL. If
# not specified, the fastest available platform will be selected automatically.
# c.General.platform = None
# OpenMM can take a pdb...
# c.General.coords = u''
# Forcefield to use for the protein atoms. For details, consult the literature.
# c.General.forcefield = 'amber99sb-ildn'
#------------------------------------------------------------------------------
# System configuration
#------------------------------------------------------------------------------
# Cutoff for long-range non-bonded interactions. This option is usef for all
# non-bonded methods except for "NoCutoff".
# c.System.cutoff = 1.0*nanometer
# Initialize the system with random initial velocities, drawn from the Maxwell
# Boltzmann distribution.
# c.System.rand_vels = True
# The error tolerance is roughly equal to the fractional error in the forces due
# to truncating the Ewald summation. Only applicable when nonbonded == Ewald or
# nonbonded == PME.
# c.System.ewald_tol = 0.0005
# Keep water rigid. Be aware that flexible water may require you to further
# reduce the integration step size, typically to about 0.5 fs.
# c.System.rigid_water = True
# Temperature used for generating initial velocities. This option is only used
# if rand_vels == True.
# c.System.gen_temp = 300*kelvin
# Method for calculating long range non-bondend interactions. Refer to the user
# guide for a detailed discussion.
# c.System.nb_method = 'PME'
# Applying constraints to some of the atoms can enable you to take longer
# timesteps.
# c.System.constraints = 'HBonds'
#------------------------------------------------------------------------------
# Integrator configuration
#------------------------------------------------------------------------------
# OpenMM offers a choice of several different integration methods. Refer to the
# user guide for details.
# c.Integrator.kind = 'Langevin'
# Friction coefficient, for use with stochastic integrators or the Anderson
# thermostat.
# c.Integrator.collision_rate = 1.0/picosecond
# Activate a barostat for pressure coupling. The MC barostat requires
# temperature control (stochastic integrator or Andersen thermostat) to be in
# effect as well.
# c.Integrator.barostat = 'None'
# Activate a thermostat to maintain a constant temperature simulation.
# c.Integrator.thermostat = 'None'
# Temperature of the heat bath, used either by a stochastic integrator or the
# Andersen thermostat to maintain a constant temperature ensemble.
# c.Integrator.temp = 300*kelvin
# Pressure target, used by a barostat.
# c.Integrator.pressure = 1*atmosphere
# The frequency (in time steps) at which Monte Carlo pressure changes should be
# attempted. This option is only invoked when barostat == MonteCarlo.
# c.Integrator.barostat_interval = 25
# Timestep for fixed-timestep integrators.
# c.Integrator.dt = 2*femtosecond
# Tolerance for variable timestep integrators ('VariableLangevin',
# 'VariableVerlet'). Smaller values will produce a smaller average step size.
# c.Integrator.tolerance = 0.0001
#------------------------------------------------------------------------------
# Simulation configuration
#------------------------------------------------------------------------------
# First perform local energy minimization, to find a local potential energy
# minimum near the starting structure.
c.Simulation.minimize = False
# Number of steps of production simulation to run.
c.Simulation.prod_steps = 0
# Frequency, in steps, to print summary statistics on the state of the
# simulation.
# c.Simulation.statedata_freq = 1000
# Frequency, in steps, to save the state to disk in the DCD format.
# c.Simulation.traj_freq = 1000
# Filename to save the resulting trajectory to, in DCD format.
# c.Simulation.traj_file = 'output.dcd'
# Number of steps of equilibration to run, prior to attaching reporters and
# running production.
c.Simulation.equil_steps = 0