Beispiel #1
0
    def init_dynamical_matrix(
        self,
        fc2,
        supercell,
        primitive,
        nac_params=None,
        decimals=None,
    ):
        """Prepare for phonon calculation on grid.

        solve_dynamical_matrices : bool
           When False, phonon calculation will be postponed.

        """
        self._nac_params = nac_params
        self._dm = get_dynamical_matrix(
            fc2,
            supercell,
            primitive,
            nac_params=nac_params,
            frequency_scale_factor=self._frequency_scale_factor,
            decimals=decimals,
            symprec=self._symprec,
        )
        self._allocate_phonon()
Beispiel #2
0
    def init_dynamical_matrix(self,
                              fc2,
                              supercell,
                              primitive,
                              nac_params=None,
                              solve_dynamical_matrices=True,
                              decimals=None,
                              verbose=False):
        self._nac_params = nac_params
        self._dm = get_dynamical_matrix(
            fc2,
            supercell,
            primitive,
            nac_params=nac_params,
            frequency_scale_factor=self._frequency_scale_factor,
            decimals=decimals,
            symprec=self._symprec)

        if solve_dynamical_matrices:
            self.run_phonon_solver(verbose=verbose)
        else:
            self.run_phonon_solver(np.array([0], dtype='uintp'),
                                   verbose=verbose)

        if (self._grid_address[0] == 0).all():
            if np.sum(self._frequencies[0] < self._cutoff_frequency) < 3:
                for i, f in enumerate(self._frequencies[0, :3]):
                    if not (f < self._cutoff_frequency):
                        self._frequencies[0, i] = 0
                        print("=" * 26 + " Warning " + "=" * 26)
                        print(" Phonon frequency of band index %d at Gamma "
                              "is calculated to be %f." % (i + 1, f))
                        print(" But this frequency is forced to be zero.")
                        print("=" * 61)
Beispiel #3
0
 def set_dynamical_matrix(self,
                          fc2,
                          supercell,
                          primitive,
                          nac_params=None,
                          frequency_scale_factor=None,
                          decimals=None):
     self._dm = get_dynamical_matrix(
         fc2,
         supercell,
         primitive,
         nac_params=nac_params,
         frequency_scale_factor=frequency_scale_factor,
         decimals=decimals,
         symprec=self._symprec)
     self.set_phonons(np.arange(len(self._grid_address), dtype='intc'))
     if (self._grid_address[0] == 0).all():
         if np.sum(self._frequencies[0] < self._cutoff_frequency) < 3:
             for i, f in enumerate(self._frequencies[0, :3]):
                 if not (f < self._cutoff_frequency):
                     self._frequencies[0, i] = 0
                     print("=" * 26 + " Warning " + "=" * 26)
                     print(" Phonon frequency of band index %d at Gamma "
                           "is calculated to be %f." % (i + 1, f))
                     print(" But this frequency is forced to be zero.")
                     print("=" * 61)
Beispiel #4
0
 def _set_dynamical_matrix(self):
     self._dm = get_dynamical_matrix(
         self._fc2,
         self._supercell,
         self._primitive,
         nac_params=self._nac_params,
         frequency_scale_factor=self._frequency_scale_factor,
         symprec=self._symprec)
Beispiel #5
0
 def _init_dynamical_matrix(self):
     self._dm = get_dynamical_matrix(
         self._fc2,
         self._supercell,
         self._primitive,
         nac_params=self._nac_params,
         frequency_scale_factor=self._frequency_scale_factor,
         symprec=self._symprec)
Beispiel #6
0
    def __init__(
        self,
        fc2,
        fc3,
        supercell,
        primitive,
        nac_params=None,
        nac_q_direction=None,
        ion_clamped=False,
        factor=VaspToTHz,
        symprec=1e-5,
    ):
        """Init method."""
        self._fc2 = fc2
        self._fc3 = fc3
        self._scell = supercell
        self._pcell = primitive
        self._ion_clamped = ion_clamped
        self._factor = factor
        self._symprec = symprec
        self._dm = get_dynamical_matrix(
            self._fc2,
            self._scell,
            self._pcell,
            nac_params=nac_params,
            symprec=self._symprec,
        )
        self._nac_q_direction = nac_q_direction

        svecs, multi = self._pcell.get_smallest_vectors()
        if self._pcell.store_dense_svecs:
            self._svecs = svecs
            self._multi = multi
        else:
            self._svecs, self._multi = sparse_to_dense_svecs(svecs, multi)

        if self._ion_clamped:
            num_atom_prim = self._pcell.get_number_of_atoms()
            self._X = np.zeros((num_atom_prim, 3, 3, 3), dtype=float)
        else:
            self._X = self._get_X()
        self._dPhidu = self._get_dPhidu()

        self._gruneisen_parameters = None
        self._frequencies = None
        self._qpoints = None
        self._mesh = None
        self._band_paths = None
        self._band_distances = None
        self._run_mode = None
        self._weights = None
Beispiel #7
0
 def set_dynamical_matrix(self,
                          fc2,
                          supercell,
                          primitive,
                          nac_params=None,
                          frequency_scale_factor=None,
                          decimals=None):
     self._dm = get_dynamical_matrix(
         fc2,
         supercell,
         primitive,
         nac_params=nac_params,
         frequency_scale_factor=frequency_scale_factor,
         decimals=decimals,
         symprec=self._symprec)
Beispiel #8
0
 def set_dynamical_matrix(self,
                          fc2,
                          supercell,
                          primitive,
                          nac_params=None,
                          frequency_scale_factor=None,
                          decimals=None):
     self._dm = get_dynamical_matrix(
         fc2,
         supercell,
         primitive,
         nac_params=nac_params,
         frequency_scale_factor=frequency_scale_factor,
         decimals=decimals,
         symprec=self._symprec)
Beispiel #9
0
 def init_dynamical_matrix(
     self,
     fc2,
     supercell,
     primitive,
     nac_params=None,
     frequency_scale_factor=None,
     decimals=None,
 ):
     """Initialize dynamical matrix."""
     self._primitive = primitive
     self._dm = get_dynamical_matrix(
         fc2,
         supercell,
         primitive,
         nac_params=nac_params,
         frequency_scale_factor=frequency_scale_factor,
         decimals=decimals,
         symprec=self._symprec,
     )
    def __init__(self,
                 supercell,
                 primitive,
                 force_constants,
                 dist_func=None,
                 cutoff_frequency=None,
                 factor=VaspToTHz):
        """

        Parameters
        ----------
        supercell : Supercell
            Supercell.
        primitive : Primitive
            Primitive cell
        force_constants : array_like
            Force constants matrix. See the details at docstring of
            DynamialMatrix.
        dist_func : str or None
            Harmonic oscillator distribution function either by 'quantum'
            or 'classical'. The starndard deviation of normal distribution
            is determined following the choice. Default is None, corresponding
            to 'quantum'.
        cutoff_frequency : float
            Lowest phonon frequency below which frequency the phonon mode
            is treated specially. See _get_sigma. Default is None, which
            means 0.01.
        factor : float
            Phonon frequency unit conversion factor to THz

        """

        if cutoff_frequency is None or cutoff_frequency < 0:
            self._cutoff_frequency = 0.01
        else:
            self._cutoff_frequency = cutoff_frequency
        self._factor = factor
        self._T = None
        self.u = None

        if dist_func is None or dist_func == 'quantum':
            self._dist_func = 'quantum'
        elif dist_func == 'classical':
            self._dist_func = 'classical'
        else:
            raise RuntimeError("Either 'quantum' or 'classical' is required.")

        self._unit_conversion = (Hbar * EV / AMU / THz / (2 * np.pi) /
                                 Angstrom**2)
        self._unit_conversion_classical = (Kb * EV / AMU / (THz *
                                                            (2 * np.pi))**2 /
                                           Angstrom**2)

        # Dynamical matrix without NAC because of commensurate points only
        self._dynmat = get_dynamical_matrix(force_constants, supercell,
                                            primitive)

        self._setup_sampling_qpoints(supercell.cell, primitive.cell)

        s2p = primitive.s2p_map
        p2p = primitive.p2p_map
        self._s2pp = [p2p[i] for i in s2p]

        self._eigvals_ii = []
        self._eigvecs_ii = []
        self._phase_ii = []
        self._eigvals_ij = []
        self._eigvecs_ij = []
        self._phase_ij = []
        self._prepare()

        # This is set when running run_d2f.
        # The aim is to produce force constants from modified frequencies.
        self._force_constants = None
    def __init__(self,
                 supercell,
                 primitive,
                 force_constants,
                 cutoff_frequency=None,
                 factor=VaspToTHz):
        """

        Parameters
        ----------
        supercell : Supercell
            Supercell.
        primitive : Primitive
            Primitive cell
        force_constants : array_like
            Force constants matrix. See the details at docstring of
            DynamialMatrix.
        cutoff_frequency : float
            Lowest phonon frequency below which frequency the phonon mode
            is treated specially. See _get_sigma. Default is None, which
            means 0.01.
        factor : float
            Phonon frequency unit conversion factor to THz

        """

        # Dynamical matrix without NAC because of commensurate points only
        self._dynmat = get_dynamical_matrix(force_constants, supercell,
                                            primitive)
        if cutoff_frequency is None or cutoff_frequency < 0:
            self._cutoff_frequency = 0.01
        else:
            self._cutoff_frequency = cutoff_frequency
        self._factor = factor
        self._T = None
        self.u = None

        self._unit_conversion = (Hbar * EV / AMU / THz / (2 * np.pi) /
                                 Angstrom**2)

        slat = supercell.cell
        self._rec_lat = np.linalg.inv(primitive.cell)
        smat = np.rint(np.dot(slat, self._rec_lat).T).astype(int)
        self._comm_points = get_commensurate_points_in_integers(smat)
        self._ii, self._ij = self._categorize_points()
        assert len(self._ii) + len(self._ij) * 2 == len(self._comm_points)

        s2p = primitive.s2p_map
        p2p = primitive.p2p_map
        self._s2pp = [p2p[i] for i in s2p]

        self._eigvals_ii = []
        self._eigvecs_ii = []
        self._phase_ii = []
        self._eigvals_ij = []
        self._eigvecs_ij = []
        self._phase_ij = []
        self._prepare()

        # This is set when running run_d2f.
        # The aim is to produce force constants from modified frequencies.
        self._force_constants = None