Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Nov 4, 2024
2 parents c3bb891 + 5d2fa2e commit c839d3e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -34,6 +34,9 @@ jobs:
- name: Test with pytest
run: |
conda activate test
velph --help
phelel --help
phelel-load --help
pytest -v --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
]
requires-python = ">=3.9"
dependencies = [
"phono3py",
"phono3py >= 3.6.0",
"finufft",
"click",
"tomli",
Expand Down
3 changes: 2 additions & 1 deletion src/phelel/velph/cli/el_bands/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import click
import h5py
import matplotlib.pyplot as plt

from phelel.velph.cli.utils import (
get_distances_along_BZ_path,
Expand Down Expand Up @@ -35,6 +34,8 @@ def plot_el_bandstructures(
File name of band structure plot.
"""
import matplotlib.pyplot as plt

f_h5py_bands = h5py.File(vaspout_filename_bands)
f_h5py_dos = h5py.File(vaspout_filename_dos)
efermi = f_h5py_dos["results"]["electron_dos_kpoints_opt"]["efermi"][()]
Expand Down
3 changes: 2 additions & 1 deletion src/phelel/velph/cli/ph_bands/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import click
import h5py
import matplotlib.pyplot as plt
import numpy as np

from phelel.velph.cli.utils import (
Expand Down Expand Up @@ -32,6 +31,8 @@ def plot_ph_bandstructures(
File name of band structure plot.
"""
import matplotlib.pyplot as plt

f = h5py.File(vaspout_filename)
eigvals = f["results"]["phonons"]["eigenvalues"][:] # phonon eigenvalues
if use_ordinary_frequency:
Expand Down
20 changes: 16 additions & 4 deletions src/phelel/velph/cli/transport/plot/plot_eigenvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import click
import h5py
import matplotlib.pyplot as plt
import numpy as np
from phonopy.structure.brillouin_zone import get_qpoints_in_Brillouin_zone
from phonopy.structure.cells import get_reduced_bases
Expand Down Expand Up @@ -137,6 +136,8 @@ def _plot_eigenvalues_in_BZ(
title: Optional[str] = None,
):
"""Plot kpoints in Brillouin zone."""
import matplotlib.pyplot as plt

ax = _get_ax_3D()
point_sizes = (1 - np.abs(weights)) * 5
scatter = ax.scatter(
Expand All @@ -158,16 +159,25 @@ def _plot_eigenvalues_in_BZ(
plt.show()


def _get_ax_3D() -> plt.Axes:
"""Get 3D axis."""
def _get_ax_3D() -> "plt.Axes": # noqa: F821
"""Get 3D axis.
Returns
-------
plt.Axes
3D axis.
"""
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection="3d")
ax.grid(False)
ax.set_box_aspect([1, 1, 1])
return ax


def _plot_Brillouin_zone(bz_lattice: np.ndarray, ax: plt.Axes):
def _plot_Brillouin_zone(bz_lattice: np.ndarray, ax: "plt.Axes"): # noqa: F821
"""Plot Brillouin zone.
Parameters
Expand All @@ -176,6 +186,8 @@ def _plot_Brillouin_zone(bz_lattice: np.ndarray, ax: plt.Axes):
Reciprocal basis vectors in column vectors.
"""
import matplotlib.pyplot as plt # noqa: F401

bz_red_lattice = get_reduced_bases(bz_lattice.T).T
points = np.dot(np.array(list(np.ndindex(3, 3, 3))) - [1, 1, 1], bz_red_lattice.T)
vor = Voronoi(points)
Expand Down
13 changes: 7 additions & 6 deletions src/phelel/velph/cli/transport/plot/plot_selfenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import click
import h5py
import matplotlib.pyplot as plt


def plot_selfenergy(f_h5py: h5py.File, plot_filename: str, save_plot: bool = False):
Expand All @@ -20,6 +19,8 @@ def plot_selfenergy(f_h5py: h5py.File, plot_filename: str, save_plot: bool = Fal
- static_approximation (True or False)
"""
import matplotlib.pyplot as plt

selfens = {}
for key in f_h5py["results"]["electron_phonon"]["electrons"]:
if "self_energy_" in key:
Expand Down Expand Up @@ -73,7 +74,7 @@ def _show(selfen: h5py.Group, index: int):
selfen["scattering_approximation"][()].decode("utf-8"),
)
print(f" static_approximation: {bool(selfen['static'][()])}")
print(f" use_tetrahedron_method: {bool(selfen["tetrahedron"][()])}")
print(f" use_tetrahedron_method: {bool(selfen['tetrahedron'][()])}")
if not selfen["tetrahedron"][()]:
print(f" smearing_width: {selfen['delta'][()]}")
print(
Expand All @@ -87,7 +88,7 @@ def _show(selfen: h5py.Group, index: int):
print(f" - {t} # {i + 1}")

print(" data_array_shapes:")
print(f" carrier_per_cell: {list(selfen["carrier_per_cell"].shape)}")
print(f" Fan_self_energy: {list(selfen["selfen_fan"].shape)}")
print(f" sampling_energy_points: {list(selfen["energies"].shape)}")
print(f" Fermi_energies: {list(selfen["efermi"].shape)}")
print(f" carrier_per_cell: {list(selfen['carrier_per_cell'].shape)}")
print(f" Fan_self_energy: {list(selfen['selfen_fan'].shape)}")
print(f" sampling_energy_points: {list(selfen['energies'].shape)}")
print(f" Fermi_energies: {list(selfen['efermi'].shape)}")
10 changes: 6 additions & 4 deletions src/phelel/velph/cli/transport/plot/plot_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import click
import h5py
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np


Expand All @@ -27,6 +25,8 @@ def plot_transport(f_h5py: h5py.File, plot_filename: str, save_plot: bool = Fals
In the following codes, N(scattering_approximation) * N(temps) are only considered.
"""
import matplotlib.pyplot as plt

property_names = (
"e_conductivity",
"e_conductivity",
Expand Down Expand Up @@ -91,6 +91,8 @@ def _plot(
Second property with the property name "e_conductivity" is resistivity.
"""
import matplotlib.ticker as ticker

temps = transport["temps"][:]
dat_filename = f"transport-{index + 1}.dat"
properties = []
Expand Down Expand Up @@ -131,7 +133,7 @@ def _plot(
axs[i].tick_params(axis="y", direction="in")
axs[i].set_xlabel("temperature (K)")
if labels:
axs[i].set_ylabel(f"[{index + 1}] {label_property} ({"-".join(labels)})")
axs[i].set_ylabel(f"[{index + 1}] {label_property} ({'-'.join(labels)})")
else:
axs[i].set_ylabel(f"[{index + 1}] {label_property}")
axs[i].set_xlim(left=0, right=max(temps))
Expand Down Expand Up @@ -168,7 +170,7 @@ def _show(transport: h5py.Group, index: int):
print(f" {key[1]}: {transport[key[0]][()]}")
else:
print(f" {key}: {transport[key][()]}")
print(f" static_approximation: {bool(transport["static"][()])}")
print(f" static_approximation: {bool(transport['static'][()])}")

print(" data_scalar:")
for key in (
Expand Down
2 changes: 1 addition & 1 deletion src/phelel/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version number."""

__version__ = "0.6.3"
__version__ = "0.6.4"

0 comments on commit c839d3e

Please sign in to comment.