def test_Amm2(): """Test of DOS calculation using TetrahedronMesh for Amm2 crystal.""" data = np.loadtxt(StringIO(dos_str)) phonon = _get_phonon("Amm2", [3, 2, 2], [[1, 0, 0], [0, 0.5, -0.5], [0, 0.5, 0.5]]) mesh = [11, 11, 11] primitive = phonon.primitive phonon.run_mesh([11, 11, 11]) weights = phonon.mesh.weights frequencies = phonon.mesh.frequencies grid_address = phonon.mesh.grid_address ir_grid_points = phonon.mesh.ir_grid_points grid_mapping_table = phonon.mesh.grid_mapping_table thm = TetrahedronMesh( primitive, frequencies, mesh, np.array(grid_address, dtype="int_"), np.array(grid_mapping_table, dtype="int_"), ir_grid_points, ) thm.set(value="I", division_number=40) freq_points = thm.get_frequency_points() dos = np.zeros_like(freq_points) for i, iw in enumerate(thm): dos += np.sum(iw * weights[i], axis=1) dos_comp = np.transpose([freq_points, dos]).reshape(10, 8) np.testing.assert_allclose(dos_comp, data, atol=1e-5)
def test_Amm2(self): data = np.loadtxt(StringIO(dos_str)) phonon = self._get_phonon("Amm2", [3, 2, 2], [[1, 0, 0], [0, 0.5, -0.5], [0, 0.5, 0.5]]) mesh = [11, 11, 11] primitive = phonon.get_primitive() phonon.run_mesh([11, 11, 11]) qpoints = phonon.mesh.qpoints weights = phonon.mesh.weights frequencies = phonon.mesh.frequencies grid_address = phonon.mesh.grid_address ir_grid_points = phonon.mesh.ir_grid_points grid_mapping_table = phonon.mesh.grid_mapping_table thm = TetrahedronMesh(primitive, frequencies, mesh, grid_address, grid_mapping_table, ir_grid_points) thm.set(value='I', division_number=40) freq_points = thm.get_frequency_points() dos = np.zeros_like(freq_points) for i, iw in enumerate(thm): dos += np.sum(iw * weights[i], axis=1) dos_comp = np.transpose([freq_points, dos]).reshape(10, 8) self.assertTrue(np.abs(dos_comp - data).all() < 1e-5)
def test_Amm2(self): data = np.loadtxt(StringIO(dos_str)) phonon = self._get_phonon("Amm2", [3, 2, 2], [[1, 0, 0], [0, 0.5, -0.5], [0, 0.5, 0.5]]) mesh = [11, 11, 11] primitive = phonon.get_primitive() phonon.set_mesh([11, 11, 11]) qpoints, weights, frequencies, _ = phonon.get_mesh() (grid_address, ir_grid_points, grid_mapping_table) = phonon.get_mesh_grid_info() thm = TetrahedronMesh(primitive, frequencies, mesh, grid_address, grid_mapping_table, ir_grid_points) thm.set(value='I', division_number=40) freq_points = thm.get_frequency_points() dos = np.zeros_like(freq_points) for i, iw in enumerate(thm): dos += np.sum(iw * weights[i], axis=1) dos_comp = np.transpose([freq_points, dos]).reshape(10, 8) self.assertTrue(np.abs(dos_comp - data).all() < 1e-5)
def __init__(self, mesh_object, sigma=None, use_tetrahedron_method=False): self._mesh_object = mesh_object self._frequencies = mesh_object.frequencies self._weights = mesh_object.weights if use_tetrahedron_method and sigma is None: self._tetrahedron_mesh = TetrahedronMesh( mesh_object.dynamical_matrix.primitive, self._frequencies, mesh_object.mesh_numbers, mesh_object.grid_address, mesh_object.grid_mapping_table, mesh_object.ir_grid_points) else: self._tetrahedron_mesh = None self._frequency_points = None self._sigma = sigma self.set_draw_area() self.set_smearing_function('Normal')
def __init__(self, mesh_object, sigma=None, tetrahedron_method=False): self._mesh_object = mesh_object self._frequencies = mesh_object.get_frequencies() self._weights = mesh_object.get_weights() if tetrahedron_method: self._tetrahedron_mesh = TetrahedronMesh( mesh_object.get_dynamical_matrix().get_primitive(), self._frequencies, mesh_object.get_mesh_numbers(), mesh_object.get_grid_address(), mesh_object.get_grid_mapping_table()) else: self._tetrahedron_mesh = None self._frequency_points = None self._sigma = sigma self.set_draw_area() self.set_smearing_function('Normal')
def __init__(self, mesh_object: Mesh, sigma=None, use_tetrahedron_method=False): """Init method.""" self._mesh_object = mesh_object self._frequencies = mesh_object.frequencies self._weights = mesh_object.weights self._tetrahedron_mesh = None if use_tetrahedron_method and sigma is None: self._tetrahedron_mesh = TetrahedronMesh( mesh_object.dynamical_matrix.primitive, self._frequencies, mesh_object.mesh_numbers, np.array(mesh_object.grid_address, dtype="int_"), np.array(mesh_object.grid_mapping_table, dtype="int_"), mesh_object.ir_grid_points, ) self._frequency_points = None self._sigma = sigma self.set_draw_area() self.set_smearing_function("Normal")
def __init__(self, mesh_object, sigma=None, tetrahedron_method=False): self._frequencies = mesh_object.get_frequencies() self._weights = mesh_object.get_weights() if tetrahedron_method: self._tetrahedron_mesh = TetrahedronMesh( mesh_object.get_dynamical_matrix().get_primitive(), self._frequencies, mesh_object.get_mesh_numbers(), mesh_object.get_grid_address(), mesh_object.get_grid_mapping_table()) else: self._tetrahedron_mesh = None self._omega_pitch = None if sigma: self._sigma = sigma else: self._sigma = (self._frequencies.max() - self._frequencies.min()) / 100 self.set_draw_area() # Default smearing self.set_smearing_function('Normal')
def __init__(self, mode_kappa, cell, frequencies, mesh, grid_address, grid_mapping_table, ir_grid_points, grid_order=None, num_sampling_points=100): self._mode_kappa = mode_kappa self._tetrahedron_mesh = TetrahedronMesh(cell, frequencies, mesh, grid_address, grid_mapping_table, ir_grid_points) min_freq = min(frequencies.ravel()) max_freq = max(frequencies.ravel()) + epsilon self._frequency_points = np.linspace(min_freq, max_freq, num_sampling_points) self._kdos = np.zeros( (len(mode_kappa), len(self._frequency_points), 2, 6), dtype='double') self._run_tetrahedron_method()
from phonopy.structure.symmetry import Symmetry from phonopy.interface.vasp import read_vasp from phonopy.file_IO import parse_FORCE_SETS, parse_BORN from phonopy.structure.spglib import get_stabilized_reciprocal_mesh from phonopy.structure.tetrahedron_method import TetrahedronMethod from phonopy.phonon.tetrahedron_mesh import TetrahedronMesh cell = read_vasp(sys.argv[1]) phonon = Phonopy(cell, [[2, 0, 0], [0, 2, 0], [0, 0, 2]], is_auto_displacements=False) force_sets = parse_FORCE_SETS() phonon.set_force_sets(force_sets) phonon.set_post_process([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]) primitive = phonon.get_primitive() born = parse_BORN(primitive) phonon.set_nac_params(born) symmetry = phonon.get_primitive_symmetry() mesh = [20, 20, 20] # phonon.set_mesh(mesh) # phonon.set_total_DOS(sigma=0.1) # phonon.plot_total_DOS().show() rotations = symmetry.get_pointgroup_operations() thm = TetrahedronMesh(phonon.get_dynamical_matrix(), mesh, rotations, is_gamma_center=True) thm.run_dos() for f, iw in zip(thm.get_frequency_points(), thm.get_integration_weights()): print f, iw