From f7c358f87d074666172c34183f577a97b621819e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 21 Feb 2026 15:56:02 +0900 Subject: [PATCH 1/4] Implementing velph-ph_selfenergy-dump --- .../cli/ph_selfenergy/cmd_ph_selfenergy.py | 21 +++ .../velph/cli/ph_selfenergy/plot/cmd_plot.py | 29 +++- src/phelel/velph/cli/selfenergy/__init__.py | 54 +----- .../velph/cli/selfenergy/cmd_selfenergy.py | 53 ++++++ src/phelel/velph/cli/transport/__init__.py | 57 +------ .../velph/cli/transport/cmd_transport.py | 56 +++++++ .../velph/cli/transport/plot/__init__.py | 136 +-------------- .../velph/cli/transport/plot/cmd_plot.py | 155 ++++++++++++++++++ src/phelel/velph/utils/plot_eigenvalues.py | 48 ++++-- 9 files changed, 352 insertions(+), 257 deletions(-) create mode 100644 src/phelel/velph/cli/selfenergy/cmd_selfenergy.py create mode 100644 src/phelel/velph/cli/transport/cmd_transport.py create mode 100644 src/phelel/velph/cli/transport/plot/cmd_plot.py diff --git a/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py b/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py index fb3fbfb..cd991c4 100644 --- a/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py +++ b/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py @@ -3,6 +3,7 @@ import pathlib import click +import h5py from phelel.velph.cli import cmd_root from phelel.velph.cli.selfenergy.generate import write_selfenergy_input_files @@ -51,3 +52,23 @@ def cmd_generate(toml_filename: str, dry_run: bool): def cmd_check_fft(toml_filename: str): """Show [NGX, NGY, NGZ] in vasprun.xml.""" check_fft(toml_filename, "ph_selfenergy") + + +@cmd_ph_selfenergy.command("dump") +@click.argument( + "vaspout_filename", + nargs=1, + type=click.Path(), + default="ph_selfenergy/vaspout.h5", +) +@click.argument( + "output_filename", + nargs=1, + type=click.Path(), + default="ph_selfenergy/ph_selfenergy.hdf5", +) +@click.help_option("-h", "--help") +def cmd_dump(vaspout_filename: str, output_filename: str): + """Dump ph_selfenergy data to HDF5 file.""" + with h5py.File(vaspout_filename, "r") as f: + list(f) diff --git a/src/phelel/velph/cli/ph_selfenergy/plot/cmd_plot.py b/src/phelel/velph/cli/ph_selfenergy/plot/cmd_plot.py index b24b59b..a6727b0 100644 --- a/src/phelel/velph/cli/ph_selfenergy/plot/cmd_plot.py +++ b/src/phelel/velph/cli/ph_selfenergy/plot/cmd_plot.py @@ -40,11 +40,12 @@ def cmd_plot(): @click.help_option("-h", "--help") def cmd_plot_selfenergy(vaspout_filename: str, save_plot: bool): """Plot self-energy in ph_selfenergy.""" - f_h5py, plot_filename = _get_f_h5py_and_plot_filename( + _vaspout_filename, plot_filename = _get_h5py_and_plot_filenames( "selfenergy", vaspout_filename=pathlib.Path(vaspout_filename) ) - if f_h5py is not None and plot_filename is not None: - plot_selfenergy(f_h5py, plot_filename, save_plot=save_plot) + with h5py.File(_vaspout_filename, "r") as f_h5py: + if f_h5py is not None and plot_filename is not None: + plot_selfenergy(f_h5py, plot_filename, save_plot=save_plot) @cmd_plot.command("eigenvalues") @@ -60,10 +61,20 @@ def cmd_plot_selfenergy(vaspout_filename: str, save_plot: bool): type=int, default=None, help=( - "Index of self-energy calculation for collecting chemical potential and " + "Index of temperature for collecting chemical potential and " "temperature. (tid: int, default=None)" ), ) +@click.option( + "--calcid", + nargs=1, + type=int, + default=None, + help=( + "Index of self-energy calculation for collecting chemical potential and " + "temperature. (calcid: int, default=None)" + ), +) @eigenvalue_plot_options def cmd_plot_ph_selfenergy_eigenvalues( vaspout_filename: str, @@ -71,6 +82,7 @@ def cmd_plot_ph_selfenergy_eigenvalues( cutoff_occupancy: float, mu: float | None, tid: int | None, + calcid: int | None, ): """Show eigenvalues in ph_selfenergy.""" cmd_plot_eigenvalues( @@ -79,15 +91,16 @@ def cmd_plot_ph_selfenergy_eigenvalues( cutoff_occupancy, mu, tid, + calcid, calc_type="ph_selfenergy", ) -def _get_f_h5py_and_plot_filename( +def _get_h5py_and_plot_filenames( property_name: str, vaspout_filename: str | os.PathLike | None = None, plot_filename: str | os.PathLike | None = None, -) -> tuple[h5py.File, pathlib.Path] | tuple[None, None]: +) -> tuple[pathlib.Path, pathlib.Path] | tuple[None, None]: """Return h5py.File object and plot filename.""" if vaspout_filename is None: _vaspout_filename = pathlib.Path(f"{property_name}/vaspout.h5") @@ -106,6 +119,4 @@ def _get_f_h5py_and_plot_filename( else: _plot_filename = pathlib.Path(plot_filename) - f_h5py = h5py.File(_vaspout_filename) - - return f_h5py, _plot_filename + return _vaspout_filename, _plot_filename diff --git a/src/phelel/velph/cli/selfenergy/__init__.py b/src/phelel/velph/cli/selfenergy/__init__.py index a5e64e6..2f89d56 100644 --- a/src/phelel/velph/cli/selfenergy/__init__.py +++ b/src/phelel/velph/cli/selfenergy/__init__.py @@ -1,53 +1,7 @@ """velph command line tool / velph-selfenergy.""" -import pathlib - -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.selfenergy.generate import write_input_files -from phelel.velph.cli.utils import check_fft - - -@cmd_root.group("selfenergy") -@click.help_option("-h", "--help") -def cmd_selfenergy(): - """Choose selfenergy options.""" - pass - - -@cmd_selfenergy.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.option( - "--dry-run/--no-dry-run", - "-d", - "dry_run", - is_flag=True, - default=False, - show_default=True, -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str, dry_run: bool): - """Generate elph input files.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_input_files(pathlib.Path(toml_filename), dry_run) - - -@cmd_selfenergy.command("check-fft") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", +from phelel.velph.cli.selfenergy.cmd_selfenergy import ( + cmd_check_fft, # noqa F401 : velph selfenergy check-fft + cmd_generate, # noqa F401 : velph selfenergy generate + cmd_selfenergy, # noqa F401 : velph selfenergy ) -@click.help_option("-h", "--help") -def cmd_check_fft(toml_filename: str): - """Show [NGX, NGY, NGZ] in vasprun.xml.""" - check_fft(toml_filename, "selfenergy") diff --git a/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py b/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py new file mode 100644 index 0000000..a5e64e6 --- /dev/null +++ b/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py @@ -0,0 +1,53 @@ +"""velph command line tool / velph-selfenergy.""" + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.selfenergy.generate import write_input_files +from phelel.velph.cli.utils import check_fft + + +@cmd_root.group("selfenergy") +@click.help_option("-h", "--help") +def cmd_selfenergy(): + """Choose selfenergy options.""" + pass + + +@cmd_selfenergy.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.option( + "--dry-run/--no-dry-run", + "-d", + "dry_run", + is_flag=True, + default=False, + show_default=True, +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str, dry_run: bool): + """Generate elph input files.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_input_files(pathlib.Path(toml_filename), dry_run) + + +@cmd_selfenergy.command("check-fft") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_check_fft(toml_filename: str): + """Show [NGX, NGY, NGZ] in vasprun.xml.""" + check_fft(toml_filename, "selfenergy") diff --git a/src/phelel/velph/cli/transport/__init__.py b/src/phelel/velph/cli/transport/__init__.py index 434facb..648e6a8 100644 --- a/src/phelel/velph/cli/transport/__init__.py +++ b/src/phelel/velph/cli/transport/__init__.py @@ -1,56 +1,9 @@ """velph command line tool / velph-transport.""" -import pathlib - -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.transport.generate import write_input_files -from phelel.velph.cli.utils import check_fft - - -@cmd_root.group("transport") -@click.help_option("-h", "--help") -def cmd_transport(): - """Choose transport options.""" - pass - - -@cmd_transport.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", +from phelel.velph.cli.transport.cmd_transport import ( + cmd_check_fft, # noqa F401 : velph transport check-fft + cmd_generate, # noqa F401 : velph transport generate ) -@click.option( - "--dry-run/--no-dry-run", - "-d", - "dry_run", - is_flag=True, - default=False, - show_default=True, +from phelel.velph.cli.transport.plot import ( + cmd_plot, # noqa F401 : velph transport plot ) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str, dry_run: bool): - """Generate transport input files.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_input_files(pathlib.Path(toml_filename), dry_run) - - -@cmd_transport.command("check-fft") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_check_fft(toml_filename: str): - """Show [NGX, NGY, NGZ] in vasprun.xml.""" - check_fft(toml_filename, "transport") - - -from phelel.velph.cli.transport.plot import cmd_plot # noqa F401 diff --git a/src/phelel/velph/cli/transport/cmd_transport.py b/src/phelel/velph/cli/transport/cmd_transport.py new file mode 100644 index 0000000..434facb --- /dev/null +++ b/src/phelel/velph/cli/transport/cmd_transport.py @@ -0,0 +1,56 @@ +"""velph command line tool / velph-transport.""" + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.transport.generate import write_input_files +from phelel.velph.cli.utils import check_fft + + +@cmd_root.group("transport") +@click.help_option("-h", "--help") +def cmd_transport(): + """Choose transport options.""" + pass + + +@cmd_transport.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.option( + "--dry-run/--no-dry-run", + "-d", + "dry_run", + is_flag=True, + default=False, + show_default=True, +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str, dry_run: bool): + """Generate transport input files.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_input_files(pathlib.Path(toml_filename), dry_run) + + +@cmd_transport.command("check-fft") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_check_fft(toml_filename: str): + """Show [NGX, NGY, NGZ] in vasprun.xml.""" + check_fft(toml_filename, "transport") + + +from phelel.velph.cli.transport.plot import cmd_plot # noqa F401 diff --git a/src/phelel/velph/cli/transport/plot/__init__.py b/src/phelel/velph/cli/transport/plot/__init__.py index e2cd6ff..d047d16 100644 --- a/src/phelel/velph/cli/transport/plot/__init__.py +++ b/src/phelel/velph/cli/transport/plot/__init__.py @@ -1,135 +1,7 @@ """velph command line tool / velph-transport-plot.""" -from __future__ import annotations - -import os -import pathlib - -import click -import h5py - -from phelel.velph.cli.transport import cmd_transport -from phelel.velph.cli.transport.plot.plot_selfenergy import plot_selfenergy -from phelel.velph.cli.transport.plot.plot_transport import plot_transport -from phelel.velph.utils.plot_eigenvalues import ( - cmd_plot_eigenvalues, - eigenvalue_plot_options, -) - - -@cmd_transport.group("plot") -@click.help_option("-h", "--help") -def cmd_plot(): - """Choose plot options.""" - pass - - -@cmd_plot.command("selfenergy") -@click.argument( - "vaspout_filename", - nargs=1, - type=click.Path(), - default="transport/vaspout.h5", -) -@click.option( - "--save", - "save_plot", - is_flag=bool, - default=False, - help=("Save plot to file."), -) -@click.help_option("-h", "--help") -def cmd_plot_selfenergy(vaspout_filename: str, save_plot: bool): - """Plot self-energy in transports.""" - args = _get_f_h5py_and_plot_filename( - "selfenergy", vaspout_filename=pathlib.Path(vaspout_filename) - ) - if args[0] is not None: - plot_selfenergy(*args, save_plot=save_plot) - - -@cmd_plot.command("transport") -@click.argument( - "vaspout_filename", - nargs=1, - type=click.Path(), - default="transport/vaspout.h5", +from phelel.velph.cli.transport.plot.cmd_plot import ( + cmd_plot_eigenvalues, # noqa F401 : velph transport plot eigenvalues + cmd_plot_selfenergy, # noqa F401 : velph transport plot selfenergy + cmd_plot_transport_eigenvalues, # noqa F401 : velph transport plot transport ) -@click.option( - "--save", - "save_plot", - is_flag=bool, - default=False, - help=("Save plot to file."), -) -@click.help_option("-h", "--help") -def cmd_plot_transport(vaspout_filename: str, save_plot: bool): - """Plot transport in transports.""" - args = _get_f_h5py_and_plot_filename( - "transport", vaspout_filename=pathlib.Path(vaspout_filename) - ) - if args[0] is not None: - plot_transport(*args, save_plot=save_plot) - - -@cmd_plot.command("eigenvalues") -@click.argument( - "vaspout_filename", - nargs=1, - type=click.Path(), - default="transport/vaspout.h5", -) -@click.option( - "--tid", - nargs=1, - type=int, - default=None, - help=( - "Index of self-energy calculation for collecting chemical potential and " - "temperature. (tid: int, default=None)" - ), -) -@eigenvalue_plot_options -def cmd_plot_transport_eigenvalues( - vaspout_filename: str, - temperature: float, - cutoff_occupancy: float, - mu: float | None, - tid: int | None, -): - """Show eigenvalues in transports.""" - cmd_plot_eigenvalues( - vaspout_filename, - temperature, - cutoff_occupancy, - mu, - tid, - ) - - -def _get_f_h5py_and_plot_filename( - property_name: str, - vaspout_filename: str | os.PathLike | None = None, - plot_filename: str | os.PathLike | None = None, -) -> tuple[h5py.File, pathlib.Path, pathlib.Path] | tuple[None, None, None]: - """Return h5py.File object and plot filename.""" - if vaspout_filename is None: - _vaspout_filename = pathlib.Path(f"{property_name}/vaspout.h5") - else: - _vaspout_filename = pathlib.Path(vaspout_filename) - - if not _vaspout_filename.exists(): - click.echo(f'"{_vaspout_filename}" (default path) not found.') - click.echo("Please specify vaspout.h5 file path.") - return None, None, None - - dir_name = _vaspout_filename.parent - - if plot_filename is None: - _plot_filename = dir_name / f"{property_name}.pdf" - else: - _plot_filename = pathlib.Path(plot_filename) - - f_h5py = h5py.File(_vaspout_filename) - - return f_h5py, _plot_filename, dir_name diff --git a/src/phelel/velph/cli/transport/plot/cmd_plot.py b/src/phelel/velph/cli/transport/plot/cmd_plot.py new file mode 100644 index 0000000..27bd461 --- /dev/null +++ b/src/phelel/velph/cli/transport/plot/cmd_plot.py @@ -0,0 +1,155 @@ +"""velph command line tool / velph-transport-plot.""" + +from __future__ import annotations + +import os +import pathlib + +import click +import h5py + +from phelel.velph.cli.transport.cmd_transport import cmd_transport +from phelel.velph.cli.transport.plot.plot_selfenergy import plot_selfenergy +from phelel.velph.cli.transport.plot.plot_transport import plot_transport +from phelel.velph.utils.plot_eigenvalues import ( + cmd_plot_eigenvalues, + eigenvalue_plot_options, +) + + +@cmd_transport.group("plot") +@click.help_option("-h", "--help") +def cmd_plot(): + """Choose plot options.""" + pass + + +@cmd_plot.command("selfenergy") +@click.argument( + "vaspout_filename", + nargs=1, + type=click.Path(), + default="transport/vaspout.h5", +) +@click.option( + "--save", + "save_plot", + is_flag=bool, + default=False, + help=("Save plot to file."), +) +@click.help_option("-h", "--help") +def cmd_plot_selfenergy(vaspout_filename: str, save_plot: bool): + """Plot self-energy in transports.""" + _vaspout_filename, plot_filename, dir_name = _get_h5py_and_plot_filenames( + "selfenergy", vaspout_filename=pathlib.Path(vaspout_filename) + ) + if ( + _vaspout_filename is not None + and plot_filename is not None + and dir_name is not None + ): + with h5py.File(_vaspout_filename, "r") as f_h5py: + plot_selfenergy(f_h5py, plot_filename, dir_name, save_plot=save_plot) + + +@cmd_plot.command("transport") +@click.argument( + "vaspout_filename", + nargs=1, + type=click.Path(), + default="transport/vaspout.h5", +) +@click.option( + "--save", + "save_plot", + is_flag=bool, + default=False, + help=("Save plot to file."), +) +@click.help_option("-h", "--help") +def cmd_plot_transport(vaspout_filename: str, save_plot: bool): + """Plot transport in transports.""" + _vaspout_filename, plot_filename, dir_name = _get_h5py_and_plot_filenames( + "transport", vaspout_filename=pathlib.Path(vaspout_filename) + ) + if ( + _vaspout_filename is not None + and plot_filename is not None + and dir_name is not None + ): + with h5py.File(_vaspout_filename, "r") as f_h5py: + plot_transport(f_h5py, plot_filename, dir_name, save_plot=save_plot) + + +@cmd_plot.command("eigenvalues") +@click.argument( + "vaspout_filename", + nargs=1, + type=click.Path(), + default="transport/vaspout.h5", +) +@click.option( + "--tid", + nargs=1, + type=int, + default=None, + help=( + "Index of self-energy calculation for collecting chemical potential and " + "temperature. (tid: int, default=None)" + ), +) +@click.option( + "--calcid", + nargs=1, + type=int, + default=None, + help=( + "Index of self-energy calculation for collecting chemical potential and " + "temperature. (calcid: int, default=None)" + ), +) +@eigenvalue_plot_options +def cmd_plot_transport_eigenvalues( + vaspout_filename: str, + temperature: float, + cutoff_occupancy: float, + mu: float | None, + tid: int | None, + calcid: int | None, +): + """Show eigenvalues in transports.""" + cmd_plot_eigenvalues( + vaspout_filename, + temperature, + cutoff_occupancy, + mu, + calcid, + tid, + ) + + +def _get_h5py_and_plot_filenames( + property_name: str, + vaspout_filename: str | os.PathLike | None = None, + plot_filename: str | os.PathLike | None = None, +) -> tuple[pathlib.Path, pathlib.Path, pathlib.Path] | tuple[None, None, None]: + """Return h5py.File object and plot filename.""" + if vaspout_filename is None: + _vaspout_filename = pathlib.Path(f"{property_name}/vaspout.h5") + else: + _vaspout_filename = pathlib.Path(vaspout_filename) + + if not _vaspout_filename.exists(): + click.echo(f'"{_vaspout_filename}" (default path) not found.') + click.echo("Please specify vaspout.h5 file path.") + return None, None, None + + dir_name = _vaspout_filename.parent + + if plot_filename is None: + _plot_filename = dir_name / f"{property_name}.pdf" + else: + _plot_filename = pathlib.Path(plot_filename) + + return _vaspout_filename, _plot_filename, dir_name diff --git a/src/phelel/velph/utils/plot_eigenvalues.py b/src/phelel/velph/utils/plot_eigenvalues.py index dd698d8..94d0727 100644 --- a/src/phelel/velph/utils/plot_eigenvalues.py +++ b/src/phelel/velph/utils/plot_eigenvalues.py @@ -72,6 +72,7 @@ def cmd_plot_eigenvalues( cutoff_occupancy: float, mu: float | None, tid: int | None, + calcid: int | None, calc_type: Literal["transport", "ph_selfenergy", "el_bands"] = "transport", ): """Show eigenvalues in transports. @@ -90,15 +91,23 @@ def cmd_plot_eigenvalues( ) return None - f_h5py = h5py.File(_vaspout_filename) - retvals = _plot_eigenvalues( - f_h5py, - tid=tid, - temperature=temperature, - cutoff_occupancy=cutoff_occupancy, - mu=mu, - calc_type=calc_type, - ) + with h5py.File(_vaspout_filename) as f_h5py: + if calc_type in ("transport", "ph_selfenergy"): + n_calculators: int = f_h5py[ + "results/electron_phonon/electrons/self_energy_meta/ncalculators" + ][()] # type: ignore + + click.echo(f"Possible calculator IDs: {np.arange(n_calculators) + 1}.") + + retvals = _plot_eigenvalues( + f_h5py, + tid=tid, + calcid=calcid, + temperature=temperature, + cutoff_occupancy=cutoff_occupancy, + mu=mu, + calc_type=calc_type, + ) if retvals is not None: with open(f"{calc_type}/bz.dat", "w") as w: @@ -113,6 +122,7 @@ def cmd_plot_eigenvalues( def _plot_eigenvalues( f_h5py: h5py.File, tid: int | None = None, + calcid: int | None = None, temperature: float | None = None, cutoff_occupancy: float = 1e-2, mu: float | None = None, @@ -139,14 +149,24 @@ def _plot_eigenvalues( sym_dataset = get_symmetry_dataset(cell) rotations = [r.T for r in sym_dataset.rotations] - if tid is not None and calc_type != "el_bands": - if calc_type == "transport": - params = f_h5py["results/electron_phonon/electrons/transport_1"] - elif calc_type == "ph_selfenergy": - params = f_h5py["results/electron_phonon/phonons/self_energy_1"] + if calcid is None: + _calcid = 1 + else: + _calcid = calcid + + if calc_type == "transport": + params = f_h5py[f"results/electron_phonon/electrons/transport_{_calcid}"] # type: ignore + elif calc_type == "ph_selfenergy": + params = f_h5py[f"results/electron_phonon/phonons/self_energy_{_calcid}"] # type: ignore + + if calc_type in ("transport", "ph_selfenergy") and tid is not None: _temperature: float = params["temps"][tid - 1] # type: ignore _mu = params["efermi"][tid - 1] # type: ignore else: + if calc_type in ("transport", "ph_selfenergy"): + click.echo( + f"Possible temperature IDs {np.arange(params['temps'].shape[0]) + 1}." # type: ignore + ) if temperature is None: _temperature = 300 else: From d3143346d66688ebf44b9e397bbe8d679b67b729 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 22 Feb 2026 16:49:04 +0900 Subject: [PATCH 2/4] Refactor velph --- src/phelel/velph/cli/__init__.py | 2 - src/phelel/velph/cli/el_bands/__init__.py | 111 +----- src/phelel/velph/cli/el_bands/cmd_el_bands.py | 100 +++++ src/phelel/velph/cli/generate/__init__.py | 60 +-- src/phelel/velph/cli/generate/cmd_generate.py | 70 ++++ src/phelel/velph/cli/hints/__init__.py | 100 ----- src/phelel/velph/cli/init/__init__.py | 374 +---------------- src/phelel/velph/cli/init/cmd_init.py | 375 ++++++++++++++++++ src/phelel/velph/cli/nac/__init__.py | 30 +- src/phelel/velph/cli/nac/cmd_nac.py | 33 ++ src/phelel/velph/cli/ph_bands/__init__.py | 72 +--- src/phelel/velph/cli/ph_bands/cmd_ph_bands.py | 68 ++++ .../velph/cli/ph_selfenergy/__init__.py | 15 +- src/phelel/velph/cli/phelel/__init__.py | 214 +--------- src/phelel/velph/cli/phelel/cmd_phelel.py | 203 ++++++++++ src/phelel/velph/cli/phono3py/__init__.py | 85 +--- src/phelel/velph/cli/phono3py/cmd_phono3py.py | 86 ++++ src/phelel/velph/cli/phonopy/__init__.py | 70 +--- src/phelel/velph/cli/phonopy/cmd_phonopy.py | 71 ++++ src/phelel/velph/cli/relax/__init__.py | 45 +-- src/phelel/velph/cli/relax/cmd_relax.py | 48 +++ src/phelel/velph/cli/selfenergy/__init__.py | 12 +- src/phelel/velph/cli/transport/__init__.py | 12 +- .../velph/cli/transport/cmd_transport.py | 3 - 24 files changed, 1119 insertions(+), 1140 deletions(-) create mode 100644 src/phelel/velph/cli/el_bands/cmd_el_bands.py create mode 100644 src/phelel/velph/cli/generate/cmd_generate.py delete mode 100644 src/phelel/velph/cli/hints/__init__.py create mode 100644 src/phelel/velph/cli/init/cmd_init.py create mode 100644 src/phelel/velph/cli/nac/cmd_nac.py create mode 100644 src/phelel/velph/cli/ph_bands/cmd_ph_bands.py create mode 100644 src/phelel/velph/cli/phelel/cmd_phelel.py create mode 100644 src/phelel/velph/cli/phono3py/cmd_phono3py.py create mode 100644 src/phelel/velph/cli/phonopy/cmd_phonopy.py create mode 100644 src/phelel/velph/cli/relax/cmd_relax.py diff --git a/src/phelel/velph/cli/__init__.py b/src/phelel/velph/cli/__init__.py index 89a8fb8..e7c2d32 100644 --- a/src/phelel/velph/cli/__init__.py +++ b/src/phelel/velph/cli/__init__.py @@ -12,7 +12,6 @@ def cmd_root(): from phelel.velph.cli.el_bands import cmd_el_bands # noqa F401 from phelel.velph.cli.generate import cmd_generate # noqa F401 -from phelel.velph.cli.hints import cmd_hints # noqa F401 from phelel.velph.cli.init import cmd_init # noqa F401 from phelel.velph.cli.nac import cmd_nac # noqa F401 from phelel.velph.cli.ph_bands import cmd_ph_bands # noqa F401 @@ -27,7 +26,6 @@ def cmd_root(): __all__ = [ "cmd_el_bands", "cmd_generate", - "cmd_hints", "cmd_init", "cmd_nac", "cmd_phelel", diff --git a/src/phelel/velph/cli/el_bands/__init__.py b/src/phelel/velph/cli/el_bands/__init__.py index ff0a9df..30af4a0 100644 --- a/src/phelel/velph/cli/el_bands/__init__.py +++ b/src/phelel/velph/cli/el_bands/__init__.py @@ -1,106 +1,13 @@ """velph command line tool / velph-el_bands.""" -from __future__ import annotations - -import pathlib - -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.el_bands.generate import write_input_files -from phelel.velph.cli.el_bands.plot import plot_el_bandstructures -from phelel.velph.utils.plot_eigenvalues import ( - cmd_plot_eigenvalues, - eigenvalue_plot_options, -) - - -@cmd_root.group("el_bands") -@click.help_option("-h", "--help") -def cmd_el_bands(): - """Choose electronic band structure options.""" - pass - - -# -# velph el_bands generate -# -@cmd_el_bands.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate input files to plot electronic band structure.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_input_files(pathlib.Path(toml_filename)) - - -# -# velph el_bands plot -# -@cmd_el_bands.command("plot") -@click.option( - "--window", - required=True, - type=(float, float), - help="Energy window, emin and emax with respect to Fermi level.", +from phelel.velph.cli.el_bands.cmd_el_bands import ( + cmd_generate, # velph el_bands generate + cmd_plot, # velph el_bands plot + cmd_plot_eigenvalues, # velph el_bands plot_eigenvalues ) -@click.option( - "--save", - "save_plot", - is_flag=bool, - default=False, - help=("Save plot to file."), -) -@click.help_option("-h", "--help") -def cmd_plot(window: tuple[float, float], save_plot: bool): - """Plot electronic band structure.""" - vaspout_filename_bands = pathlib.Path("el_bands/bands/vaspout.h5") - vaspout_filename_dos = pathlib.Path("el_bands/dos/vaspout.h5") - if not vaspout_filename_bands.exists(): - click.echo(f'"{vaspout_filename_bands}" not found.') - if not vaspout_filename_dos.exists(): - click.echo(f'"{vaspout_filename_dos}" not found.') - - if vaspout_filename_bands.exists() and vaspout_filename_dos.exists(): - plot_el_bandstructures( - window, vaspout_filename_bands, vaspout_filename_dos, save_plot=save_plot - ) - - -@cmd_el_bands.command("plot_eigenvalues") -@click.argument( - "vaspout_filename", - nargs=1, - type=click.Path(), - default="el_bands/dos/vaspout.h5", -) -@eigenvalue_plot_options -def cmd_plot_transport_eigenvalues( - vaspout_filename: str, - temperature: float, - cutoff_occupancy: float, - mu: float | None, -): - """Show eigenvalues in transports.""" - cmd_plot_eigenvalues( - vaspout_filename, - temperature, - cutoff_occupancy, - mu, - None, - calc_type="el_bands", - ) - -def plot(window: tuple[float, float], save_plot: bool = False): - """Plot electronic band structure.""" - with click.Context(cmd_plot) as ctx: - ctx.params = {"window": window, "save_plot": save_plot} - cmd_plot.invoke(ctx) +__all__ = [ + "cmd_generate", + "cmd_plot", + "cmd_plot_eigenvalues", +] diff --git a/src/phelel/velph/cli/el_bands/cmd_el_bands.py b/src/phelel/velph/cli/el_bands/cmd_el_bands.py new file mode 100644 index 0000000..1daa833 --- /dev/null +++ b/src/phelel/velph/cli/el_bands/cmd_el_bands.py @@ -0,0 +1,100 @@ +"""velph command line tool / velph-el_bands.""" + +from __future__ import annotations + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.el_bands.generate import write_input_files +from phelel.velph.cli.el_bands.plot import plot_el_bandstructures +from phelel.velph.utils.plot_eigenvalues import ( + cmd_plot_eigenvalues, + eigenvalue_plot_options, +) + + +@cmd_root.group("el_bands") +@click.help_option("-h", "--help") +def cmd_el_bands(): + """Choose electronic band structure options.""" + pass + + +# +# velph el_bands generate +# +@cmd_el_bands.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate input files to plot electronic band structure.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_input_files(pathlib.Path(toml_filename)) + + +# +# velph el_bands plot +# +@cmd_el_bands.command("plot") +@click.option( + "--window", + required=True, + type=(float, float), + help="Energy window, emin and emax with respect to Fermi level.", +) +@click.option( + "--save", + "save_plot", + is_flag=bool, + default=False, + help=("Save plot to file."), +) +@click.help_option("-h", "--help") +def cmd_plot(window: tuple[float, float], save_plot: bool): + """Plot electronic band structure.""" + vaspout_filename_bands = pathlib.Path("el_bands/bands/vaspout.h5") + vaspout_filename_dos = pathlib.Path("el_bands/dos/vaspout.h5") + if not vaspout_filename_bands.exists(): + click.echo(f'"{vaspout_filename_bands}" not found.') + if not vaspout_filename_dos.exists(): + click.echo(f'"{vaspout_filename_dos}" not found.') + + if vaspout_filename_bands.exists() and vaspout_filename_dos.exists(): + plot_el_bandstructures( + window, vaspout_filename_bands, vaspout_filename_dos, save_plot=save_plot + ) + + +@cmd_el_bands.command("plot_eigenvalues") +@click.argument( + "vaspout_filename", + nargs=1, + type=click.Path(), + default="el_bands/dos/vaspout.h5", +) +@eigenvalue_plot_options +def cmd_plot_transport_eigenvalues( + vaspout_filename: str, + temperature: float, + cutoff_occupancy: float, + mu: float | None, +): + """Show eigenvalues in transports.""" + cmd_plot_eigenvalues( + vaspout_filename, + temperature, + cutoff_occupancy, + mu, + None, + None, + calc_type="el_bands", + ) diff --git a/src/phelel/velph/cli/generate/__init__.py b/src/phelel/velph/cli/generate/__init__.py index c34aa14..9d7955a 100644 --- a/src/phelel/velph/cli/generate/__init__.py +++ b/src/phelel/velph/cli/generate/__init__.py @@ -1,61 +1,5 @@ """velph command line tool / velph-generate.""" -import pathlib +from phelel.velph.cli.generate.cmd_generate import cmd_generate -import click -import tomli -from phonopy.interface.calculator import write_crystal_structure -from phonopy.structure.atoms import parse_cell_dict - -from phelel.velph.cli import cmd_root - - -# -# velph generate -# -@cmd_root.command("generate") -@click.option( - "-f", - "toml_filename", - nargs=1, - type=click.Path(exists=True), - default="velph.toml", - show_default=True, - help="Specify velph.toml", -) -@click.option( - "--prefix", - nargs=1, - type=click.Path(), - default="POSCAR", - show_default=True, - help="{prefix}-unitcell, {prefix}-primitive", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str, prefix: str): - """Write POSCAR-unitcell and POSCAR-primitive. - - Filename prefix "POSCAR" can be replaced using the "prefix" option. - - """ - _run_generate(toml_filename, prefix) - - -def _run_generate(toml_filename: str, prefix: str) -> None: - """Generate {prefix}-unitcell and {prefix}-primitive.""" - with open(toml_filename, "rb") as f: - toml_dict = tomli.load(f) - - filename = f"{prefix}-unitcell" - _write_cell(filename, toml_dict["unitcell"]) - if "primitive_cell" in toml_dict: - filename = f"{prefix}-primitive" - _write_cell(filename, toml_dict["primitive_cell"]) - - -def _write_cell(filename, toml_cell_dict): - if pathlib.Path(filename).exists(): - click.echo(f'"{filename}" was not overwritten because it exists.', err=True) - else: - write_crystal_structure(filename, parse_cell_dict(toml_cell_dict)) - click.echo(f'"{filename}" was generated.', err=True) +__all__ = ["cmd_generate"] diff --git a/src/phelel/velph/cli/generate/cmd_generate.py b/src/phelel/velph/cli/generate/cmd_generate.py new file mode 100644 index 0000000..9b88447 --- /dev/null +++ b/src/phelel/velph/cli/generate/cmd_generate.py @@ -0,0 +1,70 @@ +"""velph command line tool / velph-generate.""" + +from __future__ import annotations + +import pathlib + +import click +import tomli +from phonopy.interface.calculator import write_crystal_structure +from phonopy.structure.atoms import parse_cell_dict + +from phelel.velph.cli import cmd_root + + +# +# velph generate +# +@cmd_root.command("generate") +@click.option( + "-f", + "toml_filename", + nargs=1, + type=click.Path(exists=True), + default="velph.toml", + show_default=True, + help="Specify velph.toml", +) +@click.option( + "--prefix", + nargs=1, + type=click.Path(), + default="POSCAR", + show_default=True, + help="{prefix}-unitcell, {prefix}-primitive", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str, prefix: str): + """Write POSCAR-unitcell and POSCAR-primitive. + + Filename prefix "POSCAR" can be replaced using the "prefix" option. + + """ + _run_generate(toml_filename, prefix) + + +def _run_generate(toml_filename: str, prefix: str) -> None: + """Generate {prefix}-unitcell and {prefix}-primitive.""" + with open(toml_filename, "rb") as f: + toml_dict = tomli.load(f) + + filename = f"{prefix}-unitcell" + _write_cell(filename, toml_dict["unitcell"]) + if "primitive_cell" in toml_dict: + filename = f"{prefix}-primitive" + _write_cell(filename, toml_dict["primitive_cell"]) + + +def _write_cell(filename: str, toml_cell_dict: dict): + if pathlib.Path(filename).exists(): + click.echo(f'"{filename}" was not overwritten because it exists.', err=True) + else: + cell = parse_cell_dict(toml_cell_dict) + if cell is None: + click.echo( + f'"{filename}" was not generated because of invalid cell data.', + err=True, + ) + return + write_crystal_structure(filename, cell) + click.echo(f'"{filename}" was generated.') diff --git a/src/phelel/velph/cli/hints/__init__.py b/src/phelel/velph/cli/hints/__init__.py deleted file mode 100644 index 40ef6b3..0000000 --- a/src/phelel/velph/cli/hints/__init__.py +++ /dev/null @@ -1,100 +0,0 @@ -"""velph command line tool / velph-hints.""" - -import click - -from phelel.velph.cli import cmd_root - - -# -# velph hints -# -@cmd_root.command("hints") -def cmd_hints(): - """Show velph command hints.""" - _show_hints("velph.toml") - - -def _show_hints(toml_filename: str): - """Show hints.""" - click.echo( - "------------------------------- velph hints -------------------------------" - ) - click.echo('To see detailed options, "velph ... --help".') - click.echo("") - click.echo("# Initialization") - click.echo('1. "velph init --help": List velph-init options.') - click.echo(f'2. "velph init POSCAR_TYPE_FILE FOLDER": Generate "{toml_filename}".') - click.echo( - '3. "velph generate": Generate standardized unit cell and primitive cell.' - ) - click.echo("4. Confirm if space-group-type is the expected one.") - click.echo('5. Otherwise restart from step 1 using "--tolerance" option.') - click.echo("") - click.echo("# Unit cell relaxation (optional)") - click.echo(f'1. Modify [vasp.relax] section in "{toml_filename}".') - click.echo('2. "velph relax generate": Generate input files.') - click.echo("3. Run VASP.") - click.echo( - '4. Restart from # Initialization using "CONTCAR" then skip ' - "# Unit cell relaxation." - ) - click.echo() - click.echo("# Electronic band structure calculation") - click.echo(f'1. Modify [vasp.el_bands] sections in "{toml_filename}".') - click.echo( - '2. "velph el_bands generate": Generate input files for electronic band ' - "structure." - ) - click.echo("3. Run VASP in el_bands directories.") - click.echo( - '4. "velph el_bands plot --window -3 4" to plot the bands from Ef-3 to Ef+4' - ) - click.echo() - click.echo("# NAC calculation (optional)") - click.echo(f'1. Modify [vasp.nac] section in "{toml_filename}".') - click.echo('2. "velph nac generate": Generate input files.') - click.echo("3. Run VASP.") - click.echo() - click.echo("# Supercell calculation") - click.echo(f'1. Modify [vasp.phelel] section in "{toml_filename}".') - click.echo('2. "velph phelel init": Prepare finite displacement calculation. ') - click.echo(" NAC parameters are read when NAC calculation is available.") - click.echo('3. "velph phelel generate": Generate input files.') - click.echo("4. Run VASP.") - click.echo() - click.echo("# Phonon band structure calculation") - click.echo("Result of supercell calculation is necessary.") - click.echo(f'1. Modify [vasp.ph_bands] sections in "{toml_filename}".') - click.echo( - '2. "velph ph_bands generate": Generate input files for phononic band ' - "structure." - ) - click.echo("3. Run VASP in ph_bands directories.") - click.echo('4. "velph ph_bands plot" to plot the phonon bands') - click.echo() - click.echo("# Electron transport calculation") - click.echo(f'1. Write [vasp.transport] section in "{toml_filename}".') - click.echo('2. (optioanl) "velph transport generate": Dry-run to find FFT-mesh.') - click.echo("3. (optioanl) Run VASP.") - click.echo('4. (optioanl) "velph transport check-fft": Check FFT grid.') - click.echo('5. (optioanl) Modify "fft_mesh" in [phelel] section manually.') - click.echo('6. "velph supercell differentiate": Generate derivatives hdf5 file') - click.echo('7. "velph transport generate": Generate input files') - click.echo() - click.echo("# Electron self-energy calculation") - click.echo(f'1. Modify [vasp.selfenergy] section in "{toml_filename}".') - click.echo( - '2. (optional) "velph selfenergy generate -d": Dry-run to find FFT-mesh.' - ) - click.echo("3. (optional) Run VASP.") - click.echo('4. (optioanl) "velph selfenergy check-fft": Check FFT grid.') - click.echo('5. (optioanl) Modify "fft_mesh" in [phelel] section manually.') - click.echo('6. "velph phelel differentiate": Generate derivatives hdf5 file') - click.echo('7. "velph selfenergy generate": Generate input files') - click.echo() - click.echo("# Different supercell size for phonon") - click.echo('1. Write "supercell_dimension" in [phonopy] section and') - click.echo("2. Write [vasp.phelel.phonon.*] entry.") - click.echo( - "------------------------------- velph hints -------------------------------" - ) diff --git a/src/phelel/velph/cli/init/__init__.py b/src/phelel/velph/cli/init/__init__.py index 76286c1..1c2c73c 100644 --- a/src/phelel/velph/cli/init/__init__.py +++ b/src/phelel/velph/cli/init/__init__.py @@ -1,375 +1,5 @@ """velph command line tool / velph-init.""" -from __future__ import annotations +from phelel.velph.cli.init.cmd_init import cmd_init -import pathlib -import shutil -from typing import Literal - -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.init.init import run_init -from phelel.velph.cli.utils import ( - DefaultCellChoices, - DisplacementOptions, - PrimitiveCellChoice, - VelphFilePaths, - VelphInitOptions, - VelphInitParams, -) -from phelel.velph.utils.vasp import VaspPotcar - - -# -# velph init -# -@cmd_root.command("init") -@click.argument("cell_filename", nargs=1, type=click.Path()) -@click.argument("project_folder", nargs=1, type=click.Path()) -@click.option( - "--amplitude", - nargs=1, - type=float, - default=None, - help=( - "Distance of displacements in Angstrom. " - f"(amplitude: float, default={DisplacementOptions.amplitude})" - ), -) -@click.option( - "--cell-for-nac", - "cell_for_nac", - type=str, - default=None, - help=( - 'Cell choice for NAC, "primitive" or "unitcell" ' - f'(cell_for_nac: str, default="{DefaultCellChoices.nac.value}")' - ), -) -@click.option( - "--cell-for-relax", - "cell_for_relax", - type=str, - default=None, - help=( - 'Cell choice for relax, "primitive" or "unitcell" ' - f'(cell_for_relax: str, default="{DefaultCellChoices.relax.value}")' - ), -) -@click.option( - "--diagonal", - "diagonal", - type=bool, - default=None, - help=( - "Generate displacements in diagonal directions or only along axes." - f"(diagonal: bool, default={DisplacementOptions.diagonal})" - ), -) -@click.option( - "--dim", - "supercell_dimension", - nargs=3, - type=int, - default=None, - help=( - "Specify supercell dimensions by three integers like 2 2 2. " - "For specifiying nine integers, use --supercell-matrix. " - "This option is a shortcut for diagonal supercell matrix, where " - "three integers correspond to the diagonal elements. " - "(supercell_dimension: tuple[int, int, int], " - f"default={DisplacementOptions.supercell_matrix})" - ), -) -@click.option( - "--force", - "force_create", - is_flag=True, - default=None, - help="Create velph.toml even if it already exists.", -) -@click.option( - "--kspacing", - "kspacing", - nargs=1, - type=float, - default=None, - help=( - "Define k-point grid by KSPACING. " - f"(kspacing: float, default={VelphInitParams.kspacing})" - ), -) -@click.option( - "--kspacing-dense", - "kspacing_dense", - nargs=1, - type=float, - default=None, - help=( - "Define dense k-point grid by KSPACING_DENSE. " - f"(kspacing_dense: float, default={VelphInitParams.kspacing_dense})" - ), -) -@click.option( - "--magmom", - "magmom", - type=str, - default=None, - help=( - 'String corresponding to INCAR MAGMOM tag value, e.g., "24*1" or "0 0 1"' - f"(magmom: str, default={VelphInitParams.magmom})" - ), -) -@click.option( - "--max-num-atoms", - "max_num_atoms", - nargs=1, - default=None, - type=int, - help=( - "Determine supercell dimension so that number of atoms in supercell " - "is less than this number. This must be used with --symmmetrize-cell. " - f"(max_num_atoms: int, default={DisplacementOptions.max_num_atoms})" - ), -) -@click.option( - "--no-find-primitive", - "find_primitive", - is_flag=True, - flag_value=False, - default=None, - help=( - "Disable finding primitive cell in input cell. " - f"(find_primitive: bool, default={VelphInitParams.find_primitive})" - ), -) -@click.option( - "--phelel-nosym", - "phelel_nosym", - is_flag=True, - default=None, - help=( - 'Invoke "phelel --nosym". ' - f"(phelel_nosym: bool, default={VelphInitParams.phelel_nosym})" - ), -) -@click.option( - "--plusminus/--auto", - "plusminus", - type=bool, - default=None, - help=( - "Plus-minus displacements in supercell, otherwise auto. " - f"(plusminus: bool or 'auto', default={DisplacementOptions.plusminus})" - ), -) -@click.option( - "--primitive-cell-choice", - "primitive_cell_choice", - type=str, - default=None, - help=( - 'Primitive cell choice, "standardized" or "reduced" ' - "(primitive_cell_choice: str, " - f'default="{PrimitiveCellChoice.STANDARDIZED.value}")' - ), -) -@click.option( - "--supercell-matrix", - "supercell_matrix", - nargs=9, - type=int, - default=None, - help=( - "Specify supercell dimensions by nine integers like 0 2 2 2 0 2 2 2 0." - "(supercell_matrix: tuple[int, ...], " - f"default={DisplacementOptions.supercell_matrix})" - ), -) -@click.option( - "--symmetrize-cell", - "symmetrize_cell", - is_flag=True, - default=None, - help=( - "Symmetrize input crystal structure. " - f"(symmetrize_cell: bool, default={VelphInitParams.symmetrize_cell})" - ), -) -@click.option( - "--template-toml", - "template_toml_filename", - nargs=1, - type=click.Path(), - default=None, - help=( - "File name of template in toml to update velph.toml in python's " - "dict.update() style." - ), -) -@click.option( - "--tolerance", - "tolerance", - nargs=1, - type=float, - default=None, - help=( - "Tolerance to find crystal symmetry. " - f"(tolerance: float, default={VelphInitParams.tolerance})" - ), -) -@click.option( - "--toml-filename", - "toml_filename", - nargs=1, - type=click.Path(), - default=None, - help="File name of velph.toml type file to be created.", -) -@click.option( - "--use-grg", - "use_grg", - is_flag=True, - default=None, - help=( - "Use generalized regular grid when needed. " - f"(use_grg: bool, default={VelphInitParams.use_grg})" - ), -) -@click.help_option("-h", "--help") -def cmd_init( - amplitude: float | None, - cell_filename: str, - cell_for_nac: Literal["primitive", "unitcell"] | None, - cell_for_relax: Literal["primitive", "unitcell"] | None, - diagonal: bool | None, - find_primitive: bool | None, - force_create: bool | None, - kspacing: float | None, - kspacing_dense: float | None, - magmom: str | None, - max_num_atoms: int | None, - phelel_nosym: bool | None, - plusminus: bool | None, - primitive_cell_choice: Literal["standardized", "reduced"] | None, - project_folder: str, - supercell_dimension: tuple[int, int, int] | None, - supercell_matrix: tuple[int, int, int, int, int, int, int, int, int] | None, - symmetrize_cell: bool | None, - template_toml_filename: str | None, - toml_filename: str | None, - tolerance: float | None, - use_grg: bool | None, -): - """Initialize an electron phonon calculation project. - - Crystal structure (CELL_FILENAME) and new folder where new velph project - is created have to be specified as command-line arguments. - - Some command options can be specified in the [init.options] section of the - velph.toml-template file. Each option's key and its corresponding type are - indicated in parentheses within echo help documentation, for example, - - \b - [init.options] - kspacing = 0.2 - kspacing_dense = 0.1 - max_num_atoms = 120 - - """ # noqa: D301 - if not pathlib.Path(cell_filename).exists(): - click.echo(f'"{cell_filename}" not found.', err=True) - return - - if plusminus is True: - _plusminus = True - elif plusminus is False: - _plusminus = "auto" - else: - _plusminus = None - - vip_cmd_options = VelphInitOptions( - amplitude=amplitude, - cell_for_nac=cell_for_nac, - cell_for_relax=cell_for_relax, - diagonal=diagonal, - find_primitive=find_primitive, - kspacing=kspacing, - kspacing_dense=kspacing_dense, - magmom=magmom, - max_num_atoms=max_num_atoms, - phelel_nosym=phelel_nosym, - plusminus=_plusminus, - primitive_cell_choice=primitive_cell_choice, - supercell_dimension=supercell_dimension, - supercell_matrix=supercell_matrix, - symmetrize_cell=symmetrize_cell, - tolerance=tolerance, - use_grg=use_grg, - ) - - cell_filepath = pathlib.Path(cell_filename) - if cell_filepath.exists(): - vfp_dict = {"cell_filepath": cell_filepath} - else: - click.echo(f'"{cell_filename}" not found.', err=True) - return - - project_folder_path = pathlib.Path(project_folder) - if project_folder_path.exists(): - if project_folder_path.samefile(pathlib.Path()): - click.echo(f'Project directory: "{project_folder}".') - else: - click.echo(f'File or folder "{project_folder}" already exists.') - if not force_create: - return - - if template_toml_filename is not None: - velph_tmpl_filepath = pathlib.Path(template_toml_filename) - if velph_tmpl_filepath.exists(): - vfp_dict["velph_template_filepath"] = velph_tmpl_filepath - else: - click.echo(f'"{template_toml_filename}" not found.', err=True) - return - - if toml_filename is None: - toml_filepath = project_folder_path / "velph.toml" - else: - toml_filepath = project_folder_path / toml_filename - - if toml_filepath.exists(): - if force_create: - click.echo(f'"{toml_filepath}" exists, but will be overwritten.', err=True) - else: - click.echo( - f'"{toml_filepath}" was not overwritten because it exists.', err=True - ) - return - - vfp = VelphFilePaths(**vfp_dict) - toml_lines = run_init(vip_cmd_options, vfp) - - # Write velph.toml. - if toml_lines: - if not project_folder_path.exists(): - project_folder_path.mkdir() - click.echo(f'Created new folder "{project_folder}".') - with open(toml_filepath, "w") as w: - w.write("\n".join(toml_lines)) - w.write("\n") - click.echo(f'Initial settings were written to "{toml_filepath}".') - if pathlib.Path("POTCAR").exists(): - vasp_potcar = VaspPotcar("POTCAR") - click.echo('Found "POTCAR".') - for elem in vasp_potcar.titel: - print(f" {elem}") - enmax = max(vasp_potcar.enmax) - click.echo(f' Max ENMAX in "POTCAR" is {enmax}.') - if project_folder is not None: - if not (project_folder_path / "POTCAR").exists(): - shutil.copy2(pathlib.Path("POTCAR"), project_folder_path / "POTCAR") - click.echo(f'"POTCAR" was copied to "{project_folder}/POTCAR".') - else: - click.echo("") - click.echo(f'"{toml_filepath}" was not created.') +__all__ = ["cmd_init"] diff --git a/src/phelel/velph/cli/init/cmd_init.py b/src/phelel/velph/cli/init/cmd_init.py new file mode 100644 index 0000000..76286c1 --- /dev/null +++ b/src/phelel/velph/cli/init/cmd_init.py @@ -0,0 +1,375 @@ +"""velph command line tool / velph-init.""" + +from __future__ import annotations + +import pathlib +import shutil +from typing import Literal + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.init.init import run_init +from phelel.velph.cli.utils import ( + DefaultCellChoices, + DisplacementOptions, + PrimitiveCellChoice, + VelphFilePaths, + VelphInitOptions, + VelphInitParams, +) +from phelel.velph.utils.vasp import VaspPotcar + + +# +# velph init +# +@cmd_root.command("init") +@click.argument("cell_filename", nargs=1, type=click.Path()) +@click.argument("project_folder", nargs=1, type=click.Path()) +@click.option( + "--amplitude", + nargs=1, + type=float, + default=None, + help=( + "Distance of displacements in Angstrom. " + f"(amplitude: float, default={DisplacementOptions.amplitude})" + ), +) +@click.option( + "--cell-for-nac", + "cell_for_nac", + type=str, + default=None, + help=( + 'Cell choice for NAC, "primitive" or "unitcell" ' + f'(cell_for_nac: str, default="{DefaultCellChoices.nac.value}")' + ), +) +@click.option( + "--cell-for-relax", + "cell_for_relax", + type=str, + default=None, + help=( + 'Cell choice for relax, "primitive" or "unitcell" ' + f'(cell_for_relax: str, default="{DefaultCellChoices.relax.value}")' + ), +) +@click.option( + "--diagonal", + "diagonal", + type=bool, + default=None, + help=( + "Generate displacements in diagonal directions or only along axes." + f"(diagonal: bool, default={DisplacementOptions.diagonal})" + ), +) +@click.option( + "--dim", + "supercell_dimension", + nargs=3, + type=int, + default=None, + help=( + "Specify supercell dimensions by three integers like 2 2 2. " + "For specifiying nine integers, use --supercell-matrix. " + "This option is a shortcut for diagonal supercell matrix, where " + "three integers correspond to the diagonal elements. " + "(supercell_dimension: tuple[int, int, int], " + f"default={DisplacementOptions.supercell_matrix})" + ), +) +@click.option( + "--force", + "force_create", + is_flag=True, + default=None, + help="Create velph.toml even if it already exists.", +) +@click.option( + "--kspacing", + "kspacing", + nargs=1, + type=float, + default=None, + help=( + "Define k-point grid by KSPACING. " + f"(kspacing: float, default={VelphInitParams.kspacing})" + ), +) +@click.option( + "--kspacing-dense", + "kspacing_dense", + nargs=1, + type=float, + default=None, + help=( + "Define dense k-point grid by KSPACING_DENSE. " + f"(kspacing_dense: float, default={VelphInitParams.kspacing_dense})" + ), +) +@click.option( + "--magmom", + "magmom", + type=str, + default=None, + help=( + 'String corresponding to INCAR MAGMOM tag value, e.g., "24*1" or "0 0 1"' + f"(magmom: str, default={VelphInitParams.magmom})" + ), +) +@click.option( + "--max-num-atoms", + "max_num_atoms", + nargs=1, + default=None, + type=int, + help=( + "Determine supercell dimension so that number of atoms in supercell " + "is less than this number. This must be used with --symmmetrize-cell. " + f"(max_num_atoms: int, default={DisplacementOptions.max_num_atoms})" + ), +) +@click.option( + "--no-find-primitive", + "find_primitive", + is_flag=True, + flag_value=False, + default=None, + help=( + "Disable finding primitive cell in input cell. " + f"(find_primitive: bool, default={VelphInitParams.find_primitive})" + ), +) +@click.option( + "--phelel-nosym", + "phelel_nosym", + is_flag=True, + default=None, + help=( + 'Invoke "phelel --nosym". ' + f"(phelel_nosym: bool, default={VelphInitParams.phelel_nosym})" + ), +) +@click.option( + "--plusminus/--auto", + "plusminus", + type=bool, + default=None, + help=( + "Plus-minus displacements in supercell, otherwise auto. " + f"(plusminus: bool or 'auto', default={DisplacementOptions.plusminus})" + ), +) +@click.option( + "--primitive-cell-choice", + "primitive_cell_choice", + type=str, + default=None, + help=( + 'Primitive cell choice, "standardized" or "reduced" ' + "(primitive_cell_choice: str, " + f'default="{PrimitiveCellChoice.STANDARDIZED.value}")' + ), +) +@click.option( + "--supercell-matrix", + "supercell_matrix", + nargs=9, + type=int, + default=None, + help=( + "Specify supercell dimensions by nine integers like 0 2 2 2 0 2 2 2 0." + "(supercell_matrix: tuple[int, ...], " + f"default={DisplacementOptions.supercell_matrix})" + ), +) +@click.option( + "--symmetrize-cell", + "symmetrize_cell", + is_flag=True, + default=None, + help=( + "Symmetrize input crystal structure. " + f"(symmetrize_cell: bool, default={VelphInitParams.symmetrize_cell})" + ), +) +@click.option( + "--template-toml", + "template_toml_filename", + nargs=1, + type=click.Path(), + default=None, + help=( + "File name of template in toml to update velph.toml in python's " + "dict.update() style." + ), +) +@click.option( + "--tolerance", + "tolerance", + nargs=1, + type=float, + default=None, + help=( + "Tolerance to find crystal symmetry. " + f"(tolerance: float, default={VelphInitParams.tolerance})" + ), +) +@click.option( + "--toml-filename", + "toml_filename", + nargs=1, + type=click.Path(), + default=None, + help="File name of velph.toml type file to be created.", +) +@click.option( + "--use-grg", + "use_grg", + is_flag=True, + default=None, + help=( + "Use generalized regular grid when needed. " + f"(use_grg: bool, default={VelphInitParams.use_grg})" + ), +) +@click.help_option("-h", "--help") +def cmd_init( + amplitude: float | None, + cell_filename: str, + cell_for_nac: Literal["primitive", "unitcell"] | None, + cell_for_relax: Literal["primitive", "unitcell"] | None, + diagonal: bool | None, + find_primitive: bool | None, + force_create: bool | None, + kspacing: float | None, + kspacing_dense: float | None, + magmom: str | None, + max_num_atoms: int | None, + phelel_nosym: bool | None, + plusminus: bool | None, + primitive_cell_choice: Literal["standardized", "reduced"] | None, + project_folder: str, + supercell_dimension: tuple[int, int, int] | None, + supercell_matrix: tuple[int, int, int, int, int, int, int, int, int] | None, + symmetrize_cell: bool | None, + template_toml_filename: str | None, + toml_filename: str | None, + tolerance: float | None, + use_grg: bool | None, +): + """Initialize an electron phonon calculation project. + + Crystal structure (CELL_FILENAME) and new folder where new velph project + is created have to be specified as command-line arguments. + + Some command options can be specified in the [init.options] section of the + velph.toml-template file. Each option's key and its corresponding type are + indicated in parentheses within echo help documentation, for example, + + \b + [init.options] + kspacing = 0.2 + kspacing_dense = 0.1 + max_num_atoms = 120 + + """ # noqa: D301 + if not pathlib.Path(cell_filename).exists(): + click.echo(f'"{cell_filename}" not found.', err=True) + return + + if plusminus is True: + _plusminus = True + elif plusminus is False: + _plusminus = "auto" + else: + _plusminus = None + + vip_cmd_options = VelphInitOptions( + amplitude=amplitude, + cell_for_nac=cell_for_nac, + cell_for_relax=cell_for_relax, + diagonal=diagonal, + find_primitive=find_primitive, + kspacing=kspacing, + kspacing_dense=kspacing_dense, + magmom=magmom, + max_num_atoms=max_num_atoms, + phelel_nosym=phelel_nosym, + plusminus=_plusminus, + primitive_cell_choice=primitive_cell_choice, + supercell_dimension=supercell_dimension, + supercell_matrix=supercell_matrix, + symmetrize_cell=symmetrize_cell, + tolerance=tolerance, + use_grg=use_grg, + ) + + cell_filepath = pathlib.Path(cell_filename) + if cell_filepath.exists(): + vfp_dict = {"cell_filepath": cell_filepath} + else: + click.echo(f'"{cell_filename}" not found.', err=True) + return + + project_folder_path = pathlib.Path(project_folder) + if project_folder_path.exists(): + if project_folder_path.samefile(pathlib.Path()): + click.echo(f'Project directory: "{project_folder}".') + else: + click.echo(f'File or folder "{project_folder}" already exists.') + if not force_create: + return + + if template_toml_filename is not None: + velph_tmpl_filepath = pathlib.Path(template_toml_filename) + if velph_tmpl_filepath.exists(): + vfp_dict["velph_template_filepath"] = velph_tmpl_filepath + else: + click.echo(f'"{template_toml_filename}" not found.', err=True) + return + + if toml_filename is None: + toml_filepath = project_folder_path / "velph.toml" + else: + toml_filepath = project_folder_path / toml_filename + + if toml_filepath.exists(): + if force_create: + click.echo(f'"{toml_filepath}" exists, but will be overwritten.', err=True) + else: + click.echo( + f'"{toml_filepath}" was not overwritten because it exists.', err=True + ) + return + + vfp = VelphFilePaths(**vfp_dict) + toml_lines = run_init(vip_cmd_options, vfp) + + # Write velph.toml. + if toml_lines: + if not project_folder_path.exists(): + project_folder_path.mkdir() + click.echo(f'Created new folder "{project_folder}".') + with open(toml_filepath, "w") as w: + w.write("\n".join(toml_lines)) + w.write("\n") + click.echo(f'Initial settings were written to "{toml_filepath}".') + if pathlib.Path("POTCAR").exists(): + vasp_potcar = VaspPotcar("POTCAR") + click.echo('Found "POTCAR".') + for elem in vasp_potcar.titel: + print(f" {elem}") + enmax = max(vasp_potcar.enmax) + click.echo(f' Max ENMAX in "POTCAR" is {enmax}.') + if project_folder is not None: + if not (project_folder_path / "POTCAR").exists(): + shutil.copy2(pathlib.Path("POTCAR"), project_folder_path / "POTCAR") + click.echo(f'"POTCAR" was copied to "{project_folder}/POTCAR".') + else: + click.echo("") + click.echo(f'"{toml_filepath}" was not created.') diff --git a/src/phelel/velph/cli/nac/__init__.py b/src/phelel/velph/cli/nac/__init__.py index 6d1889f..c0c23c2 100644 --- a/src/phelel/velph/cli/nac/__init__.py +++ b/src/phelel/velph/cli/nac/__init__.py @@ -1,31 +1,5 @@ """velph command line tool / velph-nac.""" -import pathlib +from phelel.velph.cli.nac.cmd_nac import cmd_generate, cmd_nac -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.nac.generate import write_input_files - - -@cmd_root.group("nac") -@click.help_option("-h", "--help") -def cmd_nac(): - """Choose nac options.""" - pass - - -@cmd_nac.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate relax input files.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_input_files(pathlib.Path(toml_filename)) +__all__ = ["cmd_nac", "cmd_generate"] diff --git a/src/phelel/velph/cli/nac/cmd_nac.py b/src/phelel/velph/cli/nac/cmd_nac.py new file mode 100644 index 0000000..9570bab --- /dev/null +++ b/src/phelel/velph/cli/nac/cmd_nac.py @@ -0,0 +1,33 @@ +"""velph command line tool / velph-nac.""" + +from __future__ import annotations + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.nac.generate import write_input_files + + +@cmd_root.group("nac") +@click.help_option("-h", "--help") +def cmd_nac(): + """Choose nac options.""" + pass + + +@cmd_nac.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate relax input files.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_input_files(pathlib.Path(toml_filename)) diff --git a/src/phelel/velph/cli/ph_bands/__init__.py b/src/phelel/velph/cli/ph_bands/__init__.py index 7c8ca00..336002b 100644 --- a/src/phelel/velph/cli/ph_bands/__init__.py +++ b/src/phelel/velph/cli/ph_bands/__init__.py @@ -1,73 +1,5 @@ """velph command line tool / velph-ph_bands.""" -import pathlib +from phelel.velph.cli.ph_bands.cmd_ph_bands import cmd_generate, cmd_ph_bands, cmd_plot -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.ph_bands.generate import ( - write_input_files as write_input_files_ph_bandstructures, -) -from phelel.velph.cli.ph_bands.plot import plot_ph_bandstructures - - -@cmd_root.group("ph_bands") -@click.help_option("-h", "--help") -def cmd_ph_bands(): - """Choose phonon band structure options.""" - pass - - -# -# velph ph_bands generate -# -@cmd_ph_bands.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate input files to plot phonon band structure.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_input_files_ph_bandstructures(pathlib.Path(toml_filename)) - - -# -# velph ph_bands plot -# -@cmd_ph_bands.command("plot") -@click.option( - "--ordinary-frequency/--angular-frequency", - "use_ordinary_frequency", - type=bool, - default=False, - help=("Use ordinary frequency instead of angular frequency."), -) -@click.option( - "--save", - "save_plot", - is_flag=bool, - default=False, - help=("Save plot to file."), -) -@click.help_option("-h", "--help") -def cmd_plot(use_ordinary_frequency: bool, save_plot: bool): - """Plot phonon band structure.""" - vaspout_filename = pathlib.Path("ph_bands/bands/vaspout.h5") - if not vaspout_filename.exists(): - click.echo(f'"{vaspout_filename}" not found.') - plot_ph_bandstructures( - vaspout_filename, use_ordinary_frequency, save_plot=save_plot - ) - - -def plot(save_plot: bool = False): - """Plot phonon band structure.""" - with click.Context(cmd_plot) as ctx: - ctx.params = {"save_plot": save_plot} - cmd_plot.invoke(ctx) +__all__ = ["cmd_ph_bands", "cmd_generate", "cmd_plot"] diff --git a/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py b/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py new file mode 100644 index 0000000..30f979d --- /dev/null +++ b/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py @@ -0,0 +1,68 @@ +"""velph command line tool / velph-ph_bands.""" + +from __future__ import annotations + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.ph_bands.generate import ( + write_input_files as write_input_files_ph_bandstructures, +) +from phelel.velph.cli.ph_bands.plot import plot_ph_bandstructures + + +@cmd_root.group("ph_bands") +@click.help_option("-h", "--help") +def cmd_ph_bands(): + """Choose phonon band structure options.""" + pass + + +# +# velph ph_bands generate +# +@cmd_ph_bands.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate input files to plot phonon band structure.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_input_files_ph_bandstructures(pathlib.Path(toml_filename)) + + +# +# velph ph_bands plot +# +@cmd_ph_bands.command("plot") +@click.option( + "--ordinary-frequency/--angular-frequency", + "use_ordinary_frequency", + type=bool, + default=False, + help=("Use ordinary frequency instead of angular frequency."), +) +@click.option( + "--save", + "save_plot", + is_flag=bool, + default=False, + help=("Save plot to file."), +) +@click.help_option("-h", "--help") +def cmd_plot(use_ordinary_frequency: bool, save_plot: bool): + """Plot phonon band structure.""" + vaspout_filename = pathlib.Path("ph_bands/bands/vaspout.h5") + if not vaspout_filename.exists(): + click.echo(f'"{vaspout_filename}" not found.') + plot_ph_bandstructures( + vaspout_filename, use_ordinary_frequency, save_plot=save_plot + ) diff --git a/src/phelel/velph/cli/ph_selfenergy/__init__.py b/src/phelel/velph/cli/ph_selfenergy/__init__.py index 9177caf..9118371 100644 --- a/src/phelel/velph/cli/ph_selfenergy/__init__.py +++ b/src/phelel/velph/cli/ph_selfenergy/__init__.py @@ -1,10 +1,17 @@ """velph command line tool / velph-ph_selfenergy.""" from phelel.velph.cli.ph_selfenergy.cmd_ph_selfenergy import ( - cmd_check_fft, # noqa F401 : velph ph_selfenergy check-fft - cmd_generate, # noqa F401 : velph ph_selfenergy generate - cmd_ph_selfenergy, # noqa F401 : velph ph_selfenergy + cmd_check_fft, # velph ph_selfenergy check-fft + cmd_generate, # velph ph_selfenergy generate + cmd_ph_selfenergy, # velph ph_selfenergy ) from phelel.velph.cli.ph_selfenergy.plot import ( - cmd_plot, # noqa F401 : velph ph_selfenergy plot + cmd_plot, # velph ph_selfenergy plot ) + +__all__ = [ + "cmd_check_fft", + "cmd_generate", + "cmd_ph_selfenergy", + "cmd_plot", +] diff --git a/src/phelel/velph/cli/phelel/__init__.py b/src/phelel/velph/cli/phelel/__init__.py index 616ae14..4fecf22 100644 --- a/src/phelel/velph/cli/phelel/__init__.py +++ b/src/phelel/velph/cli/phelel/__init__.py @@ -1,203 +1,15 @@ """velph command line tool / velph-phelel.""" -from __future__ import annotations - -import pathlib - -import click -import tomli - -import phelel -from phelel.cui.phelel_script import finalize_phelel -from phelel.velph.cli import cmd_root -from phelel.velph.cli.phelel.differentiate import run_derivatives -from phelel.velph.cli.phelel.generate import write_supercell_input_files -from phelel.velph.cli.phelel.init import run_init -from phelel.velph.cli.phelel.phonopy import create_phonopy_yaml -from phelel.velph.utils.vasp import CutoffToFFTMesh - - -@cmd_root.group("phelel") -@click.help_option("-h", "--help") -def cmd_phelel(): - """Choose supercell options.""" - pass - - -# -# velph phelel init -# -@cmd_phelel.command("init") -@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") -@click.option( - "--dir-name", - "dir_name", - type=str, - default="phelel", - help=( - 'Used for backward compatibility, for which set "supercell". ' - '(dir_name: str, default="phelel")' - ), -) -@click.help_option("-h", "--help") -def cmd_init(toml_filename: str, dir_name: str): - """Generate displacements and write phelel_disp.yaml.""" - with open(toml_filename, "rb") as f: - toml_dict = tomli.load(f) - - phe = run_init(toml_dict) - - phelel_yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") - phelel_yaml_filename.parent.mkdir(parents=True, exist_ok=True) - finalize_phelel( - phe, - displacements_mode=True, - filename=phelel_yaml_filename, - sys_exit_after_finalize=False, - ) - - click.echo(f'"{phelel_yaml_filename}" was generated. ') - click.echo('VASP input files will be generated by "velph phelel generate".') - - -# -# velph phelel generate -# -@cmd_phelel.command("generate") -@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") -@click.option( - "--dir-name", - "dir_name", - type=str, - default="phelel", - help=( - 'Used for backward compatibility, for which set "supercell". ' - '(phelel_dirname: str, default="phelel")' - ), -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str, dir_name: str): - """Generate phelel input files.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") - write_supercell_input_files( - pathlib.Path(toml_filename), yaml_filename, dir_name=dir_name - ) - - -# -# velph supercell differentiate -# -@cmd_phelel.command("differentiate") -@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") -@click.option( - "--dir-name", - "dir_name", - type=str, - default="phelel", - help=( - 'Used for backward compatibility, for which set "supercell". ' - '(phelel_dirname: str, default="phelel")' - ), -) -@click.option( - "--encut", - nargs=1, - type=float, - default=None, - help=( - "Cutoff energy corresponding to FFT mesh of local potential grid. " - "(encut: float, default=None)" - ), -) -@click.option( - "-v", - "verbose", - is_flag=True, - default=False, - help=("More information will be printed."), -) -@click.help_option("-h", "--help") -def cmd_differentiate( - toml_filename: str, - encut: float | None, - dir_name: str, - verbose: bool, -) -> None: - """Calculate derivatives and write phelel_params.hdf5.""" - hdf5_filename = pathlib.Path(f"{dir_name}/phelel_params.hdf5") - yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") - - with open(toml_filename, "rb") as f: - toml_dict = tomli.load(f) - - if "phelel" not in toml_dict or "fft_mesh" not in toml_dict["phelel"]: - click.echo('"fft_mesh" has to be specified in [phelel] section.', err=True) - return None - - is_symmetry = True - try: - if toml_dict["phelel"]["nosym"] is True: - click.echo( - 'Found "nosym = true" in [phelel] section. ' - "Symmetrization is turned off." - ) - is_symmetry = False - except KeyError: - pass - - phe = phelel.load( - yaml_filename, - fft_mesh=toml_dict["phelel"]["fft_mesh"], - is_symmetry=is_symmetry, - ) - - if encut is not None: - try: - prec = toml_dict["vasp"]["selfenergy"]["incar"]["prec"] - except KeyError: - click.echo(f'[vasp.selfenergy.incar] not found in "{toml_filename}".') - click.echo('prec = "accurate" is assumed.') - prec = "accurate" - click.echo(f"FFT mesh is generated for encut={encut}.") - phe.fft_mesh = CutoffToFFTMesh.get_FFTMesh(encut, phe.primitive.cell, prec) - - if phe.fft_mesh is None: - click.echo("FFT mesh is not specified.", err=True) - else: - if encut is None: - click.echo(f"FFT mesh: {phe.fft_mesh}.") - else: - click.echo(f"FFT mesh: {phe.fft_mesh} (encut={encut}).") - - if run_derivatives(phe, dir_name=dir_name, verbose=verbose): - pathlib.Path(hdf5_filename).parent.mkdir(parents=True, exist_ok=True) - phe.save_hdf5(filename=hdf5_filename) - click.echo(f'"{hdf5_filename}" has been made.') - - -# -# velph phelel phonopy -# -@cmd_phelel.command("phonopy") -@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") -@click.option( - "--dir-name", - "dir_name", - type=str, - default="phelel", - help=( - 'Used for backward compatibility, for which set "supercell". ' - '(phelel_dirname: str, default="phelel")' - ), -) -@click.help_option("-h", "--help") -def cmd_phonopy(toml_filename: str, dir_name: str): - """Create phonopy_params.yaml.""" - create_phonopy_yaml( - pathlib.Path(toml_filename), - pathlib.Path(f"{dir_name}/phelel_disp.yaml"), - dir_name=dir_name, - ) +from phelel.velph.cli.phelel.cmd_phelel import ( + cmd_differentiate, # velph phelel differentiate + cmd_generate, # velph phelel generate + cmd_init, # velph phelel init + cmd_phonopy, # velph phelel phonopy +) + +__all__ = [ + "cmd_differentiate", + "cmd_generate", + "cmd_init", + "cmd_phonopy", +] diff --git a/src/phelel/velph/cli/phelel/cmd_phelel.py b/src/phelel/velph/cli/phelel/cmd_phelel.py new file mode 100644 index 0000000..616ae14 --- /dev/null +++ b/src/phelel/velph/cli/phelel/cmd_phelel.py @@ -0,0 +1,203 @@ +"""velph command line tool / velph-phelel.""" + +from __future__ import annotations + +import pathlib + +import click +import tomli + +import phelel +from phelel.cui.phelel_script import finalize_phelel +from phelel.velph.cli import cmd_root +from phelel.velph.cli.phelel.differentiate import run_derivatives +from phelel.velph.cli.phelel.generate import write_supercell_input_files +from phelel.velph.cli.phelel.init import run_init +from phelel.velph.cli.phelel.phonopy import create_phonopy_yaml +from phelel.velph.utils.vasp import CutoffToFFTMesh + + +@cmd_root.group("phelel") +@click.help_option("-h", "--help") +def cmd_phelel(): + """Choose supercell options.""" + pass + + +# +# velph phelel init +# +@cmd_phelel.command("init") +@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") +@click.option( + "--dir-name", + "dir_name", + type=str, + default="phelel", + help=( + 'Used for backward compatibility, for which set "supercell". ' + '(dir_name: str, default="phelel")' + ), +) +@click.help_option("-h", "--help") +def cmd_init(toml_filename: str, dir_name: str): + """Generate displacements and write phelel_disp.yaml.""" + with open(toml_filename, "rb") as f: + toml_dict = tomli.load(f) + + phe = run_init(toml_dict) + + phelel_yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") + phelel_yaml_filename.parent.mkdir(parents=True, exist_ok=True) + finalize_phelel( + phe, + displacements_mode=True, + filename=phelel_yaml_filename, + sys_exit_after_finalize=False, + ) + + click.echo(f'"{phelel_yaml_filename}" was generated. ') + click.echo('VASP input files will be generated by "velph phelel generate".') + + +# +# velph phelel generate +# +@cmd_phelel.command("generate") +@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") +@click.option( + "--dir-name", + "dir_name", + type=str, + default="phelel", + help=( + 'Used for backward compatibility, for which set "supercell". ' + '(phelel_dirname: str, default="phelel")' + ), +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str, dir_name: str): + """Generate phelel input files.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") + write_supercell_input_files( + pathlib.Path(toml_filename), yaml_filename, dir_name=dir_name + ) + + +# +# velph supercell differentiate +# +@cmd_phelel.command("differentiate") +@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") +@click.option( + "--dir-name", + "dir_name", + type=str, + default="phelel", + help=( + 'Used for backward compatibility, for which set "supercell". ' + '(phelel_dirname: str, default="phelel")' + ), +) +@click.option( + "--encut", + nargs=1, + type=float, + default=None, + help=( + "Cutoff energy corresponding to FFT mesh of local potential grid. " + "(encut: float, default=None)" + ), +) +@click.option( + "-v", + "verbose", + is_flag=True, + default=False, + help=("More information will be printed."), +) +@click.help_option("-h", "--help") +def cmd_differentiate( + toml_filename: str, + encut: float | None, + dir_name: str, + verbose: bool, +) -> None: + """Calculate derivatives and write phelel_params.hdf5.""" + hdf5_filename = pathlib.Path(f"{dir_name}/phelel_params.hdf5") + yaml_filename = pathlib.Path(f"{dir_name}/phelel_disp.yaml") + + with open(toml_filename, "rb") as f: + toml_dict = tomli.load(f) + + if "phelel" not in toml_dict or "fft_mesh" not in toml_dict["phelel"]: + click.echo('"fft_mesh" has to be specified in [phelel] section.', err=True) + return None + + is_symmetry = True + try: + if toml_dict["phelel"]["nosym"] is True: + click.echo( + 'Found "nosym = true" in [phelel] section. ' + "Symmetrization is turned off." + ) + is_symmetry = False + except KeyError: + pass + + phe = phelel.load( + yaml_filename, + fft_mesh=toml_dict["phelel"]["fft_mesh"], + is_symmetry=is_symmetry, + ) + + if encut is not None: + try: + prec = toml_dict["vasp"]["selfenergy"]["incar"]["prec"] + except KeyError: + click.echo(f'[vasp.selfenergy.incar] not found in "{toml_filename}".') + click.echo('prec = "accurate" is assumed.') + prec = "accurate" + click.echo(f"FFT mesh is generated for encut={encut}.") + phe.fft_mesh = CutoffToFFTMesh.get_FFTMesh(encut, phe.primitive.cell, prec) + + if phe.fft_mesh is None: + click.echo("FFT mesh is not specified.", err=True) + else: + if encut is None: + click.echo(f"FFT mesh: {phe.fft_mesh}.") + else: + click.echo(f"FFT mesh: {phe.fft_mesh} (encut={encut}).") + + if run_derivatives(phe, dir_name=dir_name, verbose=verbose): + pathlib.Path(hdf5_filename).parent.mkdir(parents=True, exist_ok=True) + phe.save_hdf5(filename=hdf5_filename) + click.echo(f'"{hdf5_filename}" has been made.') + + +# +# velph phelel phonopy +# +@cmd_phelel.command("phonopy") +@click.argument("toml_filename", nargs=1, type=click.Path(), default="velph.toml") +@click.option( + "--dir-name", + "dir_name", + type=str, + default="phelel", + help=( + 'Used for backward compatibility, for which set "supercell". ' + '(phelel_dirname: str, default="phelel")' + ), +) +@click.help_option("-h", "--help") +def cmd_phonopy(toml_filename: str, dir_name: str): + """Create phonopy_params.yaml.""" + create_phonopy_yaml( + pathlib.Path(toml_filename), + pathlib.Path(f"{dir_name}/phelel_disp.yaml"), + dir_name=dir_name, + ) diff --git a/src/phelel/velph/cli/phono3py/__init__.py b/src/phelel/velph/cli/phono3py/__init__.py index c9006dc..645df7f 100644 --- a/src/phelel/velph/cli/phono3py/__init__.py +++ b/src/phelel/velph/cli/phono3py/__init__.py @@ -1,86 +1,5 @@ """velph command line tool / velph-phono3py.""" -from __future__ import annotations +from phelel.velph.cli.phono3py.cmd_phono3py import cmd_generate, cmd_init, cmd_phono3py -import pathlib -from typing import Optional - -import click -import tomli - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.phono3py.generate import write_supercell_input_files -from phelel.velph.cli.phono3py.init import run_init - - -@cmd_root.group("phono3py") -@click.help_option("-h", "--help") -def cmd_phono3py(): - """Choose phono3py options.""" - pass - - -# -# velph phono3py init -# -@cmd_phono3py.command("init") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.option( - "--rd", - "random_displacements", - nargs=1, - default=None, - type=int, - help="Number of snapshots of supercells with random directional displacement.", -) -@click.help_option("-h", "--help") -def cmd_init( - toml_filename: str, - random_displacements: Optional[int], -): - """Generate displacements and write phono3py_disp.yaml.""" - with open(toml_filename, "rb") as f: - toml_dict = tomli.load(f) - - if "phono3py" not in toml_dict: - click.echo(f'[phono3py] section not found in "{toml_filename}" file.', err=True) - return - - ph3 = run_init( - toml_dict, - number_of_snapshots=random_displacements, - ) - - phono3py_yaml_filename = pathlib.Path("phono3py/phono3py_disp.yaml") - phono3py_yaml_filename.parent.mkdir(parents=True, exist_ok=True) - ph3.save(phono3py_yaml_filename) - - click.echo(f'"{phono3py_yaml_filename}" was generated. ') - click.echo('VASP input files will be generated by "velph phono3py generate".') - - -# -# velph phono3py generate -# -@cmd_phono3py.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate phono3py input files.""" - yaml_filename = "phono3py/phono3py_disp.yaml" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_supercell_input_files( - pathlib.Path(toml_filename), pathlib.Path(yaml_filename) - ) +__all__ = ["cmd_phono3py", "cmd_init", "cmd_generate"] diff --git a/src/phelel/velph/cli/phono3py/cmd_phono3py.py b/src/phelel/velph/cli/phono3py/cmd_phono3py.py new file mode 100644 index 0000000..c9006dc --- /dev/null +++ b/src/phelel/velph/cli/phono3py/cmd_phono3py.py @@ -0,0 +1,86 @@ +"""velph command line tool / velph-phono3py.""" + +from __future__ import annotations + +import pathlib +from typing import Optional + +import click +import tomli + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.phono3py.generate import write_supercell_input_files +from phelel.velph.cli.phono3py.init import run_init + + +@cmd_root.group("phono3py") +@click.help_option("-h", "--help") +def cmd_phono3py(): + """Choose phono3py options.""" + pass + + +# +# velph phono3py init +# +@cmd_phono3py.command("init") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.option( + "--rd", + "random_displacements", + nargs=1, + default=None, + type=int, + help="Number of snapshots of supercells with random directional displacement.", +) +@click.help_option("-h", "--help") +def cmd_init( + toml_filename: str, + random_displacements: Optional[int], +): + """Generate displacements and write phono3py_disp.yaml.""" + with open(toml_filename, "rb") as f: + toml_dict = tomli.load(f) + + if "phono3py" not in toml_dict: + click.echo(f'[phono3py] section not found in "{toml_filename}" file.', err=True) + return + + ph3 = run_init( + toml_dict, + number_of_snapshots=random_displacements, + ) + + phono3py_yaml_filename = pathlib.Path("phono3py/phono3py_disp.yaml") + phono3py_yaml_filename.parent.mkdir(parents=True, exist_ok=True) + ph3.save(phono3py_yaml_filename) + + click.echo(f'"{phono3py_yaml_filename}" was generated. ') + click.echo('VASP input files will be generated by "velph phono3py generate".') + + +# +# velph phono3py generate +# +@cmd_phono3py.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate phono3py input files.""" + yaml_filename = "phono3py/phono3py_disp.yaml" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_supercell_input_files( + pathlib.Path(toml_filename), pathlib.Path(yaml_filename) + ) diff --git a/src/phelel/velph/cli/phonopy/__init__.py b/src/phelel/velph/cli/phonopy/__init__.py index 5a5fe65..185ca25 100644 --- a/src/phelel/velph/cli/phonopy/__init__.py +++ b/src/phelel/velph/cli/phonopy/__init__.py @@ -1,71 +1,5 @@ """velph command line tool / velph-phonopy.""" -from __future__ import annotations +from phelel.velph.cli.phonopy.cmd_phonopy import cmd_generate, cmd_init, cmd_phonopy -import pathlib - -import click -import tomli - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.phonopy.generate import write_supercell_input_files -from phelel.velph.cli.phonopy.init import run_init - - -@cmd_root.group("phonopy") -@click.help_option("-h", "--help") -def cmd_phonopy(): - """Choose phonopy options.""" - pass - - -# -# velph phonopy init -# -@cmd_phonopy.command("init") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_init(toml_filename: str): - """Generate displacements and write phonopy_disp.yaml.""" - with open(toml_filename, "rb") as f: - toml_dict = tomli.load(f) - - if "phonopy" not in toml_dict: - click.echo(f'[phonopy] section not found in "{toml_filename}" file.', err=True) - return - - ph = run_init(toml_dict) - - phonopy_yaml_filename = pathlib.Path("phonopy/phonopy_disp.yaml") - phonopy_yaml_filename.parent.mkdir(parents=True, exist_ok=True) - ph.save(phonopy_yaml_filename) - - click.echo(f'"{phonopy_yaml_filename}" was generated. ') - click.echo('VASP input files will be generated by "velph phonopy generate".') - - -# -# velph phonopy generate -# -@cmd_phonopy.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate phonopy input files.""" - yaml_filename = "phonopy/phonopy_disp.yaml" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - write_supercell_input_files( - pathlib.Path(toml_filename), pathlib.Path(yaml_filename) - ) +__all__ = ["cmd_phonopy", "cmd_init", "cmd_generate"] diff --git a/src/phelel/velph/cli/phonopy/cmd_phonopy.py b/src/phelel/velph/cli/phonopy/cmd_phonopy.py new file mode 100644 index 0000000..5a5fe65 --- /dev/null +++ b/src/phelel/velph/cli/phonopy/cmd_phonopy.py @@ -0,0 +1,71 @@ +"""velph command line tool / velph-phonopy.""" + +from __future__ import annotations + +import pathlib + +import click +import tomli + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.phonopy.generate import write_supercell_input_files +from phelel.velph.cli.phonopy.init import run_init + + +@cmd_root.group("phonopy") +@click.help_option("-h", "--help") +def cmd_phonopy(): + """Choose phonopy options.""" + pass + + +# +# velph phonopy init +# +@cmd_phonopy.command("init") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_init(toml_filename: str): + """Generate displacements and write phonopy_disp.yaml.""" + with open(toml_filename, "rb") as f: + toml_dict = tomli.load(f) + + if "phonopy" not in toml_dict: + click.echo(f'[phonopy] section not found in "{toml_filename}" file.', err=True) + return + + ph = run_init(toml_dict) + + phonopy_yaml_filename = pathlib.Path("phonopy/phonopy_disp.yaml") + phonopy_yaml_filename.parent.mkdir(parents=True, exist_ok=True) + ph.save(phonopy_yaml_filename) + + click.echo(f'"{phonopy_yaml_filename}" was generated. ') + click.echo('VASP input files will be generated by "velph phonopy generate".') + + +# +# velph phonopy generate +# +@cmd_phonopy.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate phonopy input files.""" + yaml_filename = "phonopy/phonopy_disp.yaml" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + write_supercell_input_files( + pathlib.Path(toml_filename), pathlib.Path(yaml_filename) + ) diff --git a/src/phelel/velph/cli/relax/__init__.py b/src/phelel/velph/cli/relax/__init__.py index 603b8d2..66e941e 100644 --- a/src/phelel/velph/cli/relax/__init__.py +++ b/src/phelel/velph/cli/relax/__init__.py @@ -1,46 +1,5 @@ """velph command line tool / velph-relax.""" -import pathlib +from phelel.velph.cli.relax.cmd_relax import cmd_generate, cmd_relax -import click - -from phelel.velph.cli import cmd_root -from phelel.velph.cli.relax.generate import write_input_files - - -@cmd_root.group("relax") -@click.help_option("-h", "--help") -def cmd_relax(): - """Choose relax options.""" - pass - - -@cmd_relax.command("generate") -@click.argument( - "toml_filename", - nargs=1, - type=click.Path(), - default="velph.toml", -) -@click.help_option("-h", "--help") -def cmd_generate(toml_filename: str): - """Generate relax input files.""" - if not pathlib.Path("POTCAR").exists(): - click.echo('"POTCAR" not found in current directory.') - - if not pathlib.Path(toml_filename).exists(): - click.echo(f'"{toml_filename}" not found.', err=True) - return None - - prev_directory = None - for i in range(1, 101): - directory = pathlib.Path(f"relax/iter{i}") - if directory.exists(): - click.echo(f'"{directory}" exists.') - else: - break - prev_directory = directory - - write_input_files( - pathlib.Path(toml_filename), directory, prev_directory=prev_directory - ) +__all__ = ["cmd_relax", "cmd_generate"] diff --git a/src/phelel/velph/cli/relax/cmd_relax.py b/src/phelel/velph/cli/relax/cmd_relax.py new file mode 100644 index 0000000..81454b0 --- /dev/null +++ b/src/phelel/velph/cli/relax/cmd_relax.py @@ -0,0 +1,48 @@ +"""velph command line tool / velph-relax.""" + +from __future__ import annotations + +import pathlib + +import click + +from phelel.velph.cli import cmd_root +from phelel.velph.cli.relax.generate import write_input_files + + +@cmd_root.group("relax") +@click.help_option("-h", "--help") +def cmd_relax(): + """Choose relax options.""" + pass + + +@cmd_relax.command("generate") +@click.argument( + "toml_filename", + nargs=1, + type=click.Path(), + default="velph.toml", +) +@click.help_option("-h", "--help") +def cmd_generate(toml_filename: str): + """Generate relax input files.""" + if not pathlib.Path("POTCAR").exists(): + click.echo('"POTCAR" not found in current directory.') + + if not pathlib.Path(toml_filename).exists(): + click.echo(f'"{toml_filename}" not found.', err=True) + return None + + prev_directory = None + for i in range(1, 101): + directory = pathlib.Path(f"relax/iter{i}") + if directory.exists(): + click.echo(f'"{directory}" exists.') + else: + break + prev_directory = directory + + write_input_files( + pathlib.Path(toml_filename), directory, prev_directory=prev_directory + ) diff --git a/src/phelel/velph/cli/selfenergy/__init__.py b/src/phelel/velph/cli/selfenergy/__init__.py index 2f89d56..0a527f4 100644 --- a/src/phelel/velph/cli/selfenergy/__init__.py +++ b/src/phelel/velph/cli/selfenergy/__init__.py @@ -1,7 +1,13 @@ """velph command line tool / velph-selfenergy.""" from phelel.velph.cli.selfenergy.cmd_selfenergy import ( - cmd_check_fft, # noqa F401 : velph selfenergy check-fft - cmd_generate, # noqa F401 : velph selfenergy generate - cmd_selfenergy, # noqa F401 : velph selfenergy + cmd_check_fft, # velph selfenergy check-fft + cmd_generate, # velph selfenergy generate + cmd_selfenergy, # velph selfenergy ) + +__all__ = [ + "cmd_check_fft", + "cmd_generate", + "cmd_selfenergy", +] diff --git a/src/phelel/velph/cli/transport/__init__.py b/src/phelel/velph/cli/transport/__init__.py index 648e6a8..fed8fb8 100644 --- a/src/phelel/velph/cli/transport/__init__.py +++ b/src/phelel/velph/cli/transport/__init__.py @@ -1,9 +1,15 @@ """velph command line tool / velph-transport.""" from phelel.velph.cli.transport.cmd_transport import ( - cmd_check_fft, # noqa F401 : velph transport check-fft - cmd_generate, # noqa F401 : velph transport generate + cmd_check_fft, # velph transport check-fft + cmd_generate, # velph transport generate ) from phelel.velph.cli.transport.plot import ( - cmd_plot, # noqa F401 : velph transport plot + cmd_plot, # velph transport plot ) + +__all__ = [ + "cmd_check_fft", + "cmd_generate", + "cmd_plot", +] diff --git a/src/phelel/velph/cli/transport/cmd_transport.py b/src/phelel/velph/cli/transport/cmd_transport.py index 434facb..328fa0d 100644 --- a/src/phelel/velph/cli/transport/cmd_transport.py +++ b/src/phelel/velph/cli/transport/cmd_transport.py @@ -51,6 +51,3 @@ def cmd_generate(toml_filename: str, dry_run: bool): def cmd_check_fft(toml_filename: str): """Show [NGX, NGY, NGZ] in vasprun.xml.""" check_fft(toml_filename, "transport") - - -from phelel.velph.cli.transport.plot import cmd_plot # noqa F401 From feda9e48e0973917f9d8abde0052707c9a57276c Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 22 Feb 2026 17:24:58 +0900 Subject: [PATCH 3/4] Refactor velph --- src/phelel/velph/__init__.py | 5 -- src/phelel/velph/cli/__init__.py | 60 ++++++++----------- src/phelel/velph/cli/cmd_root.py | 10 ++++ src/phelel/velph/cli/el_bands/__init__.py | 13 ---- src/phelel/velph/cli/generate/__init__.py | 5 -- src/phelel/velph/cli/init/__init__.py | 5 -- src/phelel/velph/cli/nac/__init__.py | 5 -- src/phelel/velph/cli/ph_bands/__init__.py | 5 -- .../velph/cli/ph_selfenergy/__init__.py | 17 ------ src/phelel/velph/cli/phelel/__init__.py | 15 ----- src/phelel/velph/cli/phono3py/__init__.py | 5 -- src/phelel/velph/cli/phonopy/__init__.py | 5 -- src/phelel/velph/cli/relax/__init__.py | 5 -- src/phelel/velph/cli/selfenergy/__init__.py | 13 ---- src/phelel/velph/cli/transport/__init__.py | 15 ----- 15 files changed, 36 insertions(+), 147 deletions(-) delete mode 100644 src/phelel/velph/__init__.py create mode 100644 src/phelel/velph/cli/cmd_root.py delete mode 100644 src/phelel/velph/cli/el_bands/__init__.py delete mode 100644 src/phelel/velph/cli/generate/__init__.py delete mode 100644 src/phelel/velph/cli/init/__init__.py delete mode 100644 src/phelel/velph/cli/nac/__init__.py delete mode 100644 src/phelel/velph/cli/ph_bands/__init__.py delete mode 100644 src/phelel/velph/cli/ph_selfenergy/__init__.py delete mode 100644 src/phelel/velph/cli/phelel/__init__.py delete mode 100644 src/phelel/velph/cli/phono3py/__init__.py delete mode 100644 src/phelel/velph/cli/phonopy/__init__.py delete mode 100644 src/phelel/velph/cli/relax/__init__.py delete mode 100644 src/phelel/velph/cli/selfenergy/__init__.py delete mode 100644 src/phelel/velph/cli/transport/__init__.py diff --git a/src/phelel/velph/__init__.py b/src/phelel/velph/__init__.py deleted file mode 100644 index a3086b0..0000000 --- a/src/phelel/velph/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph module.""" - -from phelel.velph import cli, templates, utils - -__all__ = ["cli", "templates", "utils"] diff --git a/src/phelel/velph/cli/__init__.py b/src/phelel/velph/cli/__init__.py index e7c2d32..5b1a16f 100644 --- a/src/phelel/velph/cli/__init__.py +++ b/src/phelel/velph/cli/__init__.py @@ -1,39 +1,31 @@ """velph command line tool module.""" -import click - - -@click.group() -@click.help_option("-h", "--help") -def cmd_root(): - """Command-line utility to help VASP el-ph calculation.""" - pass - - -from phelel.velph.cli.el_bands import cmd_el_bands # noqa F401 -from phelel.velph.cli.generate import cmd_generate # noqa F401 -from phelel.velph.cli.init import cmd_init # noqa F401 -from phelel.velph.cli.nac import cmd_nac # noqa F401 -from phelel.velph.cli.ph_bands import cmd_ph_bands # noqa F401 -from phelel.velph.cli.ph_selfenergy import cmd_ph_selfenergy # noqa F401 -from phelel.velph.cli.phelel import cmd_phelel # noqa F401 -from phelel.velph.cli.phono3py import cmd_phono3py # noqa F401 -from phelel.velph.cli.phonopy import cmd_phonopy # noqa F401 -from phelel.velph.cli.relax import cmd_relax # noqa F401 -from phelel.velph.cli.selfenergy import cmd_selfenergy # noqa F401 -from phelel.velph.cli.transport import cmd_transport # noqa F401 +from phelel.velph.cli.cmd_root import cmd_root +from phelel.velph.cli.el_bands.cmd_el_bands import cmd_el_bands +from phelel.velph.cli.generate.cmd_generate import cmd_generate +from phelel.velph.cli.init.cmd_init import cmd_init +from phelel.velph.cli.nac.cmd_nac import cmd_nac +from phelel.velph.cli.ph_bands.cmd_ph_bands import cmd_ph_bands +from phelel.velph.cli.ph_selfenergy.cmd_ph_selfenergy import cmd_ph_selfenergy +from phelel.velph.cli.phelel.cmd_phelel import cmd_phelel +from phelel.velph.cli.phono3py.cmd_phono3py import cmd_phono3py +from phelel.velph.cli.phonopy.cmd_phonopy import cmd_phonopy +from phelel.velph.cli.relax.cmd_relax import cmd_relax +from phelel.velph.cli.selfenergy.cmd_selfenergy import cmd_selfenergy +from phelel.velph.cli.transport.cmd_transport import cmd_transport __all__ = [ - "cmd_el_bands", - "cmd_generate", - "cmd_init", - "cmd_nac", - "cmd_phelel", - "cmd_phonopy", - "cmd_phono3py", - "cmd_ph_bands", - "cmd_ph_selfenergy", - "cmd_relax", - "cmd_selfenergy", - "cmd_transport", + "cmd_el_bands", # velph el-bands + "cmd_generate", # velph generate + "cmd_init", # velph init + "cmd_nac", # velph nac + "cmd_phelel", # velph phelel + "cmd_phonopy", # velph phonopy + "cmd_phono3py", # velph phono3py + "cmd_ph_bands", # velph ph-bands + "cmd_ph_selfenergy", # velph ph-selfenergy + "cmd_relax", # velph relax + "cmd_root", # velph + "cmd_selfenergy", # velph selfenergy + "cmd_transport", # velph transport ] diff --git a/src/phelel/velph/cli/cmd_root.py b/src/phelel/velph/cli/cmd_root.py new file mode 100644 index 0000000..5ba42bc --- /dev/null +++ b/src/phelel/velph/cli/cmd_root.py @@ -0,0 +1,10 @@ +"""velph command line tool module.""" + +import click + + +@click.group() +@click.help_option("-h", "--help") +def cmd_root(): + """Command-line utility to help VASP el-ph calculation.""" + pass diff --git a/src/phelel/velph/cli/el_bands/__init__.py b/src/phelel/velph/cli/el_bands/__init__.py deleted file mode 100644 index 30af4a0..0000000 --- a/src/phelel/velph/cli/el_bands/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -"""velph command line tool / velph-el_bands.""" - -from phelel.velph.cli.el_bands.cmd_el_bands import ( - cmd_generate, # velph el_bands generate - cmd_plot, # velph el_bands plot - cmd_plot_eigenvalues, # velph el_bands plot_eigenvalues -) - -__all__ = [ - "cmd_generate", - "cmd_plot", - "cmd_plot_eigenvalues", -] diff --git a/src/phelel/velph/cli/generate/__init__.py b/src/phelel/velph/cli/generate/__init__.py deleted file mode 100644 index 9d7955a..0000000 --- a/src/phelel/velph/cli/generate/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-generate.""" - -from phelel.velph.cli.generate.cmd_generate import cmd_generate - -__all__ = ["cmd_generate"] diff --git a/src/phelel/velph/cli/init/__init__.py b/src/phelel/velph/cli/init/__init__.py deleted file mode 100644 index 1c2c73c..0000000 --- a/src/phelel/velph/cli/init/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-init.""" - -from phelel.velph.cli.init.cmd_init import cmd_init - -__all__ = ["cmd_init"] diff --git a/src/phelel/velph/cli/nac/__init__.py b/src/phelel/velph/cli/nac/__init__.py deleted file mode 100644 index c0c23c2..0000000 --- a/src/phelel/velph/cli/nac/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-nac.""" - -from phelel.velph.cli.nac.cmd_nac import cmd_generate, cmd_nac - -__all__ = ["cmd_nac", "cmd_generate"] diff --git a/src/phelel/velph/cli/ph_bands/__init__.py b/src/phelel/velph/cli/ph_bands/__init__.py deleted file mode 100644 index 336002b..0000000 --- a/src/phelel/velph/cli/ph_bands/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-ph_bands.""" - -from phelel.velph.cli.ph_bands.cmd_ph_bands import cmd_generate, cmd_ph_bands, cmd_plot - -__all__ = ["cmd_ph_bands", "cmd_generate", "cmd_plot"] diff --git a/src/phelel/velph/cli/ph_selfenergy/__init__.py b/src/phelel/velph/cli/ph_selfenergy/__init__.py deleted file mode 100644 index 9118371..0000000 --- a/src/phelel/velph/cli/ph_selfenergy/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -"""velph command line tool / velph-ph_selfenergy.""" - -from phelel.velph.cli.ph_selfenergy.cmd_ph_selfenergy import ( - cmd_check_fft, # velph ph_selfenergy check-fft - cmd_generate, # velph ph_selfenergy generate - cmd_ph_selfenergy, # velph ph_selfenergy -) -from phelel.velph.cli.ph_selfenergy.plot import ( - cmd_plot, # velph ph_selfenergy plot -) - -__all__ = [ - "cmd_check_fft", - "cmd_generate", - "cmd_ph_selfenergy", - "cmd_plot", -] diff --git a/src/phelel/velph/cli/phelel/__init__.py b/src/phelel/velph/cli/phelel/__init__.py deleted file mode 100644 index 4fecf22..0000000 --- a/src/phelel/velph/cli/phelel/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -"""velph command line tool / velph-phelel.""" - -from phelel.velph.cli.phelel.cmd_phelel import ( - cmd_differentiate, # velph phelel differentiate - cmd_generate, # velph phelel generate - cmd_init, # velph phelel init - cmd_phonopy, # velph phelel phonopy -) - -__all__ = [ - "cmd_differentiate", - "cmd_generate", - "cmd_init", - "cmd_phonopy", -] diff --git a/src/phelel/velph/cli/phono3py/__init__.py b/src/phelel/velph/cli/phono3py/__init__.py deleted file mode 100644 index 645df7f..0000000 --- a/src/phelel/velph/cli/phono3py/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-phono3py.""" - -from phelel.velph.cli.phono3py.cmd_phono3py import cmd_generate, cmd_init, cmd_phono3py - -__all__ = ["cmd_phono3py", "cmd_init", "cmd_generate"] diff --git a/src/phelel/velph/cli/phonopy/__init__.py b/src/phelel/velph/cli/phonopy/__init__.py deleted file mode 100644 index 185ca25..0000000 --- a/src/phelel/velph/cli/phonopy/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-phonopy.""" - -from phelel.velph.cli.phonopy.cmd_phonopy import cmd_generate, cmd_init, cmd_phonopy - -__all__ = ["cmd_phonopy", "cmd_init", "cmd_generate"] diff --git a/src/phelel/velph/cli/relax/__init__.py b/src/phelel/velph/cli/relax/__init__.py deleted file mode 100644 index 66e941e..0000000 --- a/src/phelel/velph/cli/relax/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""velph command line tool / velph-relax.""" - -from phelel.velph.cli.relax.cmd_relax import cmd_generate, cmd_relax - -__all__ = ["cmd_relax", "cmd_generate"] diff --git a/src/phelel/velph/cli/selfenergy/__init__.py b/src/phelel/velph/cli/selfenergy/__init__.py deleted file mode 100644 index 0a527f4..0000000 --- a/src/phelel/velph/cli/selfenergy/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -"""velph command line tool / velph-selfenergy.""" - -from phelel.velph.cli.selfenergy.cmd_selfenergy import ( - cmd_check_fft, # velph selfenergy check-fft - cmd_generate, # velph selfenergy generate - cmd_selfenergy, # velph selfenergy -) - -__all__ = [ - "cmd_check_fft", - "cmd_generate", - "cmd_selfenergy", -] diff --git a/src/phelel/velph/cli/transport/__init__.py b/src/phelel/velph/cli/transport/__init__.py deleted file mode 100644 index fed8fb8..0000000 --- a/src/phelel/velph/cli/transport/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -"""velph command line tool / velph-transport.""" - -from phelel.velph.cli.transport.cmd_transport import ( - cmd_check_fft, # velph transport check-fft - cmd_generate, # velph transport generate -) -from phelel.velph.cli.transport.plot import ( - cmd_plot, # velph transport plot -) - -__all__ = [ - "cmd_check_fft", - "cmd_generate", - "cmd_plot", -] From ad4fc2667041dd7caf8a4d96f9e516ed89169550 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 22 Feb 2026 17:51:43 +0900 Subject: [PATCH 4/4] Refactor velph --- pyproject.toml | 2 +- src/phelel/velph/cli/__init__.py | 31 ------------------- src/phelel/velph/cli/cmd_root.py | 18 +++++++++++ src/phelel/velph/cli/el_bands/cmd_el_bands.py | 2 +- src/phelel/velph/cli/generate/cmd_generate.py | 2 +- src/phelel/velph/cli/init/cmd_init.py | 2 +- src/phelel/velph/cli/nac/cmd_nac.py | 2 +- src/phelel/velph/cli/ph_bands/cmd_ph_bands.py | 2 +- .../cli/ph_selfenergy/cmd_ph_selfenergy.py | 5 ++- .../velph/cli/ph_selfenergy/plot/__init__.py | 7 ----- src/phelel/velph/cli/phelel/cmd_phelel.py | 2 +- src/phelel/velph/cli/phono3py/cmd_phono3py.py | 2 +- src/phelel/velph/cli/phono3py/init.py | 2 +- src/phelel/velph/cli/phonopy/cmd_phonopy.py | 2 +- src/phelel/velph/cli/relax/cmd_relax.py | 2 +- .../velph/cli/selfenergy/cmd_selfenergy.py | 2 +- .../velph/cli/transport/cmd_transport.py | 5 ++- .../velph/cli/transport/plot/__init__.py | 7 ----- 18 files changed, 38 insertions(+), 59 deletions(-) delete mode 100644 src/phelel/velph/cli/__init__.py delete mode 100644 src/phelel/velph/cli/ph_selfenergy/plot/__init__.py delete mode 100644 src/phelel/velph/cli/transport/plot/__init__.py diff --git a/pyproject.toml b/pyproject.toml index f66e83f..2d1825a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ license = {file = "LICENSE"} [project.scripts] phelel = "phelel.scripts.phelel:run" phelel-load = "phelel.scripts.phelel_load:run" -velph = "phelel.velph.cli:cmd_root" +velph = "phelel.velph.cli.cmd_root:cmd_root" [tool.setuptools.dynamic] version = { attr = "phelel.version.__version__" } diff --git a/src/phelel/velph/cli/__init__.py b/src/phelel/velph/cli/__init__.py deleted file mode 100644 index 5b1a16f..0000000 --- a/src/phelel/velph/cli/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -"""velph command line tool module.""" - -from phelel.velph.cli.cmd_root import cmd_root -from phelel.velph.cli.el_bands.cmd_el_bands import cmd_el_bands -from phelel.velph.cli.generate.cmd_generate import cmd_generate -from phelel.velph.cli.init.cmd_init import cmd_init -from phelel.velph.cli.nac.cmd_nac import cmd_nac -from phelel.velph.cli.ph_bands.cmd_ph_bands import cmd_ph_bands -from phelel.velph.cli.ph_selfenergy.cmd_ph_selfenergy import cmd_ph_selfenergy -from phelel.velph.cli.phelel.cmd_phelel import cmd_phelel -from phelel.velph.cli.phono3py.cmd_phono3py import cmd_phono3py -from phelel.velph.cli.phonopy.cmd_phonopy import cmd_phonopy -from phelel.velph.cli.relax.cmd_relax import cmd_relax -from phelel.velph.cli.selfenergy.cmd_selfenergy import cmd_selfenergy -from phelel.velph.cli.transport.cmd_transport import cmd_transport - -__all__ = [ - "cmd_el_bands", # velph el-bands - "cmd_generate", # velph generate - "cmd_init", # velph init - "cmd_nac", # velph nac - "cmd_phelel", # velph phelel - "cmd_phonopy", # velph phonopy - "cmd_phono3py", # velph phono3py - "cmd_ph_bands", # velph ph-bands - "cmd_ph_selfenergy", # velph ph-selfenergy - "cmd_relax", # velph relax - "cmd_root", # velph - "cmd_selfenergy", # velph selfenergy - "cmd_transport", # velph transport -] diff --git a/src/phelel/velph/cli/cmd_root.py b/src/phelel/velph/cli/cmd_root.py index 5ba42bc..9a18e4b 100644 --- a/src/phelel/velph/cli/cmd_root.py +++ b/src/phelel/velph/cli/cmd_root.py @@ -8,3 +8,21 @@ def cmd_root(): """Command-line utility to help VASP el-ph calculation.""" pass + + +from phelel.velph.cli.el_bands.cmd_el_bands import cmd_el_bands # noqa: E402, F401 +from phelel.velph.cli.generate.cmd_generate import cmd_generate # noqa: E402, F401 +from phelel.velph.cli.init.cmd_init import cmd_init # noqa: E402, F401 +from phelel.velph.cli.nac.cmd_nac import cmd_nac # noqa: E402, F401 +from phelel.velph.cli.ph_bands.cmd_ph_bands import cmd_ph_bands # noqa: E402, F401 +from phelel.velph.cli.ph_selfenergy.cmd_ph_selfenergy import ( # noqa: E402, F401 + cmd_ph_selfenergy, +) +from phelel.velph.cli.phelel.cmd_phelel import cmd_phelel # noqa: E402, F401 +from phelel.velph.cli.phono3py.cmd_phono3py import cmd_phono3py # noqa: E402, F401 +from phelel.velph.cli.phonopy.cmd_phonopy import cmd_phonopy # noqa: E402, F401 +from phelel.velph.cli.relax.cmd_relax import cmd_relax # noqa: E402, F401 +from phelel.velph.cli.selfenergy.cmd_selfenergy import ( # noqa: E402, F401 + cmd_selfenergy, +) +from phelel.velph.cli.transport.cmd_transport import cmd_transport # noqa: E402, F401 diff --git a/src/phelel/velph/cli/el_bands/cmd_el_bands.py b/src/phelel/velph/cli/el_bands/cmd_el_bands.py index 1daa833..2922492 100644 --- a/src/phelel/velph/cli/el_bands/cmd_el_bands.py +++ b/src/phelel/velph/cli/el_bands/cmd_el_bands.py @@ -6,7 +6,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.el_bands.generate import write_input_files from phelel.velph.cli.el_bands.plot import plot_el_bandstructures from phelel.velph.utils.plot_eigenvalues import ( diff --git a/src/phelel/velph/cli/generate/cmd_generate.py b/src/phelel/velph/cli/generate/cmd_generate.py index 9b88447..f9adb37 100644 --- a/src/phelel/velph/cli/generate/cmd_generate.py +++ b/src/phelel/velph/cli/generate/cmd_generate.py @@ -9,7 +9,7 @@ from phonopy.interface.calculator import write_crystal_structure from phonopy.structure.atoms import parse_cell_dict -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root # diff --git a/src/phelel/velph/cli/init/cmd_init.py b/src/phelel/velph/cli/init/cmd_init.py index 76286c1..e6e0347 100644 --- a/src/phelel/velph/cli/init/cmd_init.py +++ b/src/phelel/velph/cli/init/cmd_init.py @@ -8,7 +8,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.init.init import run_init from phelel.velph.cli.utils import ( DefaultCellChoices, diff --git a/src/phelel/velph/cli/nac/cmd_nac.py b/src/phelel/velph/cli/nac/cmd_nac.py index 9570bab..14d23da 100644 --- a/src/phelel/velph/cli/nac/cmd_nac.py +++ b/src/phelel/velph/cli/nac/cmd_nac.py @@ -6,7 +6,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.nac.generate import write_input_files diff --git a/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py b/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py index 30f979d..9aab7a5 100644 --- a/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py +++ b/src/phelel/velph/cli/ph_bands/cmd_ph_bands.py @@ -6,7 +6,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.ph_bands.generate import ( write_input_files as write_input_files_ph_bandstructures, ) diff --git a/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py b/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py index cd991c4..4fdda86 100644 --- a/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py +++ b/src/phelel/velph/cli/ph_selfenergy/cmd_ph_selfenergy.py @@ -5,7 +5,7 @@ import click import h5py -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.selfenergy.generate import write_selfenergy_input_files from phelel.velph.cli.utils import check_fft @@ -72,3 +72,6 @@ def cmd_dump(vaspout_filename: str, output_filename: str): """Dump ph_selfenergy data to HDF5 file.""" with h5py.File(vaspout_filename, "r") as f: list(f) + + +from phelel.velph.cli.ph_selfenergy.plot.cmd_plot import cmd_plot # noqa: E402, F401 diff --git a/src/phelel/velph/cli/ph_selfenergy/plot/__init__.py b/src/phelel/velph/cli/ph_selfenergy/plot/__init__.py deleted file mode 100644 index af4cd3d..0000000 --- a/src/phelel/velph/cli/ph_selfenergy/plot/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""velph command line tool / velph-ph_selfenergy-plot.""" - -from phelel.velph.cli.ph_selfenergy.plot.cmd_plot import ( - cmd_plot, # noqa F401 : velph ph_selfenergy plot - cmd_plot_ph_selfenergy_eigenvalues, # noqa F401 : velph ph_selfenergy plot eigenvalues - cmd_plot_selfenergy, # noqa F401 : velph ph_selfenergy plot selfenergy -) diff --git a/src/phelel/velph/cli/phelel/cmd_phelel.py b/src/phelel/velph/cli/phelel/cmd_phelel.py index 616ae14..bad6bff 100644 --- a/src/phelel/velph/cli/phelel/cmd_phelel.py +++ b/src/phelel/velph/cli/phelel/cmd_phelel.py @@ -9,7 +9,7 @@ import phelel from phelel.cui.phelel_script import finalize_phelel -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.phelel.differentiate import run_derivatives from phelel.velph.cli.phelel.generate import write_supercell_input_files from phelel.velph.cli.phelel.init import run_init diff --git a/src/phelel/velph/cli/phono3py/cmd_phono3py.py b/src/phelel/velph/cli/phono3py/cmd_phono3py.py index c9006dc..cc40cbb 100644 --- a/src/phelel/velph/cli/phono3py/cmd_phono3py.py +++ b/src/phelel/velph/cli/phono3py/cmd_phono3py.py @@ -8,7 +8,7 @@ import click import tomli -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.phono3py.generate import write_supercell_input_files from phelel.velph.cli.phono3py.init import run_init diff --git a/src/phelel/velph/cli/phono3py/init.py b/src/phelel/velph/cli/phono3py/init.py index 817f2c1..f755001 100644 --- a/src/phelel/velph/cli/phono3py/init.py +++ b/src/phelel/velph/cli/phono3py/init.py @@ -18,7 +18,7 @@ def run_init( toml_dict: dict, current_directory: pathlib.Path = pathlib.Path(""), number_of_snapshots: int | None = None, -) -> Phono3py | None: +) -> Phono3py: """Generate displacements and write phono3py_disp.yaml. current_directory : Path diff --git a/src/phelel/velph/cli/phonopy/cmd_phonopy.py b/src/phelel/velph/cli/phonopy/cmd_phonopy.py index 5a5fe65..e9cf252 100644 --- a/src/phelel/velph/cli/phonopy/cmd_phonopy.py +++ b/src/phelel/velph/cli/phonopy/cmd_phonopy.py @@ -7,7 +7,7 @@ import click import tomli -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.phonopy.generate import write_supercell_input_files from phelel.velph.cli.phonopy.init import run_init diff --git a/src/phelel/velph/cli/relax/cmd_relax.py b/src/phelel/velph/cli/relax/cmd_relax.py index 81454b0..8ddb776 100644 --- a/src/phelel/velph/cli/relax/cmd_relax.py +++ b/src/phelel/velph/cli/relax/cmd_relax.py @@ -6,7 +6,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.relax.generate import write_input_files diff --git a/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py b/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py index a5e64e6..4cad66e 100644 --- a/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py +++ b/src/phelel/velph/cli/selfenergy/cmd_selfenergy.py @@ -4,7 +4,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.selfenergy.generate import write_input_files from phelel.velph.cli.utils import check_fft diff --git a/src/phelel/velph/cli/transport/cmd_transport.py b/src/phelel/velph/cli/transport/cmd_transport.py index 328fa0d..a140f36 100644 --- a/src/phelel/velph/cli/transport/cmd_transport.py +++ b/src/phelel/velph/cli/transport/cmd_transport.py @@ -4,7 +4,7 @@ import click -from phelel.velph.cli import cmd_root +from phelel.velph.cli.cmd_root import cmd_root from phelel.velph.cli.transport.generate import write_input_files from phelel.velph.cli.utils import check_fft @@ -51,3 +51,6 @@ def cmd_generate(toml_filename: str, dry_run: bool): def cmd_check_fft(toml_filename: str): """Show [NGX, NGY, NGZ] in vasprun.xml.""" check_fft(toml_filename, "transport") + + +from phelel.velph.cli.transport.plot.cmd_plot import cmd_plot # noqa: E402, F401 diff --git a/src/phelel/velph/cli/transport/plot/__init__.py b/src/phelel/velph/cli/transport/plot/__init__.py deleted file mode 100644 index d047d16..0000000 --- a/src/phelel/velph/cli/transport/plot/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""velph command line tool / velph-transport-plot.""" - -from phelel.velph.cli.transport.plot.cmd_plot import ( - cmd_plot_eigenvalues, # noqa F401 : velph transport plot eigenvalues - cmd_plot_selfenergy, # noqa F401 : velph transport plot selfenergy - cmd_plot_transport_eigenvalues, # noqa F401 : velph transport plot transport -)