def get_band_structure(self, band_paths: list, labels: list = None, npoints: int = 51, with_eigenvectors: bool = False, use_reciprocal_lattice: bool = True): """ Get BandStructure class object. Args: band_paths (list): Band paths. labels (list): Band labels. npoints (int): The number of sampling points. with_eigenvectors (bool): If True, calculte eigenvectors. """ if use_reciprocal_lattice: rec_lattice = self._reciprocal_lattice else: rec_lattice = None qpoints, connections = get_band_qpoints_and_path_connections( band_paths=band_paths, npoints=npoints, rec_lattice=rec_lattice) band_structure = BandStructure( paths=qpoints, dynamical_matrix=self._phonon.get_dynamical_matrix(), with_eigenvectors=with_eigenvectors, is_band_connection=False, group_velocity=None, path_connections=connections, labels=labels, is_legacy_plot=False) return band_structure
def set_band_structure(self, bands, is_eigenvectors=False, is_band_connection=False): self._set_dynamical_matrix() self._band_structure = BandStructure( bands, self._dynamical_matrix, is_eigenvectors=is_eigenvectors, is_band_connection=is_band_connection, group_velocity=self._group_velocity, factor=self._factor)
def get_bandstructure(self): phonopy_obj = self.phonopy_obj frequency_unit_factor = VaspToTHz is_eigenvectors = False unit_cell = phonopy_obj.unitcell.get_cell() sym_tol = phonopy_obj.symmetry.tolerance if self.band_conf is not None: parameters = read_kpath(self.band_conf) else: parameters = generate_kpath_ase(unit_cell, sym_tol) if not parameters: return None, None, None # Distances calculated in phonopy.band_structure.BandStructure object # are based on absolute positions of q-points in reciprocal space # as calculated by using the cell which is handed over during instantiation. # Fooling that object by handing over a "unit cell" diag(1,1,1) instead clashes # with calculation of non-analytical terms. # Hence generate appropriate distances and special k-points list based on fractional # coordinates in reciprocal space (to keep backwards compatibility with previous # FHI-aims phonon implementation). bands = [] bands_distances = [] distance = 0.0 bands_special_points = [distance] bands_labels = [] label = parameters[0]["startname"] for b in parameters: kstart = np.array(b["kstart"]) kend = np.array(b["kend"]) npoints = b["npoints"] dk = (kend - kstart) / (npoints - 1) bands.append([(kstart + dk * n) for n in range(npoints)]) dk_length = np.linalg.norm(dk) for n in range(npoints): bands_distances.append(distance + dk_length * n) distance += dk_length * (npoints - 1) bands_special_points.append(distance) label = [b["startname"], b["endname"]] bands_labels.append(label) bs_obj = BandStructure(bands, phonopy_obj.dynamical_matrix, with_eigenvectors=is_eigenvectors, factor=frequency_unit_factor) freqs = bs_obj.get_frequencies() return np.array(freqs), np.array(bands), np.array(bands_labels)
def set_band_structure(self, bands, is_eigenvectors=False, is_band_connection=False): if self._dynamical_matrix is None: print("Warning: Dynamical matrix has not yet built.") self._band_structure = None return False self._band_structure = BandStructure( bands, self._dynamical_matrix, is_eigenvectors=is_eigenvectors, is_band_connection=is_band_connection, group_velocity=self._group_velocity, factor=self._factor) return True
band = [] for i in range(51): band.append(q_start + (q_end - q_start) / 50 * i) bands.append(band) dir_labels = [r'$\Gamma$', '$X$', '$W$', '$X$', '$K$', r'$\Gamma$', '$L$'] # plot the band structure clf() phonon.set_band_structure(bands) phonon.plot_band_structure(dir_labels) ylim(0, 20.) # save results to file band.yaml bs = BandStructure(bands, phonon.dynamical_matrix, phonon.primitive, factor=VaspToTHz) if write_yaml: bs.write_yaml() # add vertical lines to plot for p in bs.special_point: axvline(p, color='k') # Example showing how to load previously saved results if read_yaml: special_points, distances, frequencies = band_plot_from_file( gca(), 'band.yaml') # set x axis labels