''' BSD 3-Clause License Copyright (c) 2017, Stephen J. Constable, University of Rochester All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''' from simtk.openmm.app import * from simtk.openmm import * from simtk.unit import * from sys import stdout, argv # read file names from command line if len(argv) != 4: usage = ''' Usage: %s = name of .gro file from SMOG = name of .top file from SMOG = name of DCD file that will be generated ''' % argv[0] print usage exit(-1) else: gro_file = argv[1] top_file = argv[2] out_file = argv[3] # time step in reduced units. Note that mass of Carbon is 1.0 so the timestep # can be larger than is used in other MD simulations. dt = 0.0005 * picoseconds # total number of integration steps nsteps = 100000 # frequency to write output to restart file (.rst). Restart files are used to # restart simulations. You do not need to write data to this file too often. nstxout = 100000 # frequency to write energies to log file nstlog = 1000 # frequency to write data to .dcd trajectory nstdcdout = 1000 # langevin friction gamma = 1.0 / picosecond # target temperature temp = 50.0 * kelvin # coulomb and L-J cutoff distance rcutoff = 1.5 * nanometers gro = GromacsGroFile(gro_file) top = GromacsTopFile(top_file) system = top.createSystem(nonbondedMethod=CutoffNonPeriodic, nonbondedCutoff=rcutoff) integrator = LangevinIntegrator(temp, gamma, dt) simulation = Simulation(top.topology, system, integrator) simulation.context.setPositions(gro.positions) simulation.context.setVelocitiesToTemperature(temp) simulation.reporters.append(DCDReporter(out_file, nstdcdout)) simulation.reporters.append(CheckpointReporter('%s.chk' % out_file, nstxout)) simulation.reporters.append(StateDataReporter('energy.log', nstlog, step=True, potentialEnergy=True, temperature=True)) simulation.step(nsteps)