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

Update README.md in examples and fix CLI bugs #262

Merged
merged 2 commits into from
Aug 8, 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^conda/
- id: check-added-large-files
exclude: ^example/AlN-LDA/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
Expand Down
Binary file removed example/AlN-LDA/FORCES_FC3.lzma
Binary file not shown.
Binary file added example/AlN-LDA/FORCES_FC3.xz
Binary file not shown.
60 changes: 32 additions & 28 deletions example/AlN-LDA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,56 @@ from all displaced supercell forces.

Perfect and displaced supercells were created by

```
```bash
% phono3py --dim 3 3 2 -c POSCAR-unitcell -d
```

In the example directory, `FORCES_FC3` is compressed to `FORCES_FC3.lzma`. After
unzipping `FORCES_FC3.lzma` (e.g., using `tar xvfz` or `tar xvfa`), to obtain
`fc3.hdf5` and normal `fc2.hdf5`,

```
% phono3py --sym-fc
```

Using 13x13x9 sampling mesh, lattice thermal conductivity is calculated by
In the example directory, `FORCES_FC3` is compressed to `FORCES_FC3.xz`. After
unzipping `FORCES_FC3.xz` (e.g., using `xz -d`), to obtain `fc3.hdf5` and
`fc2.hdf5` using symfc (the results without using symfc, i.e., finite difference
method, are shown at the bottom of this README)

```
% phono3py --mesh 13 13 9 --fc3 --fc2 --br
```bash
% phono3py-load --symfc -v
```

`kappa-m13139.hdf5` is written as the result. The lattice thermal conductivity
is calculated as k_xx=228.2 and k_zz=224.1 W/m-K at 300 K.
Lattice thermal conductivity is calculated by

With `--nac` option, non-analytical term correction is applied reading the Born
effective charges and dielectric constant from `BORN` file:

```
% phono3py --mesh 13 13 9 --fc3 --fc2 --br --nac
```bash
% phono3py-load --mesh 40 --br --ts 300
```

This changes thermal conductivity at 300 K to k_xx=235.7 and k_zz=219.1. The
shape of phonon band structure is important to fullfil energy and momentum
conservations.
`kappa-m15158.hdf5` is written as the result. Parameters for non-analytical term
correction (NAC) is automatically read from those stored in `phono3py_disp.yaml` or
`BORN` file. The lattice thermal conductivity is calculated as k_xx=242.8 and
k_zz=226.5 W/m-K at 300 K. Without NAC, k_xx=233.6 and k_zz=222.2.

Use of larger supercell of fc2 may change the shape of phonon band structure. To
see it, first regenerate `phono3py_disp.yaml` with `--dim-fc2` option,
Use of larger supercell for fc2 may change the shape of phonon band structure.
To see it, first regenerate `phono3py_disp.yaml` with `--dim-fc2` option,

```
```bash
% phono3py --dim 3 3 2 --dim-fc2 5 5 3 -c POSCAR-unitcell -d
```

Then re-create force constants and calculate thermal conductivity,

```bash
% phono3py-load --symfc -v
% phono3py-load --br --mesh=40 --ts 300
```
% phono3py --sym-fc
% phono3py --mesh="13 13 9" --fc3 --fc2 --br --nac

If `phono3py_disp.yaml` is renamed to `phono3py_disp_dimfc2.yaml`, it can be
specified at the first argument of `phono3py-load` command:

```bash
% phono3py-load phono3py_disp_dimfc2.yaml --symfc -v
% phono3py-load phono3py_disp_dimfc2.yaml --br --mesh=40 --ts 300
```

k_xx=236.0 and k_zz=222.2 are obtained. In the case of this example, we can see
k_xx=240.2 and k_zz=230.1 are obtained. In the case of this example, we can see
that the larger fc2 supercell contributes little, which means that the 3x3x2
supercell was good enough to obtain a good shape of phonon band structure.

Using the finite difference method implemented in phono3py, lattice thermal
conductivities are obtained as k_xx=251.2 and k_zz=233,4 without using the large
fc2 supercell and k_xx=249.4 k_zz=236.9 using the large fc2 supercell.
2 changes: 1 addition & 1 deletion example/NaCl-alm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ lattice thermal conductivity at 300 K is calculated by
% phono3py-load phono3py_params_NaCl222.yaml.xz --mesh 50 --ts 300 --br
```

The result is ~7.2 W/m-K at 300 K.
The result is ~7.3 W/m-K at 300 K.
8 changes: 4 additions & 4 deletions example/Si-LDA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ conventional unit cell to the primitive cell.
To create `fc3.hdf5` and `fc2.hdf5`,

```
% phono3py --sym-fc
% phono3py-load
```

Using 11x11x11 sampling mesh, lattice thermal conductivity is calculated by

```
% phono3py --mesh 11 11 11 --fc3 --fc2 --br
% phono3py-load --mesh 11 11 11 --br --ts 300
```

`kappa-m111111.hdf5` is written as the result. The lattice thermal conductivity
is calculated as 112.5 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 127.0 W/m-K.
is calculated as 112.4 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 128.2 W/m-K.

Accumulated lattice thermal conductivity is calculated using `phono3py-kaccum`
script.
Expand Down
8 changes: 4 additions & 4 deletions example/Si-PBE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ conventional unit cell to the primitive cell.
To create `fc3.hdf5` and `fc2.hdf5`,

```
% phono3py --sym-fc
% phono3py-load
```

Using 11x11x11 sampling mesh, lattice thermal conductivity is calculated by

```
% phono3py --mesh 11 11 11 --fc3 --fc2 --br
% phono3py-load --mesh 11 11 11 --fc3 --fc2 --br
```

`kappa-m111111.hdf5` is written as the result. The lattice thermal conductivity
is calculated as 119.3 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 132.4 W/m-K.
is calculated as 119.5 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 130.1 W/m-K.

Accumulated lattice thermal conductivity is calculated using `phono3py-kaccum`
script.
Expand Down
12 changes: 6 additions & 6 deletions example/Si-PBEsol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ the conventional unit cell to the primitive cell.
To create `fc3.hdf5` and `fc2.hdf5`,

```
% phono3py --sym-fc
% phono3py-load
```

Using 11x11x11 sampling mesh, lattice thermal conductivity is calculated by

```
% phono3py --mesh 11 11 11 --fc3 --fc2 --br
% phono3py-load --mesh 11 11 11 --br
```

`kappa-m111111.hdf5` is written as the result. The lattice thermal conductivity
is calculated as 109.0 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 123.2 W/m-K.
is calculated as 109.1 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 124.4 W/m-K.

Accumulated lattice thermal conductivity is calculated using `phono3py-kaccum`
script.
Expand Down Expand Up @@ -80,11 +80,11 @@ In this example directory, the dataset is renamed to
at `vasprun_xml_fc2/disp-fc2-00001/vasprun.xml`. `FORCES_FC2` is generated by

```
% phono3py phono3py_disp_dimfc2.yaml --cf2 vasprun_xml_fc2/disp-fc2-00001/vasprun.xml
% phono3py -c phono3py_disp_dimfc2.yaml --cf2 vasprun_xml_fc2/disp-fc2-00001/vasprun.xml
```

A lattice thermal conductivity calculation is performed by, e.g.,
```
% phono3py-load phono3py_disp_dimfc2.yaml --mesh 11 11 11 --br --ts 300
```
The result is 108.0 W/m-K, and with the 19x19x19 mesh, 125.4 W/m-K.
The result is 107.9 W/m-K, and with the 19x19x19 mesh, 125.4 W/m-K.
8 changes: 4 additions & 4 deletions example/Si-QE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ the conventional unit cell to the primitive cell.
To create `fc3.hdf5` and `fc2.hdf5`,

```
% phono3py --sym-fc
% phono3py-load
```

Using 11x11x11 sampling mesh, lattice thermal conductivity is calculated by

```
% phono3py --mesh 11 11 11 --fc3 --fc2 --br
% phono3py-load --mesh 11 11 11 --br --ts 300
```

`kappa-m111111.hdf5` is written as the result. The lattice thermal conductivity
is calculated as 118.9 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 129.9 W/m-K.
is calculated as 121.3 W/m-K at 300 K. This becomes, with 19x19x19 sampling
mesh, 135.4 W/m-K.

The .out files for supercells are found in `supercell_out.tar.lzma`. If phono3py
is properly installed, the following command should work.
Expand Down
11 changes: 7 additions & 4 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,9 @@ def produce_fc3(
fc2 = None
if fc_calculator_options is not None and "|" in fc_calculator_options:
fc2 = None
# fc2 should not be set if phonon_supercell_matrix is available.
if self._phonon_supercell_matrix is not None:
fc2 = None

# Normally self._fc2 is overwritten in produce_fc2
if self._fc2 is None:
Expand Down Expand Up @@ -1527,6 +1530,9 @@ def produce_fc2(
else:
disp_dataset = self._phonon_dataset

if not forces_in_dataset(disp_dataset):
raise RuntimeError("Forces are not set in the dataset.")

if is_compact_fc:
p2s_map = self._phonon_primitive.p2s_map
else:
Expand All @@ -1548,10 +1554,7 @@ def produce_fc2(
)
else:
if "displacements" in disp_dataset:
msg = (
"fc_calculator has to be set to produce force "
"constans from this dataset for fc2."
)
msg = "fc_calculator to solve fc2 has to be set."
raise RuntimeError(msg)
self._fc2 = get_phonopy_fc2(
self._phonon_supercell,
Expand Down
Loading
Loading