Beispiel #1
0
    def center_mass(self, list_of_atoms=None):
        """
        Computes the center of mass (CM) of the XYZ object or
        a partial list of atoms. The default is to compute the
        CM of all the atoms in the object, if a list
        is enter only those in the list will be included for the CM
        Return the CM as a numpy array
        """
        if list_of_atoms is None:
            list_of_atoms = range(self.natom)

        total_mass = 0.0
        center_of_mass = np.zeros(3)
        if self.natom == 0:
            return center_of_mass

        atomicnumber = atomic_number(list(self.symbols))

        for i in range(self.natom):
            if i in list_of_atoms:
                total_mass = total_mass + mass(atomicnumber[i])
                center_of_mass = center_of_mass + mass(
                    atomicnumber[i]) * self.positions[i]

        return center_of_mass / total_mass
Beispiel #2
0
    def product_of_inertia(self, axis):

        assert self.is_perfect
        I = 0
        for isite in self:
            I += mass(isite.symbols[0]) * (np.prod(isite.position) / isite.position[axis])
        return I
Beispiel #3
0
    def moment_of_inertia(self, axis):

        assert self.is_perfect
        I = 0
        for isite in self:
            I += mass(isite.symbols[0]) * (sum(isite.position ** 2) - isite.position[axis] ** 2)
        return I
Beispiel #4
0
    def density(self):
        """
        Computes the density of the cell

        :rtype : float
        """
        return sum(_np.array(mass(self.symbols))) / self.volume
Beispiel #5
0
    def product_of_inertia(self, axis):

        assert self.is_perfect
        I = 0
        for isite in self:
            I += mass(isite.symbols[0]) * (np.prod(isite.position) /
                                           isite.position[axis])
        return I
Beispiel #6
0
    def moment_of_inertia(self, axis):

        assert self.is_perfect
        I = 0
        for isite in self:
            I += mass(isite.symbols[0]) * (sum(isite.position**2) -
                                           isite.position[axis]**2)
        return I
Beispiel #7
0
    def moment_of_inertia(self, axis):

        assert self.is_perfect
        mofi = 0
        for isite in self:
            mofi += mass(isite.symbols[0]) * (
                sum(np.array(isite.position)**2) - isite.position[axis]**2)
        return mofi
Beispiel #8
0
    def density(self):
        """
        Computes the density of the cell

        :rtype: float

        :return: float
        """
        return sum(np.array(mass(self.symbols))) / self.volume
Beispiel #9
0
    def steepest_descent(self, dt=1, tolerance=1E-3):
        forces = self.get_forces()
        while np.max(self.get_magnitude_forces()) > tolerance:
            for i in range(self.structure.natom):
                imass = mass(self.structure.symbols[i])
                self.structure.positions[i] += 0.5 * forces[i] / imass * dt ** 2

            forces = self.get_forces()
            maxforce = np.max(self.get_magnitude_forces())
            dt = max(100.0 / maxforce, 1.0)
            pcm_log.debug('Steepest Descent maxforce= %9.3E   density=%7.4f dt=%7.3f' % (maxforce,
                                                                                         self.structure.density, dt))
Beispiel #10
0
    def steepest_descent(self, dt=1, tolerance=1E-3):
        forces = self.get_forces()
        while np.max(self.get_magnitude_forces()) > tolerance:
            for i in range(self.structure.natom):
                imass = mass(self.structure.symbols[i])
                self.structure.positions[i] += 0.5 * forces[i] / imass * dt**2

            forces = self.get_forces()
            maxforce = np.max(self.get_magnitude_forces())
            dt = max(100.0 / maxforce, 1.0)
            pcm_log.debug(
                'Steepest Descent maxforce= %9.3E   density=%7.4f dt=%7.3f' %
                (maxforce, self.structure.density, dt))
Beispiel #11
0
    def center_mass(self, list_of_atoms=None):
        """
        Computes the center of mass (CM) of the XYZ object or
        a partial list of atoms. The default is to compute the
        CM of all the atoms in the object, if a list
        is enter only those in the list will be included for the CM
        Return the CM as a numpy array
        """
        if list_of_atoms is None:
            list_of_atoms = range(self.natom)

        total_mass = 0.0
        center_of_mass = np.zeros(3)
        if self.natom == 0:
            return center_of_mass

        atomicnumber = atomic_number(list(self.symbols))

        for i in range(self.natom):
            if i in list_of_atoms:
                total_mass = total_mass + mass(atomicnumber[i])
                center_of_mass = center_of_mass + mass(atomicnumber[i]) * self.positions[i]

        return center_of_mass / total_mass