forked from leeping/molssi-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_openmm.py
61 lines (47 loc) · 2.33 KB
/
run_openmm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from __future__ import print_function
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
from sys import stdout
# Load the PDB file into an object
pdb = app.PDBFile('trpcage.pdb')
# Load the force field file into an object
forcefield = app.ForceField('amber99sbildn.xml', 'tip3p.xml')
# Create system object using information in the force field:
# forcefield: contains parameters of interactions
# topology: lists of atoms, residues, and bonds
system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.PME,
nonbondedCutoff=1.0*unit.nanometers, constraints=app.HBonds, rigidWater=True,
ewaldErrorTolerance=0.0005)
# Create a Langevin integrator for temperature control
integrator = mm.LangevinIntegrator(300*unit.kelvin, 1.0/unit.picoseconds,
2.0*unit.femtoseconds)
# Add a Monte Carlo barostat to the system for pressure control
system.addForce(mm.MonteCarloBarostat(1*unit.atmospheres, 300*unit.kelvin, 25))
# Use the CPU platform
platform = mm.Platform.getPlatformByName('CPU')
### If you want to add any forces to your System or modify any
### of the existing forces, you should do it here - after the
### System has been created, but before the Simulation is created.
# Create a Simulation object by putting together the objects above
simulation = app.Simulation(pdb.topology, system, integrator, platform)
# Set positions in the Simulation object
simulation.context.setPositions(pdb.positions)
# Minimize the energy of the system (intentionally doing a rough minimization)
print('Minimizing...')
simulation.minimizeEnergy(maxIterations=20, tolerance=100)
# Initialize the random velocities of the system from a Maxwell-Boltzmann distribution
simulation.context.setVelocitiesToTemperature(300*unit.kelvin)
# Add reporters to the simulation object, which do things at regular intervals
# while the simulation is running.
# This reporter creates a DCD trajectory file
# A: Christian Bale
simulation.reporters.append(app.DCDReporter('trajectory.dcd', 100))
# This reporter prints information to the terminal
simulation.reporters.append(app.StateDataReporter(stdout, 100, step=True,
potentialEnergy=True, temperature=True, density=True, progress=True,
remainingTime=True, speed=True, totalSteps=10000, separator='\t'))
# Run the simulation itself
print('Running Production...')
simulation.step(10000)
print('Done!')