Exemplo n.º 1
0
 def centerAndMomentOfInertia(self, conf=None):
     """
     :param conf: a configuration object, or None for the
                  current configuration
     :type conf: :class:~MMTK.ParticleProperties.Configuration or NoneType
     :returns: the center of mass and the moment of inertia tensor
               in the given configuration
     """
     from Scientific.Geometry import delta
     offset = None
     universe = self.universe()
     if universe is not None:
         offset = universe.contiguousObjectOffset([self], conf)
     m = 0.
     mr = Vector(0., 0., 0.)
     t = Tensor(3 * [3 * [0.]])
     for a in self.atomIterator():
         ma = a._mass
         if offset is None:
             r = a.position(conf)
         else:
             r = a.position(conf) + offset[a]
         m += ma
         mr += ma * r
         t += ma * r.dyadicProduct(r)
     cm = mr / m
     t -= m * cm.dyadicProduct(cm)
     t = t.trace() * delta - t
     return cm, t
Exemplo n.º 2
0
 def centerAndMomentOfInertia(self, conf = None):
     """
     :param conf: a configuration object, or None for the
                  current configuration
     :type conf: :class:`~MMTK.ParticleProperties.Configuration` or NoneType
     :returns: the center of mass and the moment of inertia tensor
               in the given configuration
     """
     from Scientific.Geometry import delta
     offset = None
     universe = self.universe()
     if universe is not None:
         offset = universe.contiguousObjectOffset([self], conf)
     m = 0.
     mr = Vector(0.,0.,0.)
     t = Tensor(3*[3*[0.]])
     for a in self.atomIterator():
         ma = a._mass
         if offset is None:
             r = a.position(conf)
         else:
             r = a.position(conf)+offset[a]
         m += ma
         mr += ma*r
         t += ma*r.dyadicProduct(r)
     cm = mr/m
     t -= m*cm.dyadicProduct(cm)
     t = t.trace()*delta - t
     return cm, t
Exemplo n.º 3
0
    def centerAndMomentOfInertia(self, conf = None):
        "Returns the center of mass and the moment of inertia tensor."
        from Scientific.Geometry.TensorModule import delta
        offset = None
        universe = self.universe()
        if universe is not None:
            offset = universe.contiguousObjectOffset([self], conf)
	m = 0.
	mr = Vector(0.,0.,0.)
	t = Tensor(3*[3*[0.]])
	for a in self.atomList():
	    ma = a._mass
            if offset is None:
                r = a.position(conf)
            else:
                r = a.position(conf)+offset[a]
	    m = m + ma
	    mr = mr + ma*r
	    t = t + ma*r.dyadicProduct(r)
	cm = mr/m
	t = t - m*cm.dyadicProduct(cm)
	t = t.trace()*delta - t
	return cm, t
Exemplo n.º 4
0
 def centerAndMomentOfInertia(self, conf=None):
     "Returns the center of mass and the moment of inertia tensor."
     from Scientific.Geometry import delta
     offset = None
     universe = self.universe()
     if universe is not None:
         offset = universe.contiguousObjectOffset([self], conf)
     m = 0.
     mr = Vector(0., 0., 0.)
     t = Tensor(3 * [3 * [0.]])
     for a in self.atomList():
         ma = a._mass
         if offset is None:
             r = a.position(conf)
         else:
             r = a.position(conf) + offset[a]
         m = m + ma
         mr = mr + ma * r
         t = t + ma * r.dyadicProduct(r)
     cm = mr / m
     t = t - m * cm.dyadicProduct(cm)
     t = t.trace() * delta - t
     return cm, t