def get_triplets_integration_weights(interaction, frequency_points, sigma, is_collision_matrix=False, neighboring_phonons=False, lang='C'): triplets = interaction.get_triplets_at_q()[0] frequencies = interaction.get_phonons()[0] num_band = frequencies.shape[1] g_zero = None if is_collision_matrix: g = np.empty( (3, len(triplets), len(frequency_points), num_band, num_band), dtype='double', order='C') else: g = np.empty( (2, len(triplets), len(frequency_points), num_band, num_band), dtype='double', order='C') g[:] = 0 if sigma: if lang == 'C': import phono3py._phono3py as phono3c phono3c.triplets_integration_weights_with_sigma( g, frequency_points, triplets, frequencies, sigma) else: for i, tp in enumerate(triplets): f1s = frequencies[tp[1]] f2s = frequencies[tp[2]] for j, k in list(np.ndindex((num_band, num_band))): f1 = f1s[j] f2 = f2s[k] g0 = gaussian(frequency_points - f1 - f2, sigma) g[0, i, :, j, k] = g0 g1 = gaussian(frequency_points + f1 - f2, sigma) g2 = gaussian(frequency_points - f1 + f2, sigma) g[1, i, :, j, k] = g1 - g2 if len(g) == 3: g[2, i, :, j, k] = g0 + g1 + g2 else: if lang == 'C': g_zero = np.zeros(g.shape[1:], dtype='byte', order='C') _set_triplets_integration_weights_c( g, g_zero, interaction, frequency_points, neighboring_phonons=neighboring_phonons) else: _set_triplets_integration_weights_py(g, interaction, frequency_points) return g, g_zero
def get_triplets_integration_weights( interaction, frequency_points, sigma, sigma_cutoff=None, is_collision_matrix=False, lang="C", ): """Calculate triplets integration weights. Returns ------- g : ndarray Triplets integration weights. shape=(2 or 3, triplets, freq_points, bands, bands), dtype='double'. g_zero : ndarray Location of strictly zero elements. shape=(triplets, freq_points, bands, bands), dtype='byte' """ triplets = interaction.get_triplets_at_q()[0] frequencies = interaction.get_phonons()[0] num_band = frequencies.shape[1] g_zero = None if is_collision_matrix: g = np.empty( (3, len(triplets), len(frequency_points), num_band, num_band), dtype="double", order="C", ) else: g = np.empty( (2, len(triplets), len(frequency_points), num_band, num_band), dtype="double", order="C", ) g[:] = 0 if sigma: if lang == "C": import phono3py._phono3py as phono3c g_zero = np.zeros(g.shape[1:], dtype="byte", order="C") if sigma_cutoff is None: cutoff = -1 else: cutoff = float(sigma_cutoff) # cutoff < 0 disables g_zero feature. phono3c.triplets_integration_weights_with_sigma( g, g_zero, frequency_points, triplets, frequencies, sigma, cutoff ) else: for i, tp in enumerate(triplets): f1s = frequencies[tp[1]] f2s = frequencies[tp[2]] for j, k in list(np.ndindex((num_band, num_band))): f1 = f1s[j] f2 = f2s[k] g0 = gaussian(frequency_points - f1 - f2, sigma) g[0, i, :, j, k] = g0 g1 = gaussian(frequency_points + f1 - f2, sigma) g2 = gaussian(frequency_points - f1 + f2, sigma) g[1, i, :, j, k] = g1 - g2 if len(g) == 3: g[2, i, :, j, k] = g0 + g1 + g2 else: if lang == "C": g_zero = np.zeros(g.shape[1:], dtype="byte", order="C") _set_triplets_integration_weights_c( g, g_zero, interaction, frequency_points, ) else: _set_triplets_integration_weights_py(g, interaction, frequency_points) return g, g_zero