def __init__(self, dynamical_matrix, cutoff_frequency=None, factor=VaspToTHz): """ Parameters ---------- supercell_matrix : array_like Supercell matrix. shape=(3, 3) dtype='intc' cutoff_frequency : float, optional Above this cutoff frequency in THz, it is decided if each phonon mode is included or not. Default is None but effectively 0.01 THz. factor : float, optional Unit conversion factor of phonon frequency to THz. Default is that for the VASP unit system. """ self._dynmat = dynamical_matrix 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 = self._dynmat.supercell.get_cell() self._rec_lat = np.linalg.inv(self._dynmat.primitive.get_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 = self._dynmat.primitive.s2p_map p2p = self._dynmat.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()
def __init__(self, dynamical_matrix, cutoff_frequency=None, factor=VaspToTHz): """ Parameters ---------- supercell_matrix : array_like Supercell matrix. shape=(3, 3) dtype='intc' cutoff_frequency : float, optional Above this cutoff frequency in THz, it is decided if each phonon mode is included or not. Default is None but effectively 0.01 THz. factor : float, optional Unit conversion factor of phonon frequency to THz. Default is that for the VASP unit system. """ self._dynmat = dynamical_matrix 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 = self._dynmat.supercell.get_cell() self._rec_lat = np.linalg.inv(self._dynmat.primitive.get_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 = self._dynmat.primitive.s2p_map p2p = self._dynmat.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()
def test_get_commensurate_points_in_integers(self): comm_points = get_commensurate_points_in_integers(self._smat) comm_points = comm_points / np.linalg.det(self._smat) all_indices = [] for cpt in comm_points: diff = self._comm_points - cpt diff -= np.rint(diff) dist2 = (diff**2).sum(axis=1) indices = np.where(dist2 < 1e-5)[0] self.assertTrue(len(indices) == 1) all_indices.append(indices[0]) all_indices.sort() np.testing.assert_array_equal(all_indices, np.arange(len(comm_points)))
def __init__(self, dynamical_matrix, cutoff_frequency=None, factor=VaspToTHz): """ Parameters ---------- dynamical_matrix : DynamicalMatrix Dynamical matrix class instance. cutoff_frequency : float Lowest phonon frequency below which frequency the phonon mode is treated specially. factor : float Phonon frequency unit conversion factor """ self._dynmat = dynamical_matrix 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 = self._dynmat.supercell.get_cell() self._rec_lat = np.linalg.inv(self._dynmat.primitive.get_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 = self._dynmat.primitive.s2p_map p2p = self._dynmat.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()
def test_get_commensurate_points_in_integers(): """Test for getting commensurate points represented by integers.""" comm_points_ref, smat = _get_commensurate_points() comm_points = get_commensurate_points_in_integers(smat) comm_points = comm_points / np.linalg.det(smat) all_indices = [] for cpt in comm_points: diff = comm_points_ref - cpt diff -= np.rint(diff) dist2 = (diff**2).sum(axis=1) indices = np.where(dist2 < 1e-5)[0] assert len(indices) == 1 all_indices.append(indices[0]) all_indices.sort() np.testing.assert_array_equal(all_indices, np.arange(len(comm_points)))
def _setup_sampling_qpoints(self, slat, plat): smat = np.rint(np.dot(slat, np.linalg.inv(plat)).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)
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