def run_tetrahedron_method_dos(mesh, frequency_points, frequencies, grid_address, grid_mapping_table, relative_grid_address, coef=None): # for each grid point try: import phonopy._phonopy as phonoc except ImportError: import sys print("Phonopy C-extension has to be built properly.") sys.exit(1) if coef is None: _coef = np.ones((frequencies.shape[0], 1, frequencies.shape[1]), dtype='double') else: _coef = np.array(coef, dtype='double', order='C') arr_shape = frequencies.shape + (len(frequency_points), _coef.shape[1]) dos = np.zeros(arr_shape, dtype=np.float64) phonoc.tetrahedron_method_dos(dos, mesh, frequency_points, frequencies, _coef, grid_address, grid_mapping_table, relative_grid_address) if coef is None: return dos[:, :, :, 0].sum(axis=0).sum(axis=0) / np.prod(mesh) else: return dos.sum(axis=0).sum(axis=0) / np.prod(mesh)
def run_tetrahedron_method_dos(mesh, frequency_points, frequencies, grid_address, grid_mapping_table, relative_grid_address, coef=None): # for each grid point try: import phonopy._phonopy as phonoc except ImportError: import sys print("Phonopy C-extension has to be built properly.") sys.exit(1) if coef is None: _coef = np.ones((frequencies.shape[0], 1, frequencies.shape[1]), dtype='double') else: _coef = np.array(coef, dtype='double', order='C') arr_shape = frequencies.shape + (len(frequency_points), _coef.shape[1]) dos = np.zeros(arr_shape, dtype='double') phonoc.tetrahedron_method_dos(dos, mesh, frequency_points, frequencies, _coef, grid_address, grid_mapping_table, relative_grid_address) if coef is None: return dos[:,:,:,0].sum(axis=0).sum(axis=0) / np.prod(mesh) else: return dos.sum(axis=0).sum(axis=0) / np.prod(mesh)
def run_tetrahedron_method_dos( mesh, frequency_points, frequencies, grid_address, grid_mapping_table, relative_grid_address, coef=None, ): """Return (P)DOS calculated by tetrahedron method in C.""" try: import phonopy._phonopy as phonoc except ImportError: import sys print("Phonopy C-extension has to be built properly.") sys.exit(1) if coef is None: _coef = np.ones((frequencies.shape[0], 1, frequencies.shape[1]), dtype="double") else: _coef = np.array(coef, dtype="double", order="C") arr_shape = frequencies.shape + (len(frequency_points), _coef.shape[1]) dos = np.zeros(arr_shape, dtype="double") phonoc.tetrahedron_method_dos( dos, np.array(mesh, dtype="int_"), frequency_points, frequencies, _coef, np.array(grid_address, dtype="int_", order="C"), np.array(grid_mapping_table, dtype="int_", order="C"), relative_grid_address, ) if coef is None: return dos[:, :, :, 0].sum(axis=0).sum(axis=0) / np.prod(mesh) else: return dos.sum(axis=0).sum(axis=0) / np.prod(mesh)