def _set_triplets_integration_weights_py(g, interaction, frequency_points): reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() triplets_at_q = interaction.get_triplets_at_q()[0] unique_vertices = thm.get_unique_tetrahedra_vertices() tetrahedra_vertices = get_tetrahedra_vertices(thm.get_tetrahedra(), mesh, triplets_at_q, grid_address, bz_map) interaction.set_phonon(np.unique(tetrahedra_vertices)) frequencies = interaction.get_phonons()[0] num_band = frequencies.shape[1] for i, vertices in enumerate(tetrahedra_vertices): for j, k in list(np.ndindex((num_band, num_band))): f1_v = frequencies[vertices[0], j] f2_v = frequencies[vertices[1], k] thm.set_tetrahedra_omegas(f1_v + f2_v) thm.run(frequency_points) g0 = thm.get_integration_weight() g[0, i, :, j, k] = g0 thm.set_tetrahedra_omegas(-f1_v + f2_v) thm.run(frequency_points) g1 = thm.get_integration_weight() thm.set_tetrahedra_omegas(f1_v - f2_v) thm.run(frequency_points) g2 = thm.get_integration_weight() g[1, i, :, j, k] = g1 - g2 if len(g) == 3: g[2, i, :, j, k] = g0 + g1 + g2
def _set_triplets_integration_weights_py(g, interaction, frequency_points): reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() triplets_at_q = interaction.get_triplets_at_q()[0] unique_vertices = thm.get_unique_tetrahedra_vertices() tetrahedra_vertices = get_tetrahedra_vertices( thm.get_tetrahedra(), mesh, triplets_at_q, grid_address, bz_map) interaction.set_phonon(np.unique(tetrahedra_vertices)) frequencies = interaction.get_phonons()[0] num_band = frequencies.shape[1] for i, vertices in enumerate(tetrahedra_vertices): for j, k in list(np.ndindex((num_band, num_band))): f1_v = frequencies[vertices[0], j] f2_v = frequencies[vertices[1], k] thm.set_tetrahedra_omegas(f1_v + f2_v) thm.run(frequency_points) g0 = thm.get_integration_weight() g[0, i, :, j, k] = g0 thm.set_tetrahedra_omegas(-f1_v + f2_v) thm.run(frequency_points) g1 = thm.get_integration_weight() thm.set_tetrahedra_omegas(f1_v - f2_v) thm.run(frequency_points) g2 = thm.get_integration_weight() g[1, i, :, j, k] = g1 - g2 if len(g) == 3: g[2, i, :, j, k] = g0 + g1 + g2
def _set_triplets_integration_weights_c(g, interaction, frequency_points, neighboring_phonons=True): import anharmonic._phono3py as phono3c reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() triplets_at_q = interaction.get_triplets_at_q()[0] if neighboring_phonons: unique_vertices = thm.get_unique_tetrahedra_vertices() for i, j in zip((1, 2), (1, -1)): neighboring_grid_points = np.zeros(len(unique_vertices) * len(triplets_at_q), dtype='intc') phono3c.neighboring_grid_points(neighboring_grid_points, triplets_at_q[:, i].flatten(), j * unique_vertices, mesh, grid_address, bz_map) interaction.set_phonon(np.unique(neighboring_grid_points)) phono3c.triplets_integration_weights(g, frequency_points, thm.get_tetrahedra(), mesh, triplets_at_q, interaction.get_phonons()[0], grid_address, bz_map)
def _set_triplets_integration_weights_c(g, interaction, frequency_points): import anharmonic._phono3py as phono3c reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() triplets_at_q = interaction.get_triplets_at_q()[0] unique_vertices = thm.get_unique_tetrahedra_vertices() for i, j in zip((1, 2), (1, -1)): neighboring_grid_points = np.zeros( len(unique_vertices) * len(triplets_at_q), dtype='intc') phono3c.neighboring_grid_points( neighboring_grid_points, triplets_at_q[:, i].flatten(), j * unique_vertices, mesh, grid_address, bz_map) interaction.set_phonon(np.unique(neighboring_grid_points)) phono3c.triplets_integration_weights( g, np.array(frequency_points, dtype='double'), thm.get_tetrahedra(), mesh, triplets_at_q, interaction.get_phonons()[0], grid_address, bz_map)
def _set_triplets_integration_weights_c(g, interaction, frequency_points=None, neighboring_phonons=True, triplets_at_q=None, band_indices=None, is_triplet_symmetry=False): import anharmonic._phono3py as phono3c if triplets_at_q == None: triplets_at_q = interaction.get_triplets_at_q()[0] if len(triplets_at_q) == 0: return reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() if neighboring_phonons: unique_vertices = thm.get_unique_tetrahedra_vertices() for i in (1, 2, 0): # index inside a triplet for j in (1, -1): neighboring_grid_points = np.zeros( len(unique_vertices) * len(np.unique(triplets_at_q[:, i])), dtype='intc') phono3c.neighboring_grid_points( neighboring_grid_points, np.unique(triplets_at_q[:, i]).astype("intc"), j * unique_vertices, mesh, grid_address, bz_map) interaction.set_phonons(np.unique(neighboring_grid_points)) frequencies = interaction.get_phonons()[0] if len(np.where(mesh == 1)[0]) < 2: if band_indices is None: phono3c.triplets_integration_weights_fpoints( g, frequency_points, thm.get_tetrahedra().astype("intc").copy(), mesh, triplets_at_q, frequencies, grid_address, bz_map) else: phono3c.triplets_integration_weights( g, thm.get_tetrahedra().astype("intc").copy(), mesh, triplets_at_q, frequencies, np.array(band_indices, dtype='intc'), grid_address, bz_map, is_triplet_symmetry) else: # 1D case possible_shift = np.array((np.array(mesh) != 1), dtype='intc') relative_address = np.array( [[[0, 0, 0], possible_shift], [[0, 0, 0], -possible_shift]], dtype="intc") if band_indices is None: phono3c.triplets_integration_weights_1D_fpoints( g, frequency_points, relative_address, mesh, triplets_at_q, frequencies, grid_address, bz_map) else: phono3c.triplets_integration_weights_1D( g, relative_address, mesh, triplets_at_q, frequencies, np.array(band_indices, dtype='intc'), grid_address, bz_map, is_triplet_symmetry)
def get_unique_grid_points(grid_points, bz_grid): """Collect grid points on tetrahedron vertices around input grid points. Find grid points of 24 tetrahedra around each grid point and collect those grid points that are unique. Parameters ---------- grid_points : array_like Grid point indices. bz_grid : BZGrid Grid information in reciprocal space. Returns ------- ndarray Unique grid points on tetrahedron vertices around input grid points. shape=(unique_grid_points, ), dtype='int_'. """ import phono3py._phono3py as phono3c if _check_ndarray_state(grid_points, "int_"): _grid_points = grid_points else: _grid_points = np.array(grid_points, dtype="int_") thm = TetrahedronMethod(bz_grid.microzone_lattice) unique_vertices = np.array( np.dot(thm.get_unique_tetrahedra_vertices(), bz_grid.P.T), dtype="int_", order="C", ) neighboring_grid_points = np.zeros( len(unique_vertices) * len(_grid_points), dtype="int_" ) phono3c.neighboring_grid_points( neighboring_grid_points, _grid_points, unique_vertices, bz_grid.D_diag, bz_grid.addresses, bz_grid.gp_map, bz_grid.store_dense_gp_map * 1 + 1, ) unique_grid_points = np.array(np.unique(neighboring_grid_points), dtype="int_") return unique_grid_points
def _set_triplets_integration_weights_c(g, g_zero, interaction, frequency_points, neighboring_phonons=False): import phono3py._phono3py as phono3c reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() triplets_at_q = interaction.get_triplets_at_q()[0] if neighboring_phonons: unique_vertices = thm.get_unique_tetrahedra_vertices() for i, j in zip((1, 2), (1, -1)): neighboring_grid_points = np.zeros( len(unique_vertices) * len(triplets_at_q), dtype=bz_map.dtype) phono3c.neighboring_grid_points( neighboring_grid_points, np.array(triplets_at_q[:, i], dtype='uintp').ravel(), j * unique_vertices, mesh, grid_address, bz_map) interaction.run_phonon_solver(np.unique(neighboring_grid_points)) frequencies = interaction.get_phonons()[0] phono3c.triplets_integration_weights( g, g_zero, frequency_points, # f0 thm.get_tetrahedra(), mesh, triplets_at_q, frequencies, # f1 frequencies, # f2 grid_address, bz_map, g.shape[0])
def _set_triplets_integration_weights_c(g, interaction, frequency_points = None, neighboring_phonons=True, triplets_at_q=None, band_indices=None, is_triplet_symmetry=False): import anharmonic._phono3py as phono3c if triplets_at_q == None: triplets_at_q = interaction.get_triplets_at_q()[0] if len(triplets_at_q) == 0: return reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell()) mesh = interaction.get_mesh_numbers() thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh) grid_address = interaction.get_grid_address() bz_map = interaction.get_bz_map() if neighboring_phonons: unique_vertices = thm.get_unique_tetrahedra_vertices() for i in (1, 2, 0): # index inside a triplet for j in (1, -1): neighboring_grid_points = np.zeros( len(unique_vertices) * len(np.unique(triplets_at_q[:, i])), dtype='intc') phono3c.neighboring_grid_points( neighboring_grid_points, np.unique(triplets_at_q[:, i]).astype("intc"), j * unique_vertices, mesh, grid_address, bz_map) interaction.set_phonons(np.unique(neighboring_grid_points)) frequencies = interaction.get_phonons()[0] if len(np.where(mesh == 1)[0]) < 2: if band_indices is None: phono3c.triplets_integration_weights_fpoints( g, frequency_points, thm.get_tetrahedra().astype("intc").copy(), mesh, triplets_at_q, frequencies, grid_address, bz_map) else: phono3c.triplets_integration_weights( g, thm.get_tetrahedra().astype("intc").copy(), mesh, triplets_at_q, frequencies, np.array(band_indices, dtype='intc'), grid_address, bz_map, is_triplet_symmetry) else: # 1D case possible_shift = np.array((np.array(mesh) != 1), dtype='intc') relative_address = np.array([[[0, 0, 0], possible_shift], [[0, 0, 0], -possible_shift]], dtype="intc") if band_indices is None: phono3c.triplets_integration_weights_1D_fpoints( g, frequency_points, relative_address, mesh, triplets_at_q, frequencies, grid_address, bz_map) else: phono3c.triplets_integration_weights_1D( g, relative_address, mesh, triplets_at_q, frequencies, np.array(band_indices, dtype='intc'), grid_address, bz_map, is_triplet_symmetry)