def __call__(self, **options): # Process the keyword arguments self.setCallOptions(options) # Check if the universe has features not supported by the integrator Features.checkFeatures(self, self.universe) # Get the universe variables needed by the integrator configuration = self.universe.configuration() masses = self.universe.masses() velocities = self.universe.velocities() if velocities is None: raise ValueError("no velocities") # Get the friction coefficients. First check if a keyword argument # 'friction' was given to the integrator. Its value can be a # ParticleScalar or a plain number (used for all atoms). If no # such argument is given, collect the values of the attribute # 'friction' from all atoms (default is zero). try: friction = self.getOption('friction') except KeyError: friction = self.universe.getParticleScalar('friction') if not ParticleProperties.isParticleProperty(friction): var = ParticleProperties.ParticleScalar(self.universe) var.array[:] = friction friction = var # Construct a C evaluator object for the force field, using # the specified number of threads or the default value nt = self.getOption('threads') evaluator = self.universe.energyEvaluator(threads=nt).CEvaluator() # Run the C integrator MMTK_langevin.integrateLD(self.universe, configuration.array, velocities.array, masses.array, friction.array, evaluator, self.getOption('temperature'), self.getOption('delta_t'), self.getOption('steps'), self.getActions())
def __call__(self, **options): # Process the keyword arguments self.setCallOptions(options) # Check if the universe has features not supported by the integrator Features.checkFeatures(self, self.universe) #the following two lines are required due to MMTK mixing up atom indices. This sorts them. #atoms = self.universe.atomList() #atoms.sort(key=operator.attrgetter('index')) # Get the universe variables needed by the integrator configuration = self.universe.configuration() velocities = self.universe.velocities() if velocities is None: raise ValueError("no velocities") # Get the friction coefficients. First check if a keyword argument # 'friction' was given to the integrator. Its value can be a # ParticleScalar or a plain number (used for all atoms). If no # such argument is given, collect the values of the attribute # 'friction' from all atoms (default is zero). friction = self.getOption('friction') #call this method to create the OpenMM System. Without this, creating #the forces will fail!! self.initOmmSystem() #call this method to ensure that the forcefield parameters get #passed to OpenMM. Without this, there will be no forces to integrate! self.createOmmForces() #The restraint option must be included in the creation of the integrator for this part to be executed try: restraint = self.getOption('restraint') except ValueError: restraint = None print 'No restraints (Value Error)' except: print sys.exc_info()[0] if restraint != None: self.addRestraint(restraint) #ugly hack to get timestep skip information skip = -1 if ('actions' in self.call_options): actions = self.call_options['actions'] for action in actions: if isinstance(action, Dynamics.TranslationRemover): self.addOmmCMRemover(action.skip) if isinstance(action, Trajectory.LogOutput): break # to avoid Logoutput skip setting problem PNR NFF SJC if isinstance(action, Trajectory.TrajectoryOutput): skip = action.skip action.skip = 1 if skip < 0 : for action in actions: if issubclass(action.__class__, Trajectory.TrajectoryOutput): skip = action.skip action.skip = 1 break #we are not logging anything, so we don't have to report any intermediate values if skip < 0: skip = 100 steps = 1 # Run the C integrator atoms = self.universe.atomList() masses = [atom.mass() for atom in atoms] natoms = len(atoms) nmolecules = len(self.universe.objectList(Molecule)) molecule_lengths = N.zeros(nmolecules, dtype=N.int32, order='C') for i in range(0,len(self.universe.objectList(Molecule))): molecule_lengths[i] = len(self.universe.objectList(Molecule)[i].atomList()) MMTK_langevin.integrateLD(self.universe, configuration.array, velocities.array, N.array(masses, dtype=N.float64), friction, self.getOption('temperature'), self.getOption('delta_t'), self.getOption('steps'), skip, natoms, self.nbeads, nmolecules, molecule_lengths, self.getActions()) #call this to clean up after ourselves self.destroyOmmSystem()
def __call__(self, **options): # Process the keyword arguments self.setCallOptions(options) # Check if the universe has features not supported by the integrator Features.checkFeatures(self, self.universe) #the following two lines are required due to MMTK mixing up atom indices. This sorts them. #atoms = self.universe.atomList() #atoms.sort(key=operator.attrgetter('index')) # Get the universe variables needed by the integrator configuration = self.universe.configuration() velocities = self.universe.velocities() if velocities is None: raise ValueError("no velocities") # Get the friction coefficients. First check if a keyword argument # 'friction' was given to the integrator. Its value can be a # ParticleScalar or a plain number (used for all atoms). If no # such argument is given, collect the values of the attribute # 'friction' from all atoms (default is zero). friction = self.getOption('friction') #call this method to create the OpenMM System. Without this, creating #the forces will fail!! self.initOmmSystem() #call this method to ensure that the forcefield parameters get #passed to OpenMM. Without this, there will be no forces to integrate! self.createOmmForces() #The restraint option must be included in the creation of the integrator for this part to be executed try: restraint = self.getOption('restraint') except ValueError: restraint = None print 'No restraints (Value Error)' except: print sys.exc_info()[0] if restraint != None: self.addRestraint(restraint) #ugly hack to get timestep skip information skip = -1 if ('actions' in self.call_options): actions = self.call_options['actions'] for action in actions: if isinstance(action, Dynamics.TranslationRemover): self.addOmmCMRemover(action.skip) if isinstance(action, Trajectory.LogOutput): break # to avoid Logoutput skip setting problem PNR NFF SJC if isinstance(action, Trajectory.TrajectoryOutput): skip = action.skip action.skip = 1 if skip < 0: for action in actions: if issubclass(action.__class__, Trajectory.TrajectoryOutput): skip = action.skip action.skip = 1 break #we are not logging anything, so we don't have to report any intermediate values if skip < 0: skip = 100 steps = 1 # Run the C integrator atoms = self.universe.atomList() masses = [atom.mass() for atom in atoms] natoms = len(atoms) nmolecules = len(self.universe.objectList(Molecule)) molecule_lengths = N.zeros(nmolecules, dtype=N.int32, order='C') for i in range(0, len(self.universe.objectList(Molecule))): molecule_lengths[i] = len( self.universe.objectList(Molecule)[i].atomList()) MMTK_langevin.integrateLD(self.universe, configuration.array, velocities.array, N.array(masses, dtype=N.float64), friction, self.getOption('temperature'), self.getOption('delta_t'), self.getOption('steps'), skip, natoms, self.nbeads, nmolecules, molecule_lengths, self.getActions()) #call this to clean up after ourselves self.destroyOmmSystem()