barostat_interval = 25 barostat = mm.MonteCarloBarostat(pressure, temperature, barostat_interval) system.addForce(barostat) #### Platform platform = mm.Platform.getPlatformByName('CUDA') properties = {'CudaPrecision': 'mixed'} #### Simulation simulation = app.Simulation(topology, system, integrator, platform, properties) #### Initial Conditions positions = m3t.get(pdb, coordinates=True) simulation.context.setPositions(positions) simulation.context.setVelocitiesToTemperature(temperature) #### Iterations Parameters steps_simulation = 10000 steps_interval_saving = 500 steps_interval_verbose = 2500 steps_interval_checkpoint = 2500 time_simulation = (steps_simulation * step_size).in_units_of(unit.picoseconds) time_saving = (steps_interval_saving * step_size).in_units_of(unit.picoseconds) time_verbose = (steps_interval_verbose * step_size).in_units_of( unit.picoseconds) time_checkpoint = (steps_interval_checkpoint * step_size).in_units_of(
time_saving = 1.0 * unit.picoseconds time_verbose = 100.0 * unit.picoseconds time_checkpoint = 100.0 * unit.picoseconds number_iterations = int(time_simulation / time_saving) elapsed_iterations_verbose = int(time_verbose / time_saving) elapsed_iterations_checkpoint = int(time_checkpoint / time_saving) steps_per_iteration = int(time_saving / step_size) total_simulation_steps = number_iterations * steps_per_iteration #### Reporters # Observables Stored net_mass, n_degrees_of_freedom = m3t.get(system, net_mass=True, n_degrees_of_freedom=True) number_states_saved = number_iterations + 1 data = dict() data['time'] = unit.Quantity(np.zeros([number_states_saved], np.float64), unit.picoseconds) data['potential'] = unit.Quantity(np.zeros([number_states_saved], np.float64), unit.kilocalories_per_mole) data['kinetic'] = unit.Quantity(np.zeros([number_states_saved], np.float64), unit.kilocalories_per_mole) data['volume'] = unit.Quantity(np.zeros([number_states_saved], np.float64), unit.nanometers**3) data['density'] = unit.Quantity(np.zeros([number_states_saved], np.float64), unit.gram / unit.centimeters**3) data['kinetic_temperature'] = unit.Quantity( np.zeros([number_states_saved], np.float64), unit.kelvin)
import os import molmodmt as m3t import simtk.openmm as mm import simtk.openmm.app as app import simtk.unit as unit from openmmtools.integrators import LangevinIntegrator # Loading initial PDB file molmod_modeller = m3t.load('system_init.pdb','openmm.Modeller') # System topology = m3t.convert(molmod_modeller, 'openmm.Topology') positions = m3t.get(molmod_modeller, coordinates=True) forcefield = app.ForceField('amber99sbildn.xml','tip3p.xml') system = forcefield.createSystem(topology, constraints=app.HBonds) # Thermodynamic state (meaningless here but necessary) temperature = 0.0*unit.kelvin pressure = None # Integrator friction = 1.0/unit.picosecond step_size = 2.0*unit.femtoseconds integrator = LangevinIntegrator(temperature, friction, step_size) integrator.setConstraintTolerance(0.00001)
barostat_interval = 25 barostat = mm.MonteCarloBarostat(pressure, temperature, barostat_interval) system.addForce(barostat) #### Platform platform = mm.Platform.getPlatformByName('CUDA') properties = {'CudaPrecision': 'mixed'} #### Simulation simulation = app.Simulation(topology, system, integrator, platform, properties) #### Initial Conditions positions = m3t.get(pdb, coordinates=True) simulation.context.setPositions(positions) simulation.context.setVelocitiesToTemperature(temperature) #### Iterations Parameters time_simulation = 1.0 * unit.nanoseconds time_saving = 1.0 * unit.picoseconds time_verbose = 100.0 * unit.picoseconds time_checkpoint = 100.0 * unit.picoseconds number_iterations = int(time_simulation / time_saving) elapsed_iterations_verbose = int(time_verbose / time_saving) elapsed_iterations_checkpoint = int(time_checkpoint / time_saving) steps_per_iteration = int(time_saving / step_size) total_simulation_steps = number_iterations * steps_per_iteration