[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2022-02-21 22:21:20 +00:00
parent cf506d37a7
commit 0f12a0a295
14 changed files with 41 additions and 41 deletions

View File

@ -41,8 +41,8 @@ source_suffix = ".rst"
master_doc = "index"
# General information about the project.
project = u"phono3py"
copyright = u"2015, Atsushi Togo"
project = "phono3py"
copyright = "2015, Atsushi Togo"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -230,7 +230,7 @@ latex_elements = {
# (source start file, target name, title, author, documentclass [howto/manual])
# .
latex_documents = [
("index", "phono3py.tex", u"phono3py manual", u"Atsushi Togo", "manual"),
("index", "phono3py.tex", "phono3py manual", "Atsushi Togo", "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
@ -258,7 +258,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "phono3py", u"phono3py Documentation", [u"Atsushi Togo"], 1)]
man_pages = [("index", "phono3py", "phono3py Documentation", ["Atsushi Togo"], 1)]
# If true, show URL addresses after external links.
# man_show_urls = False
@ -273,8 +273,8 @@ texinfo_documents = [
(
"index",
"phono3py",
u"phono3py Documentation",
u"Atsushi Togo",
"phono3py Documentation",
"Atsushi Togo",
"phono3py",
"One line description of project.",
"Miscellaneous",

View File

@ -450,7 +450,7 @@ def main():
if args.mfp:
if "mean_free_path" in f_kappa:
mfp = f_kappa["mean_free_path"][:]
mean_freepath = np.sqrt((mfp ** 2).sum(axis=3))
mean_freepath = np.sqrt((mfp**2).sum(axis=3))
else:
mean_freepath = get_mfp(
f_kappa["gamma"][:], f_kappa["group_velocity"][:]

View File

@ -87,7 +87,7 @@ def write_grid_points(
)
size = (num_ir_gp * num_band * 3) ** 2 * 8 / 1.0e9
print("- Full collision matrix at each temp and sigma: %.2f Gb" % size)
size = num_gp * (num_band ** 2 * 16 + num_band * 8 + 1) / 1.0e9
size = num_gp * (num_band**2 * 16 + num_band * 8 + 1) / 1.0e9
print("- Phonons: %.2f Gb" % size)
size = num_gp * 5 * 4 / 1.0e9
print("- Grid point information: %.2f Gb" % size)
@ -122,7 +122,7 @@ def show_num_triplets(
for gp in _grid_points:
num_triplets = tp_nums.get_number_of_triplets(gp)
q = np.dot(bz_grid.addresses[gp], bz_grid.QDinv.T)
size = num_triplets * num_band0 * num_band ** 2 * 8 / 1e6
size = num_triplets * num_band0 * num_band**2 * 8 / 1e6
print(
" %5d (%5.2f %5.2f %5.2f) %8d %d Mb"
% (gp, q[0], q[1], q[2], num_triplets, size)

View File

@ -352,7 +352,7 @@ class Isotope:
ti_sum += ti_sum_band * self._integration_weights[i, bi, j]
else:
ti_sum += ti_sum_band * gaussian(f0 - f, self._sigma)
t_inv.append(np.pi / 2 / np.prod(self._bz_grid.D_diag) * f0 ** 2 * ti_sum)
t_inv.append(np.pi / 2 / np.prod(self._bz_grid.D_diag) * f0**2 * ti_sum)
self._gamma = np.array(t_inv, dtype="double") / 2

View File

@ -227,6 +227,6 @@ def run_mfp_dos(
def get_mfp(g, gv):
"""Calculate mean free path from inverse lifetime and group velocity."""
g = np.where(g > 0, g, -1)
gv_norm = np.sqrt((gv ** 2).sum(axis=2))
gv_norm = np.sqrt((gv**2).sum(axis=2))
mean_freepath = np.where(g > 0, gv_norm / (2 * 2 * np.pi * g), 0)
return mean_freepath

View File

@ -39,7 +39,7 @@ from phonopy.units import AMU, EV, Angstrom, Hbar, Kb, THz, THzToEv
def gaussian(x, sigma):
"""Return normal distribution."""
return 1.0 / np.sqrt(2 * np.pi) / sigma * np.exp(-(x ** 2) / 2 / sigma ** 2)
return 1.0 / np.sqrt(2 * np.pi) / sigma * np.exp(-(x**2) / 2 / sigma**2)
def bose_einstein(x, T):
@ -95,7 +95,7 @@ def sigma_squared(x, T):
n = bose_einstein(x, T)
# factor=1.0107576777968994
factor = Hbar * EV / (2 * np.pi * THz) / AMU / Angstrom ** 2
factor = Hbar * EV / (2 * np.pi * THz) / AMU / Angstrom**2
#########################
np.seterr(**old_settings)

View File

@ -50,7 +50,7 @@ from phono3py.phonon3.triplets import get_all_triplets
from phono3py.phonon.grid import get_grid_points_by_rotations, get_ir_grid_points
unit_to_WmK = (
(THz * Angstrom) ** 2 / (Angstrom ** 3) * EV / THz / (2 * np.pi)
(THz * Angstrom) ** 2 / (Angstrom**3) * EV / THz / (2 * np.pi)
) # 2pi comes from definition of lifetime.

View File

@ -789,7 +789,7 @@ class ConductivityLBTE(Conductivity):
-1.0,
)
inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0)
freqs_sinh = freqs * THzToEv * inv_sinh / (4 * Kb * t ** 2)
freqs_sinh = freqs * THzToEv * inv_sinh / (4 * Kb * t**2)
for i, f in enumerate(freqs_sinh):
X[i] *= weights[i]
@ -1110,7 +1110,7 @@ class ConductivityLBTE(Conductivity):
mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf]
t = self._temperatures[i_temp]
mode_kappa[i_sigma, i_temp] *= self._conversion_factor * Kb * t ** 2
mode_kappa[i_sigma, i_temp] *= self._conversion_factor * Kb * t**2
def _set_mode_kappa_Chaput(self, i_sigma, i_temp, weights):
"""Calculate mode kappa by the way in Laurent Chaput's PRL paper.
@ -1150,11 +1150,11 @@ class ConductivityLBTE(Conductivity):
mat = mat.T
spectra = np.dot(mat.T, X) ** 2 * w
for s, eigvec in zip(spectra, mat.T):
vals = s * (eigvec ** 2).reshape(-1, 3).sum(axis=1)
vals = s * (eigvec**2).reshape(-1, 3).sum(axis=1)
vals = vals.reshape(num_ir_grid_points, num_band)
self._mode_kappa[i_sigma, i_temp, :, :, i] += vals
factor = self._conversion_factor * Kb * t ** 2
factor = self._conversion_factor * Kb * t**2
self._mode_kappa[i_sigma, i_temp] *= factor
def _set_mode_kappa_from_mfp(

View File

@ -609,7 +609,7 @@ class ImagSelfEnergy:
# Unit to THz of Gamma
self._unit_conversion = (
18 * np.pi / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2
18 * np.pi / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV**2
)
def run(self):

View File

@ -124,12 +124,12 @@ class Interaction:
(Hbar * EV) ** 3
/ 36
/ 8
* EV ** 2
/ Angstrom ** 6
* EV**2
/ Angstrom**6
/ (2 * np.pi * THz) ** 3
/ AMU ** 3
/ AMU**3
/ num_grid
/ EV ** 2
/ EV**2
)
else:
self._unit_conversion = unit_conversion
@ -797,7 +797,7 @@ class Interaction:
self._fc3 = np.array(fc3, dtype="double", order="C")
else:
self._fc3 = np.array(
fc3 * self._frequency_scale_factor ** 2, dtype="double", order="C"
fc3 * self._frequency_scale_factor**2, dtype="double", order="C"
)
def _set_band_indices(self, band_indices):

View File

@ -349,7 +349,7 @@ class RealSelfEnergy:
self._real_self_energies = None
# Unit to THz of Delta
self._unit_conversion = 18 / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2
self._unit_conversion = 18 / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV**2
def run(self):
"""Calculate real-part of self-energies."""
@ -571,10 +571,10 @@ class RealSelfEnergy:
# d -= (n2 - n3) / f3
# if abs(f4) > self._epsilon:
# d += (n2 - n3) / f4
d -= (n2 + n3 + 1) * f1 / (f1 ** 2 + self._epsilon ** 2)
d += (n2 + n3 + 1) * f2 / (f2 ** 2 + self._epsilon ** 2)
d -= (n2 - n3) * f3 / (f3 ** 2 + self._epsilon ** 2)
d += (n2 - n3) * f4 / (f4 ** 2 + self._epsilon ** 2)
d -= (n2 + n3 + 1) * f1 / (f1**2 + self._epsilon**2)
d += (n2 + n3 + 1) * f2 / (f2**2 + self._epsilon**2)
d -= (n2 - n3) * f3 / (f3**2 + self._epsilon**2)
d += (n2 - n3) * f4 / (f4**2 + self._epsilon**2)
sum_d += d * interaction[i, j, k] * weight
return sum_d
@ -597,8 +597,8 @@ class RealSelfEnergy:
# d -= 1.0 / f1
# if abs(f2) > self._epsilon:
# d += 1.0 / f2
d -= 1.0 * f1 / (f1 ** 2 + self._epsilon ** 2)
d += 1.0 * f2 / (f2 ** 2 + self._epsilon ** 2)
d -= 1.0 * f1 / (f1**2 + self._epsilon**2)
d += 1.0 * f2 / (f2**2 + self._epsilon**2)
sum_d += d * interaction[i, j, k] * weight
return sum_d

View File

@ -356,8 +356,8 @@ class SpectralFunction:
def _get_spectral_function(self, gammas, deltas, freq):
fpoints = self._frequency_points
nums = 4 * freq ** 2 * gammas / np.pi
denoms = (fpoints ** 2 - freq ** 2 - 2 * freq * deltas) ** 2 + (
nums = 4 * freq**2 * gammas / np.pi
denoms = (fpoints**2 - freq**2 - 2 * freq * deltas) ** 2 + (
2 * freq * gammas
) ** 2
vals = np.where(denoms > 0, nums / denoms, 0)

View File

@ -430,9 +430,9 @@ class SecondOrderFC:
nelems = np.prod(u.shape)
# print("sum u_inv:", u_inv.sum(axis=0) / u.shape[0])
print("sum all u_inv:", u_inv.sum() / nelems)
print("rms u_inv:", np.sqrt((u_inv ** 2).sum() / nelems))
print("rms u:", np.sqrt((u ** 2).sum() / nelems))
print("rms forces:", np.sqrt((self._forces ** 2).sum() / nelems))
print("rms u_inv:", np.sqrt((u_inv**2).sum() / nelems))
print("rms u:", np.sqrt((u**2).sum() / nelems))
print("rms forces:", np.sqrt((self._forces**2).sum() / nelems))
# print("drift forces:",
# self._forces.sum(axis=0) / self._forces.shape[0])
@ -556,9 +556,9 @@ class ThirdOrderFC:
if self._log_level:
N = np.prod(u.shape)
print("rms u_inv:", np.sqrt((u_inv ** 2).sum() / N))
print("rms u:", np.sqrt((u ** 2).sum() / N))
print("rms forces:", np.sqrt((self._forces ** 2).sum() / N))
print("rms f:", np.sqrt((f ** 2).sum() / N))
print("rms u_inv:", np.sqrt((u_inv**2).sum() / N))
print("rms u:", np.sqrt((u**2).sum() / N))
print("rms forces:", np.sqrt((self._forces**2).sum() / N))
print("rms f:", np.sqrt((f**2).sum() / N))
return -np.einsum("li,lj,lk->ijk", u_inv, u_inv, f) / f.shape[0]

View File

@ -67,7 +67,7 @@ def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1):
indices = [nbins - i - 1]
short_nbinds = len(indices)
ynbins = nbins ** 2 // short_nbinds
ynbins = nbins**2 // short_nbinds
xi, yi = np.mgrid[x_min : _x_max : nbins * 1j, y_min : _y_max : ynbins * 1j]
positions = np.vstack([xi.ravel(), yi.ravel()])
zi = np.reshape(kernel(positions).T, xi.shape)