Esempio n. 1
0
    def _run_c(self, q, q_direction=None):
        import phonopy._phonopy as phonoc
        num_patom = len(self._p2s_map)
        ddm_real = np.zeros((3, num_patom * 3, num_patom * 3), dtype='double')
        ddm_imag = np.zeros((3, num_patom * 3, num_patom * 3), dtype='double')
        mass = self._pcell.get_masses()
        fc = self._force_constants
        vectors = self._smallest_vectors
        multiplicity = self._multiplicity
        if self._dynmat.is_nac():
            born = self._dynmat.get_born_effective_charges()
            dielectric = self._dynmat.get_dielectric_constant()
            nac_factor = self._dynmat.get_nac_factor()
            if q_direction is None:
                q_dir = None
            else:
                q_dir = np.array(q_direction, dtype='double', order='C')
        else:
            born = None
            dielectric = None
            nac_factor = 0
            q_dir = None

        phonoc.derivative_dynmat(
            ddm_real, ddm_imag, fc, np.array(q, dtype='double'),
            np.array(self._pcell.get_cell().T, dtype='double',
                     order='C'), vectors, multiplicity, mass, self._s2p_map,
            self._p2s_map, nac_factor, born, dielectric, q_dir)
        self._ddm = np.array([
            ddm_real[i] + ddm_real[i].T + 1j * (ddm_imag[i] - ddm_imag[i].T)
            for i in range(3)
        ]) / 2
Esempio n. 2
0
    def _run_c(self, q, q_direction=None):
        import phonopy._phonopy as phonoc

        num_patom = len(self._p2s_map)

        fc = self._force_constants
        ddm = np.zeros(
            (3, num_patom * 3, num_patom * 3),
            dtype=("c%d" % (np.dtype("double").itemsize * 2)),
        )
        if self._dynmat.is_nac():
            born = self._dynmat.born
            dielectric = self._dynmat.dielectric_constant
            nac_factor = self._dynmat.nac_factor
            if q_direction is None:
                q_dir = None
            else:
                q_dir = np.array(q_direction, dtype="double", order="C")
        else:
            born = None
            dielectric = None
            nac_factor = 0
            q_dir = None

        if fc.shape[0] == fc.shape[1]:  # full fc
            phonoc.derivative_dynmat(
                ddm.view(dtype="double"),
                fc,
                np.array(q, dtype="double"),
                np.array(self._pcell.cell.T, dtype="double", order="C"),
                self._svecs,
                self._multi,
                self._pcell.masses,
                self._s2p_map,
                self._p2s_map,
                nac_factor,
                born,
                dielectric,
                q_dir,
            )
        else:
            phonoc.derivative_dynmat(
                ddm.view(dtype="double"),
                fc,
                np.array(q, dtype="double"),
                np.array(self._pcell.cell.T, dtype="double", order="C"),
                self._svecs,
                self._multi,
                self._pcell.masses,
                self._s2pp_map,
                np.arange(len(self._p2s_map), dtype="int_"),
                nac_factor,
                born,
                dielectric,
                q_dir,
            )

        self._ddm = ddm
Esempio n. 3
0
    def _run_c(self, q, q_direction=None):
        import phonopy._phonopy as phonoc
        num_patom = len(self._p2s_map)

        mass = self._pcell.get_masses()
        fc = self._force_constants
        itemsize = self._force_constants.itemsize
        ddm = np.zeros((3, num_patom * 3, num_patom * 3),
                       dtype=("c%d" % (itemsize * 2)))
        vectors = self._smallest_vectors
        multiplicity = self._multiplicity
        if self._dynmat.is_nac():
            born = self._dynmat.get_born_effective_charges()
            dielectric = self._dynmat.get_dielectric_constant()
            nac_factor = self._dynmat.get_nac_factor()
            if q_direction is None:
                q_dir = None
            else:
                q_dir = np.array(q_direction, dtype='double', order='C')
        else:
            born = None
            dielectric = None
            nac_factor = 0
            q_dir = None

        if fc.shape[0] == fc.shape[1]: # full fc
            phonoc.derivative_dynmat(ddm.view(dtype='double'),
                                     fc,
                                     np.array(q, dtype='double'),
                                     np.array(self._pcell.get_cell().T,
                                              dtype='double', order='C'),
                                     vectors,
                                     multiplicity,
                                     mass,
                                     self._s2p_map,
                                     self._p2s_map,
                                     nac_factor,
                                     born,
                                     dielectric,
                                     q_dir)
        else:
            phonoc.derivative_dynmat(ddm.view(dtype='double'),
                                     fc,
                                     np.array(q, dtype='double'),
                                     np.array(self._pcell.get_cell().T,
                                              dtype='double', order='C'),
                                     vectors,
                                     multiplicity,
                                     mass,
                                     self._s2pp_map,
                                     np.arange(len(self._p2s_map),
                                               dtype='intc'),
                                     nac_factor,
                                     born,
                                     dielectric,
                                     q_dir)

        self._ddm = ddm
Esempio n. 4
0
    def _run_c(self, q, q_direction=None):
        import phonopy._phonopy as phonoc
        num_patom = len(self._p2s_map)
        ddm_real = np.zeros((3, num_patom * 3, num_patom * 3), dtype='double')
        ddm_imag = np.zeros((3, num_patom * 3, num_patom * 3), dtype='double')
        mass = self._pcell.get_masses()
        fc = self._force_constants
        vectors = self._smallest_vectors
        multiplicity = self._multiplicity
        if self._dynmat.is_nac():
            born = self._dynmat.get_born_effective_charges()
            dielectric = self._dynmat.get_dielectric_constant()
            nac_factor = self._dynmat.get_nac_factor()
            if q_direction is None:
                q_dir = None
            else:
                q_dir = np.array(q_direction, dtype='double', order='C')
        else:
            born = None
            dielectric = None
            nac_factor = 0
            q_dir = None

        phonoc.derivative_dynmat(ddm_real,
                                 ddm_imag,
                                 fc,
                                 np.array(q, dtype='double'),
                                 np.array(self._pcell.get_cell().T,
                                          dtype='double', order='C'),
                                 vectors,
                                 multiplicity,
                                 mass,
                                 self._s2p_map,
                                 self._p2s_map,
                                 nac_factor,
                                 born,
                                 dielectric,
                                 q_dir)
        self._ddm = np.array([ddm_real[i] + ddm_real[i].T +
                              1j * (ddm_imag[i] - ddm_imag[i].T)
                              for i in range(3)]) / 2