Loosen testing criteria for test_run_prop_dos

This commit is contained in:
Atsushi Togo 2024-04-19 16:51:55 +09:00
parent 501f1502f3
commit e50cecc1cf
3 changed files with 7 additions and 76 deletions

View File

@ -35,7 +35,7 @@ $$
### How to use `phono3py-kaccum`
Let's computer lattice thermal conductivity of Si using the `Si-PBEsol` example
Let's compute lattice thermal conductivity of Si using the `Si-PBEsol` example
found in the example directory.
```bash
@ -50,7 +50,9 @@ follows:
```
`kappa-m111111.hdf5` is the output file of thermal conductivity calculation,
which is passed to `phono3py-kaccum` as the first argument.
which is passed to `phono3py-kaccum` as the first argument. `phono3py_disp.yaml`
or `phono3py.yaml` is necessary to be located under the current directory to
read the crystal structure.
The format of the output is as follows: The first column gives frequency in THz,
and the second to seventh columns give the cumulative lattice thermal
@ -86,11 +88,7 @@ That calculated by QE with $19\times 19\times 19$ mesh:
:width: 25%
```
###General options
#### `--pa`
See {ref}`pa_option`.
### General options
#### `--temperature`

View File

@ -6,13 +6,7 @@ import sys
import h5py
import numpy as np
from phonopy.cui.collect_cell_info import collect_cell_info
from phonopy.cui.settings import fracval
from phonopy.interface.calculator import read_crystal_structure
from phonopy.structure.cells import (
get_primitive,
get_primitive_matrix,
guess_primitive_matrix,
)
from phonopy.structure.symmetry import Symmetry
from phono3py.interface.phono3py_yaml import Phono3pyYaml
@ -187,23 +181,6 @@ def _get_mode_property(args, f_kappa):
def _get_parser():
"""Return args of ArgumentParser."""
parser = argparse.ArgumentParser(description="Show unit cell volume")
parser.add_argument(
"--pa",
"--primitive-axis",
"--primitive-axes",
nargs="+",
dest="primitive_matrix",
default=None,
help="Same as PRIMITIVE_AXES tags",
)
# parser.add_argument(
# "-c",
# "--cell",
# dest="cell_filename",
# metavar="FILE",
# default=None,
# help="Read unit cell",
# )
parser.add_argument(
"--gv", action="store_true", help="Calculate for gv_x_gv (tensor)"
)
@ -272,34 +249,6 @@ def _get_parser():
return args
def _analyze_primitive_matrix_option(args, unitcell=None):
"""Analyze --pa option argument."""
if args.primitive_matrix is not None:
if type(args.primitive_matrix) is list:
_primitive_matrix = " ".join(args.primitive_matrix)
else:
_primitive_matrix = args.primitive_matrix.strip()
if _primitive_matrix.lower() == "auto":
primitive_matrix = "auto"
elif _primitive_matrix.upper() in ("P", "F", "I", "A", "C", "R"):
primitive_matrix = _primitive_matrix.upper()
elif len(_primitive_matrix.split()) != 9:
raise SyntaxError("Number of elements in --pa option argument has to be 9.")
else:
primitive_matrix = np.reshape(
[fracval(x) for x in _primitive_matrix.split()], (3, 3)
)
if np.linalg.det(primitive_matrix) < 1e-8:
raise SyntaxError("Primitive matrix has to have positive determinant.")
pmat = get_primitive_matrix(primitive_matrix)
if unitcell is not None and isinstance(pmat, str) and pmat == "auto":
return guess_primitive_matrix(unitcell)
else:
return pmat
def main():
"""Calculate kappa spectrum.
@ -310,12 +259,6 @@ def main():
% phono3py-kaccum kappa-m111111.hdf5
```
Old style usage
---------------
```
% phono3py-kaccum --pa="F" -c POSCAR-unitcell kappa-m111111.hdf5 |tee kaccum.dat
```
Plot by gnuplot
---------------
```
@ -324,9 +267,6 @@ def main():
gnuplot> p "kaccum.dat" i 30 u 1:2 w l, "kaccum.dat" i 30 u 1:8 w l
```
With phono3py.yaml type file as crystal structure, primitive matrix is
unnecessary to set.
"""
args = _get_parser()
primitive = None
@ -347,14 +287,7 @@ def main():
primitive = cell_info["phonopy_yaml"].primitive
if primitive is None:
primitive = cell
else:
primitive_matrix = _analyze_primitive_matrix_option(args, unitcell=cell)
f_kappa = h5py.File(args.filenames[0], "r")
if primitive is None:
if primitive_matrix is None:
primitive = cell
else:
primitive = get_primitive(cell, primitive_matrix)
if "grid_matrix" in f_kappa:
mesh = np.array(f_kappa["grid_matrix"][:], dtype="int_")

View File

@ -390,8 +390,8 @@ def test_run_prop_dos(si_pbesol: Phono3py):
6431.33681,
7235.25391,
]
np.testing.assert_allclose(ref_kdos, kdos[0, :, :, 0].ravel(), atol=1e-2)
np.testing.assert_allclose(ref_mfp, mfp[0, :, :, 0].ravel(), atol=1e-2)
np.testing.assert_allclose(ref_kdos, kdos[0, :, :, 0].ravel(), atol=1e-1)
np.testing.assert_allclose(ref_mfp, mfp[0, :, :, 0].ravel(), atol=1e-1)
np.testing.assert_allclose(ref_sampling_points, sampling_points[0], atol=1e-4)
np.testing.assert_allclose(ref_sampling_points_mfp, sampling_points_mfp[0], rtol=10)