From feb22c22c1b77f8da34f07237504a8161282ef1a Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 25 Aug 2024 17:17:37 +0900 Subject: [PATCH 1/5] Prefer symbols to numbers when creating PhonopyAtoms --- test/interface/test_phono3py_yaml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/interface/test_phono3py_yaml.py b/test/interface/test_phono3py_yaml.py index 6702c50f..4972544c 100644 --- a/test/interface/test_phono3py_yaml.py +++ b/test/interface/test_phono3py_yaml.py @@ -31,7 +31,7 @@ def test_read_phono3py_yaml(): [0.0, 0.5, 0.0], [0.0, 0.0, 0.5], ], - numbers=[11, 11, 11, 11, 17, 17, 17, 17], + symbols=["Na", "Na", "Na", "Na", "Cl", "Cl", "Cl", "Cl"], ) assert isclose(cell, cell_ref) From f34764604a4a2f96c6edc67d9f107be80337e835 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:34:25 +0000 Subject: [PATCH 2/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84862979..a5b78599 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: exclude: ^example/AlN-LDA/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.1 + rev: v0.6.2 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From 3eaa76fa2c7539a363bac250fd0e74630b30e323 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 31 Aug 2024 21:58:57 +0900 Subject: [PATCH 3/5] Display interface mode in CLI --- doc/command-options.md | 76 ++++++++++++++++---------- phono3py/cui/create_force_constants.py | 7 ++- phono3py/cui/create_force_sets.py | 27 +++++++-- phono3py/cui/phono3py_script.py | 3 +- phono3py/cui/show_log.py | 32 +++++++---- 5 files changed, 99 insertions(+), 46 deletions(-) diff --git a/doc/command-options.md b/doc/command-options.md index 635150fb..b4957714 100644 --- a/doc/command-options.md +++ b/doc/command-options.md @@ -86,8 +86,7 @@ These options have no respective configuration file tags. This is used to create `FORCES_FC3` from `phono3py_disp.yaml` and force calculator outputs containing forces in supercells. `phono3py_disp.yaml` has to -be located at the current directory. Calculator interface has to be specified -except for VASP (default) case. +be located at the current directory. ```bash % phono3py --cf3 disp-{00001..00755}/vasprun.xml @@ -97,14 +96,26 @@ except for VASP (default) case. % phono3py --cf3 supercell_out/disp-{00001..00111}/Si.out ``` +````{note} +The calculator interface should be stored in `phono3py_disp.yaml`, so it is not +needed to set it manually. Command-line-options like `--qe` will be ignored. If +the calculator interface is missing from `phono3py_disp.yaml` but needed, please +update the `phono3py` section in the file as follows: + +```yaml +phono3py: + calculator: qe +``` +```` + (cf3_file_option)= ### `--cf3-file` (command option only) This is used to create `FORCES_FC3` from a text file containing a list of calculator output file names. `phono3py_disp.yaml` has to be located at the -current directory. Calculator interface has to be specified except for VASP -(default) case. +current directory. The calculator interface is unnecessary to specify, see the +note at {ref}`--cf3 `. ```bash % phono3py --cf3-file file_list.dat @@ -130,8 +141,9 @@ together with `--cutoff-pair` option. This is used to create `FORCES_FC2` similarly to `--cf3` option. `phono3py_disp.yaml` has to be located at the current directory. This is -optional. Calculator interface has to be specified except for VASP (default) -case. `FORCES_FC2` is necessary to run with `--dim-fc2` option. +optional. `FORCES_FC2` is necessary to run with `--dim-fc2` option. The +calculator interface is unnecessary to specify, see the note at {ref}`--cf3 +`. ```bash % phono3py --cf2 disp_fc2-{00001..00002}/vasprun.xml @@ -142,8 +154,8 @@ case. `FORCES_FC2` is necessary to run with `--dim-fc2` option. ### `--cfz` (command option only) This is used to create `FORCES_FC3` and `FORCES_FC2` subtracting residual forces -combined with `--cf3` and `--cf2`, respectively. Calculator interface has to be -specified except for VASP (default) case. +combined with `--cf3` and `--cf2`, respectively. The calculator interface is +unnecessary to specify, see the note at {ref}`--cf3 `. In the following example, it is supposed that `disp3-00000/vasprun.xml` and `disp2-00000/vasprun.xml` contain the forces of the perfect supercells. In ideal @@ -204,7 +216,6 @@ When using with `--cf2`, `--cf3` has to be specified simultaneously as below, % phono3py --cf3 disp-{00001..00755}/vasprun.xml --cf2 disp_fc2-{00001..00002}/vasprun.xml --sp ``` - ## Supercell, primitive cell, masses, magnetic moments (dim_option)= @@ -299,6 +310,7 @@ web page](https://phonopy.github.io/phonopy/setting-tags.html#magmom). ## Displacement creation (create_displacements_option)= + ### `-d` (`CREATE_DISPLACEMENTS = .TRUE.`) **`phono3py-load` doesn't have this option.** @@ -317,6 +329,7 @@ information about primitive cell (`primitive_matrix` key) in ``` (random_displacements_option)= + ### `--rd` (`RANDOM_DISPLACEMENTS`), `--rd-fc2` (`RANDOM_DISPLACEMENTS_FC2`) and `--random-seed` (`RANDOM_SEED`) **`phono3py-load` doesn't have this option.** @@ -336,6 +349,7 @@ and/or `--rd-fc2`, ``` (amplitude_option)= + ### `--amplitude` (`DISPLACEMENT_DISTANCE`) **`phono3py-load` doesn't have this option.** @@ -348,6 +362,7 @@ The default value depends on calculator. See {ref}`default_displacement_distance_for_calculator`. (fc_calculator_option)= + ### `--fc-calc`, `--fc-calculator` (`FC_CALCULATOR`) Choice of force constants calculator. @@ -357,14 +372,17 @@ Choice of force constants calculator. ``` To use different force constants calculators for fc2 and fc3 + ```bash % phono3py-load --fc-calc "symfc|" ... ``` + Those for fc2 and fc3 are seprated by `|` such as `symfc|` . Blank means to employ the finite difference method for systematic displacements generated by the option `-d`. (fc_calculator_options_option)= + ### `--fc-calc-opt`, `--fc-calculator-options` (`FC_CALCULATOR_OPTIONS`) Special options for force constants calculators. @@ -608,9 +626,9 @@ $$ \bigl|\Phi_{-\lambda\lambda'\lambda''}\bigl|^2 \left\{(n_{\lambda'}+ n_{\lambda''}+1) \delta(\omega-\omega_{\lambda'}-\omega_{\lambda''}) \right. - + (n_{\lambda'}-n_{\lambda''}) + * (n_{\lambda'}-n_{\lambda''}) \left[\delta(\omega+\omega_{\lambda'}-\omega_{\lambda''}) -+ \left. \delta(\omega-\omega_{\lambda'}+\omega_{\lambda''}) +* \left. \delta(\omega-\omega_{\lambda'}+\omega_{\lambda''}) \right]\right\}. $$ @@ -840,7 +858,7 @@ $$ \bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 (n_{\lambda_1}-n_{\lambda_2}) \left[\delta(\omega+\omega_{\lambda_1}-\omega_{\lambda_2}) - + \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2}) + * \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2}) \right] \end{align*} $$ @@ -854,7 +872,7 @@ $$ \bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 (n_{\lambda_1}+ n_{\lambda_2}+1) \left[ \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2}) - + \delta(\omega + \omega_{\lambda_1} + \omega_{\lambda_2}) \right] + * \delta(\omega + \omega_{\lambda_1} + \omega_{\lambda_2}) \right] \end{align*}, $$ @@ -922,11 +940,11 @@ $$ \bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 & \left\{(n_{\lambda_1}+ n_{\lambda_2}+1) \left[ \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2}) - + \delta(\omega+\omega_{\lambda_1}+\omega_{\lambda_2}) \right] \right. + * \delta(\omega+\omega_{\lambda_1}+\omega_{\lambda_2}) \right] \right. \\ & + (n_{\lambda_1}-n_{\lambda_2}) \left[\delta(\omega+\omega_{\lambda_1}-\omega_{\lambda_2}) - + \left. \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2}) + * \left. \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2}) \right]\right\}, \end{align*} $$ @@ -941,14 +959,14 @@ $$ \left\{ \left[ \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{ (\omega-\omega_{\lambda_1}-\omega_{\lambda_2})_\mathrm{p}} - + \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{ + * \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{ (\omega+\omega_{\lambda_1}+\omega_{\lambda_2})_\mathrm{p}} \right] \right. \\ & + \left[ \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega + \omega_{\lambda_1} - \omega_{\lambda_2})_\mathrm{p}} - + \left. \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega - + * \left. \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega - \omega_{\lambda_1} + \omega_{\lambda_2})_\mathrm{p}} \right]\right\}, \end{align*} @@ -1012,7 +1030,7 @@ A_\lambda(\omega) = \frac{1}{\pi} \frac{4\Omega^2_\lambda \Gamma_\lambda(\omega)} {\left[\omega^2 - \Omega^2_\lambda - 2\Omega_\lambda \Delta_\lambda(\omega) \right]^2 - + \left[ 2\Omega_\lambda + * \left[ 2\Omega_\lambda \Gamma_\lambda(\omega) \right]^2}, $$ @@ -1348,12 +1366,12 @@ Using this option, output file names are slightly modified. For example, with This rule is applied to -+ `fc3.hdf5` -+ `fc2.hdf5` -+ `kappa-xxx.hdf5` -+ `phonon-xxx.hdf5` -+ `pp-xxx.hdf5` -+ `gamma_detail-xxx.hdf5` (write only) +* `fc3.hdf5` +* `fc2.hdf5` +* `kappa-xxx.hdf5` +* `phonon-xxx.hdf5` +* `pp-xxx.hdf5` +* `gamma_detail-xxx.hdf5` (write only) (input_filename_option)= @@ -1367,11 +1385,11 @@ specifying `-i iso --fc3`, a file name `fc3.iso.hdf5` is read instead of This rule is applied to -+ `fc3.hdf5` -+ `fc2.hdf5` -+ `kappa-xxx.hdf5` -+ `phonon-xxx.hdf5` -+ `pp-xxx.hdf5` +* `fc3.hdf5` +* `fc2.hdf5` +* `kappa-xxx.hdf5` +* `phonon-xxx.hdf5` +* `pp-xxx.hdf5` ### `--io` (command option only) diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index c4a41cd3..7d33ec6c 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -259,7 +259,6 @@ def parse_forces( distance_to_A=physical_units["distance_to_A"], force_to_eVperA=physical_units["force_to_eVperA"], ) - assert dataset is not None if "natom" in dataset and dataset["natom"] != natom: @@ -273,6 +272,12 @@ def parse_forces( f'Displacement dataset for {fc_type} was read from "{filename_read_from}".' ) + if calculator is not None and log_level: + print( + f"Displacements and forces were converted from {calculator} " + "unit to A and eV/A." + ) + # Overwrite dataset['cutoff_distance'] when necessary. if fc_type == "fc3" and cutoff_pair_distance: if "cutoff_distance" not in dataset or ( diff --git a/phono3py/cui/create_force_sets.py b/phono3py/cui/create_force_sets.py index 57c69570..84bec1ff 100644 --- a/phono3py/cui/create_force_sets.py +++ b/phono3py/cui/create_force_sets.py @@ -44,7 +44,7 @@ from phonopy.cui.create_force_sets import check_number_of_force_files from phonopy.cui.load_helper import get_nac_params from phonopy.cui.phonopy_script import file_exists, files_exist, print_error -from phonopy.file_IO import parse_FORCE_SETS, write_FORCE_SETS +from phonopy.file_IO import is_file_phonopy_yaml, parse_FORCE_SETS, write_FORCE_SETS from phonopy.interface.calculator import get_calc_dataset from phono3py.file_IO import ( @@ -72,10 +72,24 @@ def create_FORCES_FC3_and_FORCES_FC2( """ interface_mode = settings.calculator + disp_filename_candidates = [ "phono3py_disp.yaml", ] - if cell_filename is not None: + + if log_level: + print("") + + if ( + log_level + and cell_filename is not None + and not is_file_phonopy_yaml(cell_filename, keyword="phono3py") + ): + print(f'*Unnecessary to specify "{cell_filename}".') + + if cell_filename is not None and is_file_phonopy_yaml( + cell_filename, keyword="phono3py" + ): disp_filename_candidates.insert(0, cell_filename) disp_filenames = files_exist( disp_filename_candidates, log_level=log_level, is_any=True @@ -86,6 +100,10 @@ def create_FORCES_FC3_and_FORCES_FC2( if ph3py_yaml.calculator is not None: interface_mode = ph3py_yaml.calculator # overwrite + if interface_mode is not None: + if log_level: + print(f"Calculator interface: {interface_mode}") + if settings.create_forces_fc3 or settings.create_forces_fc3_file: calc_dataset_fc3 = _get_force_sets_fc3( settings, ph3py_yaml.dataset, disp_filename, interface_mode, log_level @@ -172,7 +190,9 @@ def create_FORCE_SETS_from_FORCES_FCx( phonon_smat, input_filename: Optional[str], cell_filename: Optional[str], log_level ): """Convert FORCES_FC3 or FORCES_FC2 to FORCE_SETS.""" - if cell_filename is not None: + if cell_filename is not None and is_file_phonopy_yaml( + cell_filename, keyword="phono3py" + ): disp_filename = cell_filename elif input_filename is None: disp_filename = "phono3py_disp.yaml" @@ -286,7 +306,6 @@ def _get_force_sets_fc3( settings, disp_dataset, disp_filename, interface_mode, log_level ) -> dict: if log_level: - print("") print(f'FC3 Displacement dataset was read from "{disp_filename}".') if "first_atoms" in disp_dataset: # type-1 diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 943b9311..36ad6b5a 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -281,7 +281,7 @@ def read_phono3py_settings(args, argparse_control, log_level): args=args, default_settings=argparse_control ) cell_filename = args.filename[0] - else: + else: # args.filename[0] is assumed to be phono3py-conf file. phono3py_conf_parser = Phono3pyConfParser( filename=args.filename[0], args=args, @@ -1033,6 +1033,7 @@ def main(**argparse_control): unitcell_filename, input_filename, output_filename, + interface_mode, ) if phono3py.supercell.magnetic_moments is None: diff --git a/phono3py/cui/show_log.py b/phono3py/cui/show_log.py index 650a5657..c03f90b6 100644 --- a/phono3py/cui/show_log.py +++ b/phono3py/cui/show_log.py @@ -46,7 +46,13 @@ def show_general_settings( - settings, run_mode, phono3py, cell_filename, input_filename, output_filename + settings, + run_mode, + phono3py, + cell_filename, + input_filename, + output_filename, + interface_mode, ): """Show general setting information.""" is_primitive_axes_auto = ( @@ -58,28 +64,32 @@ def show_general_settings( phonon_supercell_matrix = phono3py.phonon_supercell_matrix print("-" * 29 + " General settings " + "-" * 29) - print("Run mode: %s" % run_mode) + if run_mode: + print("Run mode: {run_mode}") if output_filename: - print("Output filename is modified by %s." % output_filename) + print(f"Output filename is modified by {output_filename}.") if input_filename: - print("Input filename is modified by %s." % input_filename) + print(f"Input filename is modified by {input_filename}.") if settings.hdf5_compression: - print("HDF5 data compression filter: %s" % settings.hdf5_compression) - - if phono3py.calculator: - print("Calculator interface: %s" % phono3py.calculator) - print('Crystal structure was read from "%s".' % cell_filename) + print(f"HDF5 data compression filter: {settings.hdf5_compression}") + if interface_mode: + print( + f'Crystal structure was read from "{cell_filename}" ' + f"in {interface_mode} unit." + ) + else: + print(f'Crystal structure was read from "{cell_filename}".') print_supercell_matrix(supercell_matrix, phonon_supercell_matrix) if is_primitive_axes_auto: print("Primitive matrix (Auto):") for v in primitive_matrix: - print(" %s" % v) + print(f" {v}") elif primitive_matrix is not None: print("Primitive matrix:") for v in primitive_matrix: - print(" %s" % v) + print(f" {v}") def print_supercell_matrix( From 2457584692235252fda96d1d26780047cab819b4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:08:39 +0000 Subject: [PATCH 4/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.2 → v0.6.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.2...v0.6.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5b78599..6ec4db59 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: exclude: ^example/AlN-LDA/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.2 + rev: v0.6.3 hooks: - id: ruff args: [ "--fix", "--show-fixes" ] From b7fea1a068afd53772b400bb0c7d217c1855bcf5 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 3 Sep 2024 20:12:59 +0900 Subject: [PATCH 5/5] Update for reading pypolymlp MLPs from file --- phono3py/api_phono3py.py | 7 ++++++- phono3py/cui/create_force_constants.py | 21 ++++++++++++++------- phono3py/cui/load.py | 7 ++++--- phono3py/phonon3/displacement_fc3.py | 2 +- phono3py/phonon3/reciprocal_to_normal.py | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 00d54efe..41f971cb 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -60,6 +60,7 @@ PypolymlpParams, develop_polymlp, evalulate_polymlp, + load_polymlp, parse_mlp_params, ) from phonopy.structure.atoms import PhonopyAtoms @@ -2226,8 +2227,12 @@ def develop_mlp( verbose=self._log_level - 1 > 0, ) + def load_mlp(self, filename: str = "pypolymlp.mlp"): + """Load machine learning potential of pypolymlp.""" + self._mlp = load_polymlp(filename=filename) + def evaluate_mlp(self): - """Evaluate the machine learning potential of pypolymlp. + """Evaluate machine learning potential of pypolymlp. This method calculates the supercell energies and forces from the MLP for the displacements in self._dataset of type 2. The results are stored diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index 7d33ec6c..99eb892c 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -502,7 +502,8 @@ def _read_dataset_fc3( file_exists(e.filename, log_level=log_level) if use_pypolymlp: - phono3py.mlp_dataset = dataset + if forces_in_dataset(dataset): + phono3py.mlp_dataset = dataset run_pypolymlp_to_compute_forces( phono3py, mlp_params, @@ -521,6 +522,7 @@ def run_pypolymlp_to_compute_forces( displacement_distance: Optional[float] = None, number_of_snapshots: Optional[int] = None, random_seed: Optional[int] = None, + mlp_filename: str = "pypolymlp.mlp", log_level: int = 0, ): """Run pypolymlp to compute forces.""" @@ -536,10 +538,18 @@ def run_pypolymlp_to_compute_forces( print(f" {k}: {v}") if log_level > 1: print("") - if log_level: - print("Developing MLPs by pypolymlp...", flush=True) - ph3py.develop_mlp(params=mlp_params) + if forces_in_dataset(ph3py.mlp_dataset): + if log_level: + print("Developing MLPs by pypolymlp...", flush=True) + ph3py.develop_mlp(params=mlp_params) + else: + if pathlib.Path(mlp_filename).exists(): + if log_level: + print(f'Load MLPs from "{mlp_filename}".') + ph3py.load_mlp(mlp_filename) + else: + raise RuntimeError(f'"{mlp_filename}" is not found.') if log_level: print("-" * 30 + " pypolymlp end " + "-" * 31, flush=True) @@ -577,9 +587,6 @@ def run_pypolymlp_to_compute_forces( flush=True, ) - if ph3py.mlp_dataset is None: - msg = "mlp_dataset has to be set before calling this method." - raise RuntimeError(msg) if ph3py.supercells_with_displacements is None: raise RuntimeError("Displacements are not set. Run generate_displacements.") diff --git a/phono3py/cui/load.py b/phono3py/cui/load.py index f87d6e2c..e4dda9d0 100644 --- a/phono3py/cui/load.py +++ b/phono3py/cui/load.py @@ -416,7 +416,8 @@ def set_dataset_and_force_constants( ) if not read_fc["fc3"]: if use_pypolymlp: - ph3py.mlp_dataset = dataset + if forces_in_dataset(dataset): + ph3py.mlp_dataset = dataset else: ph3py.dataset = dataset read_fc["fc2"], phonon_dataset = _get_dataset_phonon_dataset_or_fc2( @@ -461,8 +462,8 @@ def compute_force_constants_from_datasets( """ fc3_calculator = extract_fc2_fc3_calculators(fc_calculator, 3) fc2_calculator = extract_fc2_fc3_calculators(fc_calculator, 2) - if not read_fc["fc3"] and (ph3py.dataset or ph3py.mlp_dataset): - if use_pypolymlp and forces_in_dataset(ph3py.mlp_dataset): + if not read_fc["fc3"]: + if use_pypolymlp: run_pypolymlp_to_compute_forces( ph3py, mlp_params=mlp_params, diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index f769c900..9afd6eac 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -272,7 +272,7 @@ def get_bond_symmetry( def get_least_orbits(atom_index, cell, site_symmetry, symprec=1e-5): """Find least orbits for a centering atom.""" orbits = _get_orbits(atom_index, cell, site_symmetry, symprec) - mapping = np.arange(cell.get_number_of_atoms()) + mapping = np.arange(len(cell)) for i, orb in enumerate(orbits): for num in np.unique(orb): diff --git a/phono3py/phonon3/reciprocal_to_normal.py b/phono3py/phonon3/reciprocal_to_normal.py index 9cf2970e..4db52090 100644 --- a/phono3py/phonon3/reciprocal_to_normal.py +++ b/phono3py/phonon3/reciprocal_to_normal.py @@ -88,7 +88,7 @@ def _reciprocal_to_normal(self, grid_triplet): self._fc3_normal[i, j, k] = fc3_elem / fff def _sum_in_atoms(self, band_indices, eigvecs): - num_atom = self._primitive.get_number_of_atoms() + num_atom = len(self._primitive) (e1, e2, e3) = eigvecs (b1, b2, b3) = band_indices