def get_openmm_integrator(self): from simtk import openmm integrator = openmm.LangevinIntegrator( pint2simtk(self.params.temperature), pint2simtk(self.params.collision_rate), pint2simtk(self.params.timestep)) return integrator
def _set_constraints(self): system = self.mm_system fixed_atoms = set() # Constrain atom positions for constraint in self.mol.constraints: if constraint.desc == 'position': fixed_atoms.add(constraint.atom) self.mol.assert_atom(constraint.atom) system.setParticleMass(constraint.atom.index, 0.0) # Constrain distances between atom pairs elif constraint.desc == 'distance': self.mol.assert_atom(constraint.a1) self.mol.assert_atom(constraint.a2) system.addConstraint(constraint.a1, constraint.a2, opm.pint2simtk(constraint.value)) else: raise ValueError('OpenMM interface does not support "%s" constraints.' % constraint.desc) # Workaround for OpenMM issue: can't have an atom that's both fixed *and* has a distance constraint. # If both atoms in the distance constraint are also fixed, then we can just remove the constraint if len(fixed_atoms) > 0: num_constraints = system.getNumConstraints() ic = 0 while ic < num_constraints: i, j, dist = system.getConstraintParameters(ic) ai = self.mol.atoms[i] aj = self.mol.atoms[j] if (ai in fixed_atoms) and (aj in fixed_atoms): system.removeConstraint(ic) num_constraints -= 1 elif (ai in fixed_atoms) or (aj in fixed_atoms): #only one is fixed raise ValueError('In OpenMM, fixed atoms cannot be part of a constrained ' 'bond (%s)'%moldesign.molecules.bonds.Bond(ai, aj)) else: ic += 1
def _get_system_params(self): """ Translates the spec from MMBase into system parameter keywords for createSystem """ # need cmm motion nonbonded_names = {'nocutoff': opm.app.NoCutoff, 'ewald': opm.app.Ewald, 'pme': opm.app.PME, 'cutoff': opm.app.CutoffPeriodic if self.params.periodic else opm.app.CutoffNonPeriodic} implicit_solvent_names = {'obc': opm.app.OBC2} system_params = dict(nonbondedMethod=nonbonded_names[self.params.nonbonded], nonbondedCutoff=opm.pint2simtk(self.params.cutoff), implicitSolvent=implicit_solvent_names[self.params.implicit_solvent]) system_params['rigidWater'] = False system_params['constraints'] = None if self.mol.integrator is not None: if self.mol.integrator.params.get('constrain_water', False): system_params['rigidWater'] = True if self.mol.integrator.params.get('constrain_hbonds', False): system_params['constraints'] = opm.app.HBonds return system_params
def get_openmm_integrator(self): from simtk import openmm integrator = openmm.VerletIntegrator(pint2simtk(self.params.timestep)) return integrator
def _set_openmm_state(self): # TODO: periodic state self.sim.context.setPositions(opm.pint2simtk(self.mol.positions)) self.sim.context.setVelocities(opm.pint2simtk(self.mol.velocities)) self.sim.context.setTime(opm.pint2simtk(self.mol.time))
def to_simtk(self): """ Return a SimTK quantity object """ from moldesign.interfaces.openmm import pint2simtk return pint2simtk(self)
def get_openmm_integrator(self): integrator = mm.LangevinIntegrator( pint2simtk(self.params.temperature), pint2simtk(self.params.collision_rate), pint2simtk(self.params.timestep)) return integrator
def get_openmm_integrator(self): integrator = mm.VerletIntegrator(pint2simtk(self.params.timestep)) return integrator
def to_simtk(self): from moldesign.interfaces.openmm import pint2simtk return pint2simtk(self)