diff --git a/easyunfold/cli.py b/easyunfold/cli.py index b215f8d..75e3097 100644 --- a/easyunfold/cli.py +++ b/easyunfold/cli.py @@ -57,11 +57,16 @@ def easyunfold(): @click.option('--out-file', '-o', default='easyunfold.json', help='Name of the output file') @click.option('--no-expand', help='Do not expand the kpoints by symmetry', default=False, is_flag=True) @click.option('--nk-per-split', help='Number of band structure kpoints per split.', type=int) +@click.option('--separate-folders/--no-separate-folders', + help='Whether to use separate folders for each split.', + default=False, + show_default=True) @click.option('--scf-kpoints', help='File (IBZKPT) to provide SCF kpoints for self-consistent calculations. Needed for hybrid functional calculations.', type=click.Path(exists=True, dir_okay=False)) @click.option('--yes', '-y', is_flag=True, default=False, help='Skip and confirmation.', hidden=True) # hide help -def generate(pc_file, code, sc_file, matrix, kpoints, time_reversal, out_file, no_expand, symprec, nk_per_split, scf_kpoints, yes): +def generate(pc_file, code, sc_file, matrix, kpoints, time_reversal, out_file, no_expand, symprec, nk_per_split, scf_kpoints, yes, + separate_folders): """ Generate the kpoints for performing supercell calculations. @@ -155,6 +160,7 @@ def generate(pc_file, code, sc_file, matrix, kpoints, time_reversal, out_file, n out_kpt_name, nk_per_split=nk_per_split, scf_kpoints_and_weights=scf_kpoints_and_weights, + use_separate_folders=separate_folders, source=sc_file, ) diff --git a/easyunfold/unfold.py b/easyunfold/unfold.py index 26d038c..42b036d 100644 --- a/easyunfold/unfold.py +++ b/easyunfold/unfold.py @@ -11,6 +11,7 @@ import re import warnings from typing import Union, List, Tuple +from pathlib import Path from packaging import version import numpy as np @@ -332,6 +333,7 @@ def write_sc_kpoints(self, file: str, nk_per_split: Union[None, list] = None, scf_kpoints_and_weights: Union[None, list] = None, + use_separate_folders=False, **kwargs): """ Write the supercell kpoints to a file. @@ -358,12 +360,13 @@ def write_sc_kpoints(self, for i_spilt, kpt in enumerate(splits): if scf_kpoints_and_weights: kpt, weights = concatenate_scf_kpoints(scf_kpoints_and_weights[0], scf_kpoints_and_weights[1], kpt) - write_kpoints(kpt, - f'{file}_{i_spilt + 1:03d}', - f'supercell kpoints split {i_spilt + 1}', - code=self.dft_code, - weights=weights, - **kwargs) + if use_separate_folders: + folder = f'split-{i_spilt+1:03d}' + Path(folder).mkdir(exist_ok=True) + fname = str(folder / file) + else: + fname = f'{file}_{i_spilt + 1:03d}' + write_kpoints(kpt, fname, f'supercell kpoints split {i_spilt + 1}', code=self.dft_code, weights=weights, **kwargs) def write_pc_kpoints(self, file: str, expanded: bool = False, **kwargs): """Write the primitive cell kpoints"""