Exemple #1
0
    def _run_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        dm = np.zeros((size_prim * 3, size_prim * 3),
                      dtype=self._dtype_complex)

        if fc.shape[0] == fc.shape[1]:  # full FC
            phonoc.dynamical_matrix(dm.view(dtype='double'), fc,
                                    np.array(q, dtype='double'), vectors,
                                    multiplicity, mass, self._s2p_map,
                                    self._p2s_map)
        else:
            phonoc.dynamical_matrix(
                dm.view(dtype='double'), fc, np.array(q, dtype='double'),
                vectors, multiplicity, mass, self._s2pp_map,
                np.arange(len(self._p2s_map), dtype='intc'))

        # Data of dm array are stored in memory by the C order of
        # (size_prim * 3, size_prim * 3, 2), where the last 2 means
        # real and imaginary parts. This code assumes this memory
        # order is that expected by numpy. Otherwise, numpy complex array
        # should be created as follows:
        #   dm_double = dm.view(dtype='double').reshape(size_prim * 3,
        #                                               size_prim * 3, 2)
        #   dm = dm_double[:, :, 0] + 1j * dm_double[:, :, 1]
        self._dynamical_matrix = dm
    def _set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        itemsize = self._force_constants.itemsize
        dm = np.zeros((size_prim * 3, size_prim * 3),
                      dtype=("c%d" % (itemsize * 2)))
        phonoc.dynamical_matrix(dm.view(dtype='double'), fc,
                                np.array(q, dtype='double'), vectors,
                                multiplicity, mass, self._s2p_map,
                                self._p2s_map)
        self._dynamical_matrix = dm
Exemple #3
0
    def _set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        size_super = fc.shape[0]
        dynamical_matrix_real = np.zeros((size_prim * 3, size_prim * 3),
                                         dtype='double')
        dynamical_matrix_image = np.zeros_like(dynamical_matrix_real)
        phonoc.dynamical_matrix(dynamical_matrix_real, dynamical_matrix_image,
                                fc, np.array(q, dtype='double'), vectors,
                                multiplicity, mass, self._s2p_map,
                                self._p2s_map)
        dm = dynamical_matrix_real + dynamical_matrix_image * 1j
        self._dynamical_matrix = (dm + dm.conj().transpose()) / 2
Exemple #4
0
    def _set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        itemsize = self._force_constants.itemsize
        dm = np.zeros((size_prim * 3, size_prim * 3),
                      dtype=("c%d" % (itemsize * 2)))
        phonoc.dynamical_matrix(dm.view(dtype='double'),
                                fc,
                                np.array(q, dtype='double'),
                                vectors,
                                multiplicity,
                                mass,
                                self._s2p_map,
                                self._p2s_map)
        self._dynamical_matrix = dm
Exemple #5
0
    def _set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        itemsize = self._force_constants.itemsize
        dm = np.zeros((size_prim * 3, size_prim * 3),
                      dtype=("c%d" % (itemsize * 2)))

        if fc.shape[0] == fc.shape[1]:  # full FC
            phonoc.dynamical_matrix(dm.view(dtype='double'),
                                    fc,
                                    np.array(q, dtype='double'),
                                    vectors,
                                    multiplicity,
                                    mass,
                                    self._s2p_map,
                                    self._p2s_map)
        else:
            phonoc.dynamical_matrix(
                dm.view(dtype='double'),
                fc,
                np.array(q, dtype='double'),
                vectors,
                multiplicity,
                mass,
                self._s2pp_map,
                np.arange(len(self._p2s_map), dtype='intc'))

        # Data of dm array are stored in memory by the C order of
        # (size_prim * 3, size_prim * 3, 2), where the last 2 means
        # real and imaginary parts. This code assumes this memory
        # order is that expected by numpy. Otherwise, numpy complex array
        # should be created as follows:
        #   dm_double = dm.view(dtype='double').reshape(size_prim * 3,
        #                                               size_prim * 3, 2)
        #   dm = dm_double[:, :, 0] + 1j * dm_double[:, :, 1]
        self._dynamical_matrix = dm
Exemple #6
0
    def set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self.force_constants
        vectors = self.smallest_vectors
        mass = self.pcell.get_masses()
        multiplicity = self.multiplicity
        size_prim = len( mass )
        size_super = fc.shape[0]
        dynamical_matrix_real = np.zeros((size_prim * 3, size_prim * 3), dtype=float)
        dynamical_matrix_image = np.zeros((size_prim * 3, size_prim * 3), dtype=float)
        phonoc.dynamical_matrix( dynamical_matrix_real,
                                 dynamical_matrix_image,
                                 fc,
                                 np.array(q),
                                 vectors,
                                 multiplicity,
                                 mass,
                                 np.array(self.s2p_map),
                                 np.array(self.p2s_map) )
        dm = dynamical_matrix_real + dynamical_matrix_image * 1j
        self.dynamical_matrix = (dm + dm.conj().transpose()) / 2
Exemple #7
0
    def _set_c_dynamical_matrix(self, q):
        import phonopy._phonopy as phonoc

        fc = self._force_constants
        vectors = self._smallest_vectors
        mass = self._pcell.get_masses()
        multiplicity = self._multiplicity
        size_prim = len(mass)
        size_super = fc.shape[0]
        dynamical_matrix_real = np.zeros((size_prim * 3, size_prim * 3),
                                         dtype='double')
        dynamical_matrix_image = np.zeros_like(dynamical_matrix_real)
        phonoc.dynamical_matrix(dynamical_matrix_real,
                                dynamical_matrix_image,
                                fc,
                                np.array(q, dtype='double'),
                                vectors,
                                multiplicity,
                                mass,
                                self._s2p_map,
                                self._p2s_map)
        dm = dynamical_matrix_real + dynamical_matrix_image * 1j
        self._dynamical_matrix = (dm + dm.conj().transpose()) / 2