Пример #1
0
 def fluctuations(self, first_mode=6):
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.inv_relaxation_time
     f = Units.k_B * self.temperature * f / self.friction
     return f
Пример #2
0
 def charges(self, universe):
     q = ParticleProperties.ParticleScalar(universe)
     for object in universe:
         for atom in object.atomList():
             q[atom] = object.getAtomProperty(atom,
                                              self.dataset.charge_property)
     return q
Пример #3
0
 def __call__(self, vector):
     conf = self.universe.configuration()
     r = ParticleProperties.ParticleScalar(self.universe)
     l = deformation(conf.array, vector.array, self.pairs,
                     None, r.array, self.cutoff, self.fc_length,
                     self.factor, self.normalize, 0, self.version)
     return r
Пример #4
0
 def fluctuations(self, first_mode=6):
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.force_constant
     if self.temperature is not None:
         f.array *= Units.k_B * self.temperature
     return f
 def fluctuations(self, first_mode=6):
     """Returns a Class:MMTK.ParticleScalar containing the thermal
     fluctuations for each atom in the universe."""
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.inv_relaxation_time
     f = Units.k_B * self.temperature * f / self.friction
     return f
Пример #6
0
 def fluctuations(self, first_mode=6):
     """Returns a Class:MMTK.ParticleScalar containing the thermal
     fluctuations for each atom in the universe."""
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.force_constant
     f.array *= Units.k_B * self.temperature
     return f
Пример #7
0
 def fluctuations(self, first_mode=6):
     """Returns a Class:MMTK.ParticleScalar containing the thermal
     fluctuations for each atom in the universe."""
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.frequency**2
     f.array /= self.weights[:, 0]**2
     f.array *= Units.k_B * self.temperature / (2. * N.pi)**2
     return f
Пример #8
0
 def fluctuations(self, first_mode=6):
     f = ParticleProperties.ParticleScalar(self.universe)
     for i in range(first_mode, self.nmodes):
         mode = self.rawMode(i)
         f += (mode * mode) / mode.frequency**2
     f.array /= self.weights[:, 0]**2
     s = 1. / (2. * N.pi)**2
     if self.temperature is not None:
         s *= Units.k_B * self.temperature
     f.array *= s
     return f
Пример #9
0
 def booleanMask(self):
     """
     :returns: a ParticleScalar object that contains a value of 1
               for each atom that is in the object and a value of 0 for all
               other atoms in the universe
     :rtype: :class:~MMTK.ParticleProperties.ParticleScalar
     """
     universe = self.universe()
     if universe is None:
         raise ValueError("object not in a universe")
     array = N.zeros((universe.numberOfAtoms(), ), N.Int)
     mask = ParticleProperties.ParticleScalar(universe, array)
     for a in self.atomIterator():
         mask[a] = 1
     return mask
Пример #10
0
 def particleValues(self):
     """
     :returns: the values of the field at the positions of the atoms
     :rtype: :class:~MMTK.ParticleProperties.ParticleProperty
     """
     universe = self.system.universe()
     rank = self.field.rank
     if rank == 0:
         v = ParticleProperties.ParticleScalar(universe)
     elif rank == 1:
         v = ParticleProperties.ParticleVector(universe)
     else:
         raise ValueError("no appropriate return type")
     for a in self.system.atomList():
         v[a] = self.field(a.position())
     return v
Пример #11
0
    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())