def make_toy_system_object(model): """ Make openmm system and topology files for use with a toy system. """ system = openmm.System() topology = openmm_app.Topology() num_particles = model.toy_settings.num_particles assert model.toy_settings.num_particles == len(model.toy_settings.masses) new_expression = "k*(" + model.toy_settings.potential_energy_expression + ")" force = openmm.CustomCentroidBondForce(num_particles, new_expression) force.addGlobalParameter("k", 1.0 * openmm.unit.kilocalories_per_mole) groups_list = [] for i in range(num_particles): mass = model.toy_settings.masses[i] * openmm.unit.amu system.addParticle(mass) atom_name = "X{}".format(i) if not atom_name in openmm_app.element.Element._elements_by_symbol: element = openmm_app.element.Element(0, atom_name, atom_name, mass) else: element = openmm_app.element.Element._elements_by_symbol[atom_name] chain = topology.addChain() residue = topology.addResidue("UNK", chain) topology.addAtom(atom_name, element, residue) groups_list.append(force.addGroup([i])) force.addBond(groups_list, []) system.addForce(force) return system, topology
def make_fwd_rev_force_object(self): """ Make a list of reversal force objects, which will be used to monitor milestone crossing during the reversal stage. """ try: import openmm except ImportError: import simtk.openmm as openmm return openmm.CustomCentroidBondForce( self.num_groups, self.openmm_fwd_rev_expression)
def make_umbrella_force_object(self): """ Make an umbrella sampling force object, which will constrain the system to the milestone. """ try: import openmm except ImportError: import simtk.openmm as openmm return openmm.CustomCentroidBondForce( self.num_groups, self.openmm_umbrella_expression)
def make_force_object(self): """ Create an OpenMM force object which will be used to compute the value of the CV's mathematical expression as the simulation propagates. Each *milestone* in a cell, not each CV, will have a force object created. In this implementation of MMVT in OpenMM, CustomForce objects are used to provide the boundary definitions of the MMVt cell. These 'forces' are designed to never affect atomic motions, but are merely monitored by the plugin for bouncing event. So while they are technically OpenMM force objects, we don't refer to them as forces outside of this layer of the code, preferring instead the term: boundary definitions. """ try: import openmm except ImportError: import simtk.openmm as openmm assert self.num_groups == 2 return openmm.CustomCentroidBondForce(self.num_groups, self.openmm_expression)
# (s.atom_list['residue_index'] == 999)] A2 = coord.getPositions()[-1] Z_A2 = A2[2] external_force2.addGlobalParameter('k_spring', 10) external_force2.addGlobalParameter('x_A2', A2[0]) external_force2.addGlobalParameter('y_A2', A2[1]) external_force2.addGlobalParameter('Z_A2', A2[2]) external_force2.addParticle(int(s.atom_list.index[-1])) external_force.setForceGroup(10) external_force2.setForceGroup(10) s.system.addForce(external_force) s.system.addForce(external_force2) #Add bond between pulling particle and the com of the pulled particles centroid_force = openmm.CustomCentroidBondForce(2, "0.5*k*distance(g1,g2)^2") centroid_force.addPerBondParameter("k") centroid_force.addGroup([int(a) for a in A_index]) centroid_force.addGroup([int(a) for a in B_index]) centroid_force.addGroup([int(s.atom_list.index[-2])]) # A centroid_force.addGroup([int(s.atom_list.index[-1])]) # B centroid_force.addBond([0, 2], [1]) # A centroid_force.addBond([1, 3], [1]) # B centroid_force.setForceGroup(11) s.system.addForce(centroid_force) # Set up simulation temperature = sjob["temperature"] * u.kelvin integrator = openmm.LangevinIntegrator(temperature, .0001 / u.picosecond, 1 * u.picoseconds) simulation = openmm.app.Simulation(top.topology, s.system, integrator,