Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename velph-supercell to velph-phelel #19

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/phelel/velph/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def cmd_root():
from phelel.velph.cli.ph_bands import cmd_ph_bands # 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.supercell import cmd_supercell # noqa F401
from phelel.velph.cli.phelel import cmd_phelel # noqa F401
from phelel.velph.cli.transport import cmd_transport # noqa F401
13 changes: 12 additions & 1 deletion src/phelel/velph/cli/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@
f"(find_primitive: bool, default={VelphInitParams.find_primitive})"
),
)
@click.option(
"--phelel-dir-name",
"phelel_dir_name",
type=str,
default="phelel",
help=(
'Used for backward compatibility, for which set "supercell". '
'(phelel_dir_name: str, default="phelel")'
),
)
@click.option(
"--phelel-nosym",
"phelel_nosym",
Expand Down Expand Up @@ -220,6 +230,7 @@ def cmd_init(
kspacing_dense: Optional[float],
magmom: Optional[str],
max_num_atoms: Optional[int],
phelel_dir_name: str,
phelel_nosym: Optional[bool],
primitive_cell_choice: Optional[str],
project_folder: str,
Expand Down Expand Up @@ -308,7 +319,7 @@ def cmd_init(

vfp = VelphFilePaths(**vfp_dict)

toml_lines = run_init(vip_cmd_options, vfp)
toml_lines = run_init(vip_cmd_options, vfp, phelel_dir_name=phelel_dir_name)

# Write velph.toml.
if toml_lines:
Expand Down
36 changes: 29 additions & 7 deletions src/phelel/velph/cli/init/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
from phelel.version import __version__


def run_init(cmd_init_options: dict, vfp: VelphFilePaths) -> Optional[list[str]]:
def run_init(
cmd_init_options: dict, vfp: VelphFilePaths, phelel_dir_name: str = "phelel"
) -> Optional[list[str]]:
"""Run velph-init.

Main part of init processes are implemented in the function _run_init.
Expand All @@ -62,6 +64,10 @@ def run_init(cmd_init_options: dict, vfp: VelphFilePaths) -> Optional[list[str]]
vfp : VelphFilePaths
Input and output file names required for velph init. Default path to
scheduler-toml-template file is defined in VelphFilePaths.
phelel_dir_name : str, optional
Directory name for [vasp.{phelel_dir_name}]. The default is "phelel",
which used to be "supercell". This parameter exists for backward
compatibility.

Returns
-------
Expand All @@ -80,6 +86,7 @@ def run_init(cmd_init_options: dict, vfp: VelphFilePaths) -> Optional[list[str]]
cmd_init_options,
velph_template_fp=vfp.velph_template_filepath,
template_toml_filepath=vfp.velph_template_filepath,
phelel_dir_name=phelel_dir_name,
)


Expand All @@ -88,6 +95,7 @@ def _run_init(
cmd_init_options: dict,
velph_template_fp: Optional[Union[str, bytes, os.PathLike, io.IOBase]] = None,
template_toml_filepath: Optional[Union[str, bytes, os.PathLike]] = None,
phelel_dir_name: str = "phelel",
) -> Optional[list[str]]:
"""Run init process and return velph-toml lines.

Expand All @@ -105,6 +113,10 @@ def _run_init(
represents file name.
template_toml_filepath : str, bytes, os.PathLike
File name of velph-toml-template.
phelel_dir_name : str, optional
Directory name for [vasp.{phelel_dir_name}]. The default is "phelel",
which used to be "supercell". This parameter exists for backward
compatibility.

"""
#
Expand Down Expand Up @@ -158,6 +170,7 @@ def _run_init(
primitive,
cell_choices,
sym_dataset,
phelel_dir_name=phelel_dir_name,
)

return toml_lines
Expand Down Expand Up @@ -565,6 +578,7 @@ def _get_toml_lines(
primitive: PhonopyAtoms,
cell_choices: dict,
sym_dataset: dict,
phelel_dir_name: str = "phelel",
) -> list[str]:
"""Return velph-toml lines."""
supercell_dimension = _get_supercell_dimension(
Expand All @@ -589,6 +603,7 @@ def _get_toml_lines(
supercell_dimension,
cell_choices["nac"],
cell_choices["relax"],
phelel_dir_name=phelel_dir_name,
)

if "vasp" in velph_dict:
Expand All @@ -602,7 +617,6 @@ def _get_toml_lines(
_show_kpoints_lines(
kpoints_dict,
kpoints_dense_dict,
kpoints_opt_dict,
velph_dict["vasp"],
vip.kspacing,
vip.kspacing_dense,
Expand Down Expand Up @@ -635,6 +649,7 @@ def _get_toml_lines(
qpoints_dict,
cell_choices["nac"],
cell_choices["relax"],
phelel_dir_name=phelel_dir_name,
)

# [scheduler]
Expand Down Expand Up @@ -719,6 +734,7 @@ def _get_kpoints_dict(
supercell_dimension: np.ndarray,
cell_for_nac: CellChoice,
cell_for_relax: CellChoice,
phelel_dir_name: str = "phelel",
) -> tuple[dict, dict, dict, dict]:
"""Return kpoints dicts."""
use_grg_unitcell = vip_use_grg and (len(unitcell) == len(primitive))
Expand Down Expand Up @@ -760,7 +776,12 @@ def _get_kpoints_dict(

# Build return values
kpoints_dict = _get_kpoints_by_kspacing(
gm, gm_prim, gm_super, cell_for_nac, cell_for_relax
gm,
gm_prim,
gm_super,
cell_for_nac,
cell_for_relax,
phelel_dir_name=phelel_dir_name,
)
kpoints_dense_dict = _get_kpoints_by_kspacing_dense(gm_dense_prim)
qpoints_dict: dict = {}
Expand Down Expand Up @@ -791,7 +812,6 @@ def _update_kpoints_by_vasp_dict(
def _show_kpoints_lines(
kpoints_dict: dict,
kpoints_dense_dict: dict,
kpoints_opt_dict: dict,
vasp_dict: dict,
vip_kspacing: float,
vip_kspacing_dense: float,
Expand Down Expand Up @@ -828,6 +848,7 @@ def _get_kpoints_by_kspacing(
gm_super: GridMatrix,
cell_for_nac: CellChoice,
cell_for_relax: CellChoice,
phelel_dir_name: str = "phelel",
) -> dict:
"""Return kpoints dict.

Expand Down Expand Up @@ -882,7 +903,7 @@ def _get_kpoints_by_kspacing(
relax_kpoints = {"mesh": gm_relax.grid_matrix}

return {
"supercell": supercell_kpoints,
phelel_dir_name: supercell_kpoints,
"selfenergy": selfenergy_kpoints,
"relax": relax_kpoints,
"nac": nac_kpoints,
Expand All @@ -909,9 +930,10 @@ def _get_vasp_lines(
qpoints_dict: dict,
cell_for_nac: CellChoice,
cell_for_relax: CellChoice,
phelel_dir_name: str = "phelel",
) -> list:
incar_commons = _get_incar_commons(vasp_dict)
supercell_kpoints = kpoints_dict["supercell"]
supercell_kpoints = kpoints_dict[phelel_dir_name]
selfenergy_kpoints = kpoints_dict["selfenergy"]
relax_kpoints = kpoints_dict["relax"]
nac_kpoints = kpoints_dict["nac"]
Expand All @@ -924,7 +946,7 @@ def _get_vasp_lines(

lines = []

for calc_type in ("supercell", "phono3py", "phono3py.phonon"):
for calc_type in (phelel_dir_name, "phono3py", "phono3py.phonon"):
keys = calc_type.split(".")
_vasp_dict = vasp_dict
for key in keys:
Expand Down
Loading