Пример #1
0
    def __init__(self,
                 temperature,
                 nbins,
                 store_filename,
                 protocol=None,
                 mm=None):
        """
        Initialize a Hamiltonian exchange simulation object.

        ARGUMENTS

        store_filename (string) - name of NetCDF file to bind to for simulation output and checkpointing

        OPTIONAL ARGUMENTS

        protocol (dict) - Optional protocol to use for specifying simulation protocol as a dict. Provided keywords will be matched to object variables to replace defaults.

        NOTES

        von Mises distribution used for restraints

        http://en.wikipedia.org/wiki/Von_Mises_distribution

        """

        import simtk.pyopenmm.extras.testsystems as testsystems

        # Create reference system and state.
        [system, coordinates] = testsystems.AlanineDipeptideImplicit()
        self.reference_system = system
        self.reference_state = repex.ThermodynamicState(
            system=system, temperature=temperature)

        self.nbins = nbins
        self.kT = (repex.kB * temperature)
        self.beta = 1.0 / self.kT

        self.delta = 360.0 / float(
            nbins) * units.degrees  # bin spacing (angular)
        self.sigma = self.delta / 3.0  # standard deviation (angular)
        self.kappa = (self.sigma / units.radians)**(
            -2)  # kappa parameter (unitless)

        # Create list of thermodynamic states with different bias potentials.
        states = list()
        # Create a state without a biasing potential.
        [system, coordinates] = testsystems.AlanineDipeptideImplicit()
        state = repex.ThermodynamicState(system=system,
                                         temperature=temperature)
        states.append(state)
        # Create states with biasing potentials.
        for phi_index in range(nbins):
            for psi_index in range(nbins):
                print "bin (%d,%d)" % (phi_index, psi_index)
                # Create system.
                [system, coordinates] = testsystems.AlanineDipeptideImplicit()
                # Add biasing potentials.
                phi0 = (float(phi_index) +
                        0.5) * self.delta - 180.0 * units.degrees
                psi0 = (float(psi_index) +
                        0.5) * self.delta - 180.0 * units.degrees
                force = openmm.CustomTorsionForce(
                    '-kT * kappa * cos(theta - theta0)')
                force.addGlobalParameter('kT',
                                         self.kT / units.kilojoules_per_mole)
                force.addPerTorsionParameter('kappa')
                force.addPerTorsionParameter('theta0')
                force.addTorsion(4, 6, 8, 14,
                                 [self.kappa, phi0 / units.radians])
                force.addTorsion(6, 8, 14, 16,
                                 [self.kappa, psi0 / units.radians])
                system.addForce(force)
                # Add state.
                state = repex.ThermodynamicState(system=system,
                                                 temperature=temperature)
                states.append(state)

        # Initialize replica-exchange simlulation.
        ReplicaExchange.__init__(self,
                                 states,
                                 coordinates,
                                 store_filename,
                                 protocol=protocol,
                                 mm=mm)

        # Override title.
        self.title = '2D umbrella sampling replica-exchange simulation created on %s' % time.asctime(
            time.localtime())

        return
Пример #2
0
    def __init__(self, temperature, nbins, store_filename, protocol=None, mm=None):
        """
        Initialize a Hamiltonian exchange simulation object.

        ARGUMENTS

        store_filename (string) - name of NetCDF file to bind to for simulation output and checkpointing

        OPTIONAL ARGUMENTS

        protocol (dict) - Optional protocol to use for specifying simulation protocol as a dict. Provided keywords will be matched to object variables to replace defaults.

        NOTES

        von Mises distribution used for restraints

        http://en.wikipedia.org/wiki/Von_Mises_distribution

        """

        import simtk.pyopenmm.extras.testsystems as testsystems
        
        # Create reference system and state.        
        [system, coordinates] = testsystems.AlanineDipeptideImplicit()
        self.reference_system = system
        self.reference_state = repex.ThermodynamicState(system=system, temperature=temperature)

        self.nbins = nbins
        self.kT = (repex.kB * temperature)
        self.beta = 1.0 / self.kT

        self.delta = 360.0 / float(nbins) * units.degrees # bin spacing (angular)
        self.sigma = self.delta/3.0 # standard deviation (angular)
        self.kappa = (self.sigma / units.radians)**(-2) # kappa parameter (unitless)

        # Create list of thermodynamic states with different bias potentials.
        states = list()
        # Create a state without a biasing potential.
        [system, coordinates] = testsystems.AlanineDipeptideImplicit()
        state = repex.ThermodynamicState(system=system, temperature=temperature)
        states.append(state)        
        # Create states with biasing potentials.
        for phi_index in range(nbins):
            for psi_index in range(nbins):
                print "bin (%d,%d)" % (phi_index, psi_index)
                # Create system.
                [system, coordinates] = testsystems.AlanineDipeptideImplicit()                
                # Add biasing potentials.
                phi0 = (float(phi_index) + 0.5) * self.delta - 180.0 * units.degrees 
                psi0 = (float(psi_index) + 0.5) * self.delta - 180.0 * units.degrees 
                force = openmm.CustomTorsionForce('-kT * kappa * cos(theta - theta0)')
                force.addGlobalParameter('kT', self.kT / units.kilojoules_per_mole)
                force.addPerTorsionParameter('kappa')  
                force.addPerTorsionParameter('theta0')
                force.addTorsion(4, 6, 8, 14, [self.kappa, phi0 / units.radians])
                force.addTorsion(6, 8, 14, 16, [self.kappa, psi0 / units.radians])            
                system.addForce(force)
                # Add state.
                state = repex.ThermodynamicState(system=system, temperature=temperature)
                states.append(state)

        # Initialize replica-exchange simlulation.
        ReplicaExchange.__init__(self, states, coordinates, store_filename, protocol=protocol, mm=mm)

        # Override title.
        self.title = '2D umbrella sampling replica-exchange simulation created on %s' % time.asctime(time.localtime())
        
        return