mirror of https://github.com/phonopy/phono3py.git
Refactoring using pre-commit setting
This commit is contained in:
parent
1cc5e03c27
commit
994bda2f36
|
@ -12,6 +12,7 @@ Dict = DataFactory("dict")
|
|||
|
||||
|
||||
def get_settings(cutoff_energy, is_nac=False):
|
||||
"""Set up parameters."""
|
||||
unitcell_str = """ Zn Te
|
||||
1.0
|
||||
6.0653118499999996 0.0000000000000000 0.0000000000000000
|
||||
|
@ -99,6 +100,7 @@ Direct
|
|||
|
||||
|
||||
def launch_phono3py(cutoff_energy=350, is_nac=False):
|
||||
"""Launch calculation."""
|
||||
structure, forces_config, nac_config, phonon_settings = get_settings(
|
||||
cutoff_energy, is_nac
|
||||
)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""API for isotope scattering."""
|
||||
# Copyright (C) 2019 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -37,7 +38,9 @@ from phonopy.units import VaspToTHz
|
|||
from phono3py.other.isotope import Isotope
|
||||
|
||||
|
||||
class Phono3pyIsotope(object):
|
||||
class Phono3pyIsotope:
|
||||
"""Class to calculate isotope scattering."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
mesh,
|
||||
|
@ -51,6 +54,7 @@ class Phono3pyIsotope(object):
|
|||
cutoff_frequency=None,
|
||||
lapack_zheev_uplo="L",
|
||||
):
|
||||
"""Init method."""
|
||||
if sigmas is None:
|
||||
self._sigmas = [
|
||||
None,
|
||||
|
@ -72,13 +76,16 @@ class Phono3pyIsotope(object):
|
|||
|
||||
@property
|
||||
def dynamical_matrix(self):
|
||||
"""Return dynamical matrix class instance."""
|
||||
return self._iso.dynamical_matrix
|
||||
|
||||
@property
|
||||
def grid(self):
|
||||
"""Return BZGrid class instance."""
|
||||
return self._iso.bz_grid
|
||||
|
||||
def run(self, grid_points):
|
||||
"""Calculate isotope scattering."""
|
||||
gamma = np.zeros(
|
||||
(len(self._sigmas), len(grid_points), len(self._iso.band_indices)),
|
||||
dtype="double",
|
||||
|
@ -121,6 +128,7 @@ class Phono3pyIsotope(object):
|
|||
frequency_scale_factor=None,
|
||||
decimals=None,
|
||||
):
|
||||
"""Initialize dynamical matrix."""
|
||||
self._primitive = primitive
|
||||
self._iso.init_dynamical_matrix(
|
||||
fc2,
|
||||
|
@ -132,8 +140,10 @@ class Phono3pyIsotope(object):
|
|||
)
|
||||
|
||||
def set_sigma(self, sigma):
|
||||
"""Set sigma. None means tetrahedron method."""
|
||||
self._iso.set_sigma(sigma)
|
||||
|
||||
@property
|
||||
def gamma(self):
|
||||
"""Return calculated isotope scattering."""
|
||||
return self._gamma
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""API for joint-density-of-states calculation."""
|
||||
# Copyright (C) 2019 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -41,7 +42,9 @@ from phono3py.phonon.grid import BZGrid
|
|||
from phono3py.file_IO import write_joint_dos
|
||||
|
||||
|
||||
class Phono3pyJointDos(object):
|
||||
class Phono3pyJointDos:
|
||||
"""Class to calculate joint-density-of-states."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
supercell,
|
||||
|
@ -63,6 +66,7 @@ class Phono3pyJointDos(object):
|
|||
output_filename=None,
|
||||
log_level=0,
|
||||
):
|
||||
"""Init method."""
|
||||
if sigmas is None:
|
||||
self._sigmas = [None]
|
||||
else:
|
||||
|
@ -104,9 +108,11 @@ class Phono3pyJointDos(object):
|
|||
|
||||
@property
|
||||
def grid(self):
|
||||
"""Return BZGrid class instance."""
|
||||
return self._bz_grid
|
||||
|
||||
def run(self, grid_points, write_jdos=False):
|
||||
"""Calculate joint-density-of-states."""
|
||||
if self._log_level:
|
||||
print(
|
||||
"--------------------------------- Joint DOS "
|
||||
|
@ -151,14 +157,17 @@ class Phono3pyJointDos(object):
|
|||
|
||||
@property
|
||||
def dynamical_matrix(self):
|
||||
"""Return DynamicalMatrix class instance."""
|
||||
return self._jdos.dynamical_matrix
|
||||
|
||||
@property
|
||||
def frequency_points(self):
|
||||
"""Return frequency points."""
|
||||
return self._jdos.frequency_points
|
||||
|
||||
@property
|
||||
def joint_dos(self):
|
||||
"""Return calculated joint-density-of-states."""
|
||||
return self._jdos.joint_dos
|
||||
|
||||
def _write(self, gp, sigma=None):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Utilities to show various logs for main CUI script."""
|
||||
# Copyright (C) 2015 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -40,6 +41,7 @@ from phonopy.structure.cells import print_cell
|
|||
def show_general_settings(
|
||||
settings, run_mode, phono3py, cell_filename, input_filename, output_filename
|
||||
):
|
||||
"""Show general setting information."""
|
||||
is_primitive_axes_auto = (
|
||||
type(phono3py.primitive_matrix) is str and phono3py.primitive_matrix == "auto"
|
||||
)
|
||||
|
@ -84,6 +86,7 @@ def show_general_settings(
|
|||
|
||||
|
||||
def show_phono3py_cells(phono3py, settings):
|
||||
"""Show crystal structures."""
|
||||
symmetry = phono3py.symmetry
|
||||
primitive = phono3py.primitive
|
||||
supercell = phono3py.supercell
|
||||
|
@ -104,6 +107,7 @@ def show_phono3py_cells(phono3py, settings):
|
|||
|
||||
|
||||
def show_phono3py_force_constants_settings(settings):
|
||||
"""Show force constants settings."""
|
||||
read_fc3 = settings.read_fc3
|
||||
read_fc2 = settings.read_fc2
|
||||
symmetrize_fc3r = settings.is_symmetrize_fc3_r or settings.fc_symmetry
|
||||
|
@ -138,6 +142,7 @@ def show_phono3py_force_constants_settings(settings):
|
|||
|
||||
|
||||
def show_phono3py_settings(phono3py, settings, updated_settings, log_level):
|
||||
"""Show general calculation settings."""
|
||||
sigmas = updated_settings["sigmas"]
|
||||
temperatures = updated_settings["temperatures"]
|
||||
temperature_points = updated_settings["temperature_points"]
|
||||
|
@ -227,6 +232,7 @@ def show_phono3py_settings(phono3py, settings, updated_settings, log_level):
|
|||
|
||||
|
||||
def show_grid_points(grid_points):
|
||||
"""Show grid point list."""
|
||||
text = "Grid point to be calculated: "
|
||||
if len(grid_points) > 8:
|
||||
for i, gp in enumerate(grid_points):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Show and write triplets information."""
|
||||
# Copyright (C) 2015 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -49,6 +50,7 @@ def write_grid_points(
|
|||
compression="gzip",
|
||||
filename=None,
|
||||
):
|
||||
"""Write grid points into files."""
|
||||
ir_grid_points, ir_grid_weights = _get_ir_grid_points(
|
||||
bz_grid, is_kappa_star=is_kappa_star
|
||||
)
|
||||
|
@ -101,6 +103,7 @@ def write_grid_points(
|
|||
def show_num_triplets(
|
||||
primitive, bz_grid, band_indices=None, grid_points=None, is_kappa_star=True
|
||||
):
|
||||
"""Show numbers of triplets at grid points."""
|
||||
tp_nums = _TripletsNumbers(bz_grid, is_kappa_star=is_kappa_star)
|
||||
num_band = len(primitive) * 3
|
||||
if band_indices is None:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Utilities of calculator interfaces."""
|
||||
# Copyright (C) 2020 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -55,6 +56,7 @@ calculator_info = {
|
|||
|
||||
|
||||
def get_default_displacement_distance(interface_mode):
|
||||
"""Return default displacement distances for calculators."""
|
||||
if interface_mode in ("qe", "abinit", "turbomole"):
|
||||
displacement_distance = 0.06
|
||||
elif interface_mode == "crystal":
|
||||
|
@ -65,6 +67,7 @@ def get_default_displacement_distance(interface_mode):
|
|||
|
||||
|
||||
def get_additional_info_to_write_supercells(interface_mode, supercell_matrix):
|
||||
"""Return additional information to write supercells for calculators."""
|
||||
additional_info = {}
|
||||
if interface_mode == "crystal":
|
||||
additional_info["template_file"] = "TEMPLATE3"
|
||||
|
@ -75,6 +78,7 @@ def get_additional_info_to_write_supercells(interface_mode, supercell_matrix):
|
|||
def get_additional_info_to_write_fc2_supercells(
|
||||
interface_mode, phonon_supercell_matrix
|
||||
):
|
||||
"""Return additional information to write fc2-supercells for calculators."""
|
||||
additional_info = {}
|
||||
if interface_mode == "qe":
|
||||
additional_info["pre_filename"] = "supercell_fc2"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Interfaces for force constants calculators."""
|
||||
# Copyright (C) 2019 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -83,7 +84,6 @@ def get_fc3(
|
|||
for supercell.
|
||||
|
||||
"""
|
||||
|
||||
if fc_calculator == "alm":
|
||||
from phono3py.interface.alm import get_fc3
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""Routines for various scatterings."""
|
|
@ -180,7 +180,7 @@ class Isotope(object):
|
|||
|
||||
@property
|
||||
def bz_grid(self):
|
||||
"""Return BZ grid."""
|
||||
"""Return BZgrid class instance."""
|
||||
return self._bz_grid
|
||||
|
||||
@property
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""Routines for harmonic phonon related properties."""
|
|
@ -0,0 +1 @@
|
|||
"""Ph-ph interaction related routines."""
|
|
@ -1,3 +1,4 @@
|
|||
"""Parse displacement dataset."""
|
||||
# Copyright (C) 2020 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -36,7 +37,7 @@ import numpy as np
|
|||
|
||||
|
||||
def get_displacements_and_forces_fc3(disp_dataset):
|
||||
"""Returns displacements and forces from disp_dataset
|
||||
"""Return displacements and forces from disp_dataset.
|
||||
|
||||
Note
|
||||
----
|
||||
|
@ -59,7 +60,6 @@ def get_displacements_and_forces_fc3(disp_dataset):
|
|||
None is returned when forces don't exist.
|
||||
|
||||
"""
|
||||
|
||||
if "first_atoms" in disp_dataset:
|
||||
natom = disp_dataset["natom"]
|
||||
ndisp = len(disp_dataset["first_atoms"])
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Calculate real-part of self-energy of bubble diagram."""
|
||||
# Copyright (C) 2020 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -57,7 +58,7 @@ def get_real_self_energy(
|
|||
output_filename=None,
|
||||
log_level=0,
|
||||
):
|
||||
"""Real part of self energy at frequency points
|
||||
"""Real part of self energy at frequency points.
|
||||
|
||||
Band indices to be calculated at are kept in Interaction instance.
|
||||
|
||||
|
@ -115,7 +116,6 @@ def get_real_self_energy(
|
|||
band_indices, frequency_points)
|
||||
|
||||
"""
|
||||
|
||||
if epsilons is None:
|
||||
_epsilons = [
|
||||
None,
|
||||
|
@ -250,6 +250,7 @@ def write_real_self_energy(
|
|||
is_mesh_symmetry=True,
|
||||
log_level=0,
|
||||
):
|
||||
"""Write real-part of self-energies into files."""
|
||||
if epsilons is None:
|
||||
_epsilons = [
|
||||
RealSelfEnergy.default_epsilon,
|
||||
|
@ -282,11 +283,8 @@ def write_real_self_energy(
|
|||
)
|
||||
|
||||
|
||||
class RealSelfEnergy(object):
|
||||
|
||||
default_epsilon = 0.05
|
||||
|
||||
"""
|
||||
class RealSelfEnergy:
|
||||
"""Class to calculate real-part of self-energy of bubble diagram.
|
||||
|
||||
About the parameter epsilon
|
||||
---------------------------
|
||||
|
@ -305,10 +303,12 @@ class RealSelfEnergy(object):
|
|||
|
||||
"""
|
||||
|
||||
default_epsilon = 0.05
|
||||
|
||||
def __init__(
|
||||
self, interaction, grid_point=None, temperature=None, epsilon=None, lang="C"
|
||||
):
|
||||
"""
|
||||
"""Init method.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -323,7 +323,6 @@ class RealSelfEnergy(object):
|
|||
Parameter explained above. The unit is consisered as THz.
|
||||
|
||||
"""
|
||||
|
||||
self._pp = interaction
|
||||
self.epsilon = epsilon
|
||||
if temperature is None:
|
||||
|
@ -348,6 +347,7 @@ class RealSelfEnergy(object):
|
|||
self._unit_conversion = 18 / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2
|
||||
|
||||
def run(self):
|
||||
"""Calculate real-part of self-energies."""
|
||||
if self._pp_strength is None:
|
||||
self.run_interaction()
|
||||
|
||||
|
@ -362,6 +362,7 @@ class RealSelfEnergy(object):
|
|||
self._run_with_frequency_points()
|
||||
|
||||
def run_interaction(self):
|
||||
"""Calculate ph-ph interaction strength."""
|
||||
self._pp.run(lang=self._lang)
|
||||
self._pp_strength = self._pp.interaction_strength
|
||||
(self._frequencies, self._eigenvectors) = self._pp.get_phonons()[:2]
|
||||
|
@ -370,6 +371,7 @@ class RealSelfEnergy(object):
|
|||
|
||||
@property
|
||||
def real_self_energy(self):
|
||||
"""Return calculated real-part of self-energies."""
|
||||
if self._cutoff_frequency is None:
|
||||
return self._real_self_energies
|
||||
else: # Averaging frequency shifts by degenerate bands
|
||||
|
@ -395,6 +397,7 @@ class RealSelfEnergy(object):
|
|||
|
||||
@property
|
||||
def grid_point(self):
|
||||
"""Setter and getter of a grid point."""
|
||||
return self._grid_point
|
||||
|
||||
@grid_point.setter
|
||||
|
@ -409,6 +412,11 @@ class RealSelfEnergy(object):
|
|||
|
||||
@property
|
||||
def epsilon(self):
|
||||
"""Setter and getter of epsilon.
|
||||
|
||||
See the detail about epsilon at docstring of this class.
|
||||
|
||||
"""
|
||||
return self._epsilon
|
||||
|
||||
@epsilon.setter
|
||||
|
@ -420,6 +428,7 @@ class RealSelfEnergy(object):
|
|||
|
||||
@property
|
||||
def temperature(self):
|
||||
"""Setter and getter of a temperature point."""
|
||||
return self._temperature
|
||||
|
||||
@temperature.setter
|
||||
|
@ -431,6 +440,7 @@ class RealSelfEnergy(object):
|
|||
|
||||
@property
|
||||
def frequency_points(self):
|
||||
"""Setter and getter of frequency points."""
|
||||
return self._frequency_points
|
||||
|
||||
@frequency_points.setter
|
||||
|
@ -590,16 +600,17 @@ class RealSelfEnergy(object):
|
|||
|
||||
|
||||
def imag_to_real(im_part, frequency_points):
|
||||
"""Calculate real-part of self-energy from the imaginary-part."""
|
||||
i2r = ImagToReal(im_part, frequency_points)
|
||||
i2r.run()
|
||||
return i2r.re_part, i2r.frequency_points
|
||||
|
||||
|
||||
class ImagToReal(object):
|
||||
"""Calculate real part of self-energy using Kramers-Kronig relation"""
|
||||
"""Calculate real part of self-energy using Kramers-Kronig relation."""
|
||||
|
||||
def __init__(self, im_part, frequency_points, diagram="bubble"):
|
||||
"""
|
||||
"""Init method.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -615,7 +626,6 @@ class ImagToReal(object):
|
|||
Only bubble diagram is implemented currently.
|
||||
|
||||
"""
|
||||
|
||||
if diagram == "bubble":
|
||||
(
|
||||
self._im_part,
|
||||
|
@ -630,13 +640,16 @@ class ImagToReal(object):
|
|||
|
||||
@property
|
||||
def re_part(self):
|
||||
"""Return real part."""
|
||||
return self._re_part
|
||||
|
||||
@property
|
||||
def frequency_points(self):
|
||||
"""Return frequency points."""
|
||||
return self._frequency_points
|
||||
|
||||
def run(self, method="pick_one"):
|
||||
"""Calculate real part."""
|
||||
if method == "pick_one":
|
||||
self._re_part, self._frequency_points = self._pick_one()
|
||||
elif method == "half_shift":
|
||||
|
@ -645,6 +658,7 @@ class ImagToReal(object):
|
|||
raise RuntimeError("No method is found.")
|
||||
|
||||
def _pick_one(self):
|
||||
"""Calculate real-part with same frequency points excluding one point."""
|
||||
re_part = []
|
||||
fpoints = []
|
||||
coef = self._df / np.pi
|
||||
|
@ -661,6 +675,7 @@ class ImagToReal(object):
|
|||
return (np.array(re_part, dtype="double"), np.array(fpoints, dtype="double"))
|
||||
|
||||
def _half_shift(self):
|
||||
"""Calculate real-part with half-shifted frequency points."""
|
||||
re_part = []
|
||||
fpoints = []
|
||||
coef = self._df / np.pi
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Calculate spectral function due to bubble diagram."""
|
||||
# Copyright (C) 2020 Atsushi Togo
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -61,7 +62,7 @@ def run_spectral_function(
|
|||
output_filename=None,
|
||||
log_level=0,
|
||||
):
|
||||
"""Spectral function of self energy at frequency points
|
||||
"""Spectral function of self energy at frequency points.
|
||||
|
||||
Band indices to be calculated at are kept in Interaction instance.
|
||||
|
||||
|
@ -112,7 +113,6 @@ def run_spectral_function(
|
|||
spf.half_linewidths, spf.shifts have the same shape as above.
|
||||
|
||||
"""
|
||||
|
||||
spf = SpectralFunction(
|
||||
interaction,
|
||||
grid_points,
|
||||
|
@ -169,7 +169,7 @@ def run_spectral_function(
|
|||
|
||||
|
||||
class SpectralFunction(object):
|
||||
"""Calculate spectral function"""
|
||||
"""Calculate spectral function due to bubble diagram."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -183,6 +183,7 @@ class SpectralFunction(object):
|
|||
temperatures=None,
|
||||
log_level=0,
|
||||
):
|
||||
"""Init method."""
|
||||
self._interaction = interaction
|
||||
self._grid_points = grid_points
|
||||
self._frequency_points_in = frequency_points
|
||||
|
@ -205,18 +206,18 @@ class SpectralFunction(object):
|
|||
self._gp_index = None
|
||||
|
||||
def run(self):
|
||||
"""Calculate spectral function over grid points."""
|
||||
for gp_index in self:
|
||||
pass
|
||||
|
||||
def __iter__(self):
|
||||
"""Initialize iterator."""
|
||||
self._prepare()
|
||||
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
return self.__next__()
|
||||
|
||||
def __next__(self):
|
||||
"""Calculate at next grid point."""
|
||||
if self._gp_index >= len(self._grid_points):
|
||||
if self._log_level:
|
||||
print("-" * 74)
|
||||
|
@ -248,26 +249,32 @@ class SpectralFunction(object):
|
|||
|
||||
@property
|
||||
def spectral_functions(self):
|
||||
"""Return calculated spectral functions."""
|
||||
return self._spectral_functions
|
||||
|
||||
@property
|
||||
def shifts(self):
|
||||
"""Return real part of self energies."""
|
||||
return self._deltas
|
||||
|
||||
@property
|
||||
def half_linewidths(self):
|
||||
"""Return imaginary part of self energies."""
|
||||
return self._gammas
|
||||
|
||||
@property
|
||||
def frequency_points(self):
|
||||
"""Return frequency points."""
|
||||
return self._frequency_points
|
||||
|
||||
@property
|
||||
def grid_points(self):
|
||||
"""Return grid points."""
|
||||
return self._grid_points
|
||||
|
||||
@property
|
||||
def sigmas(self):
|
||||
"""Return sigmas."""
|
||||
return self._sigmas
|
||||
|
||||
def _prepare(self):
|
||||
|
@ -317,7 +324,7 @@ class SpectralFunction(object):
|
|||
assert (np.abs(self._frequency_points - fpoints) < 1e-8).all()
|
||||
|
||||
def _run_spectral_function(self, i, grid_point, sigma_i):
|
||||
"""Compute spectral functions from self-energies
|
||||
"""Compute spectral functions from self-energies.
|
||||
|
||||
Note
|
||||
----
|
||||
|
@ -332,7 +339,6 @@ class SpectralFunction(object):
|
|||
approximately 1 for each phonon mode.
|
||||
|
||||
"""
|
||||
|
||||
if self._log_level:
|
||||
print("* Spectral function")
|
||||
frequencies = self._interaction.get_phonons()[0]
|
||||
|
|
|
@ -270,7 +270,6 @@ class DispCorrMatrixMesh:
|
|||
shape=(grid_point, band, band), dtype='double', order='C'
|
||||
|
||||
"""
|
||||
|
||||
condition = frequencies > self._cutoff_frequency
|
||||
_freqs = np.where(condition, frequencies, 1)
|
||||
_a = mode_length(_freqs, T)
|
||||
|
@ -348,7 +347,6 @@ class SecondOrderFC(object):
|
|||
Phonons are ignored if they have frequencies less than this value.
|
||||
|
||||
"""
|
||||
|
||||
assert displacements.shape == forces.shape
|
||||
shape = displacements.shape
|
||||
u = np.array(displacements.reshape(shape[0], -1), dtype="double", order="C")
|
||||
|
@ -483,7 +481,7 @@ class ThirdOrderFC(object):
|
|||
|
||||
@property
|
||||
def forces(self):
|
||||
"""Return input forces"""
|
||||
"""Return input forces."""
|
||||
return self._forces
|
||||
|
||||
@property
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""Tests for various scatterings."""
|
|
@ -1,3 +1,4 @@
|
|||
"""Tests for grids."""
|
||||
import numpy as np
|
||||
from phonopy.structure.tetrahedron_method import TetrahedronMethod
|
||||
from phono3py.phonon.grid import (
|
||||
|
@ -11,13 +12,12 @@ from phono3py.phonon.grid import (
|
|||
|
||||
|
||||
def test_get_grid_point_from_address(agno2_cell):
|
||||
"""
|
||||
"""Test for get_grid_point_from_address.
|
||||
|
||||
Compare get_grid_point_from_address from spglib and that
|
||||
written in python with mesh numbers.
|
||||
|
||||
"""
|
||||
|
||||
mesh = (10, 10, 10)
|
||||
|
||||
for address in list(np.ndindex(mesh)):
|
||||
|
@ -28,8 +28,7 @@ def test_get_grid_point_from_address(agno2_cell):
|
|||
|
||||
|
||||
def test_BZGrid(si_pbesol_111):
|
||||
"""Basis test of BZGrid type1 and type2"""
|
||||
|
||||
"""Tests of BZGrid type1 and type2."""
|
||||
lat = si_pbesol_111.primitive.cell
|
||||
reclat = np.linalg.inv(lat)
|
||||
mesh = [4, 4, 4]
|
||||
|
@ -118,13 +117,12 @@ def test_BZGrid(si_pbesol_111):
|
|||
|
||||
|
||||
def test_BZGrid_bzg2grg(si_pbesol_111):
|
||||
"""BZGrid to GRGrid
|
||||
"""Test of mapping of BZGrid to GRGrid.
|
||||
|
||||
This mapping table is stored in BZGrid, but also determined by
|
||||
get_grid_point_from_address. This test checks the consistency.
|
||||
|
||||
"""
|
||||
|
||||
lat = si_pbesol_111.primitive.cell
|
||||
mesh = [4, 4, 4]
|
||||
bzgrid1 = BZGrid(mesh, lattice=lat, store_dense_gp_map=False)
|
||||
|
@ -141,7 +139,7 @@ def test_BZGrid_bzg2grg(si_pbesol_111):
|
|||
|
||||
|
||||
def test_BZGrid_SNF(si_pbesol_111):
|
||||
"""SNF in BZGrid"""
|
||||
"""Test of SNF in BZGrid."""
|
||||
lat = si_pbesol_111.primitive.cell
|
||||
mesh = 10
|
||||
bzgrid1 = BZGrid(
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""Tests for ph-ph interaction routines."""
|
|
@ -1,3 +1,4 @@
|
|||
"""Tests for joint-density-of-states."""
|
||||
import numpy as np
|
||||
from phono3py.api_jointdos import Phono3pyJointDos
|
||||
|
||||
|
@ -164,6 +165,7 @@ nacl_jdos_12_at_300K = [
|
|||
|
||||
|
||||
def test_jdos_si(si_pbesol):
|
||||
"""Test joint-DOS by Si."""
|
||||
si_pbesol.mesh_numbers = [9, 9, 9]
|
||||
jdos = Phono3pyJointDos(
|
||||
si_pbesol.phonon_supercell,
|
||||
|
@ -183,6 +185,7 @@ def test_jdos_si(si_pbesol):
|
|||
|
||||
|
||||
def test_jdso_si_nomeshsym(si_pbesol):
|
||||
"""Test joint-DOS without considering mesh symmetry by Si."""
|
||||
si_pbesol.mesh_numbers = [9, 9, 9]
|
||||
jdos = Phono3pyJointDos(
|
||||
si_pbesol.phonon_supercell,
|
||||
|
@ -203,6 +206,7 @@ def test_jdso_si_nomeshsym(si_pbesol):
|
|||
|
||||
|
||||
def test_jdos_nacl(nacl_pbe):
|
||||
"""Test joint-DOS by NaCl."""
|
||||
nacl_pbe.mesh_numbers = [9, 9, 9]
|
||||
jdos = Phono3pyJointDos(
|
||||
nacl_pbe.phonon_supercell,
|
||||
|
@ -223,6 +227,7 @@ def test_jdos_nacl(nacl_pbe):
|
|||
|
||||
|
||||
def test_jdos_nacl_gamma(nacl_pbe):
|
||||
"""Test joint-DOS at Gamma-point by NaCl."""
|
||||
nacl_pbe.mesh_numbers = [9, 9, 9]
|
||||
jdos = Phono3pyJointDos(
|
||||
nacl_pbe.phonon_supercell,
|
||||
|
@ -244,6 +249,7 @@ def test_jdos_nacl_gamma(nacl_pbe):
|
|||
|
||||
|
||||
def test_jdos_nacl_at_300K(nacl_pbe):
|
||||
"""Test joint-DOS at 300K by NaCl."""
|
||||
nacl_pbe.mesh_numbers = [9, 9, 9]
|
||||
jdos = Phono3pyJointDos(
|
||||
nacl_pbe.phonon_supercell,
|
||||
|
|
|
@ -23,21 +23,25 @@ aln_lda_kappa_RTA_with_sigmas = [213.820000, 213.820000, 224.800121, 0, 0, 0]
|
|||
|
||||
|
||||
def test_kappa_RTA_si(si_pbesol):
|
||||
"""Test RTA by Si."""
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_si_full_pp(si_pbesol):
|
||||
"""Test RTA with full-pp by Si."""
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_full_pp=True).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_si_iso(si_pbesol):
|
||||
"""Test RTA with isotope scattering by Si."""
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_isotope=True).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA_iso, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_si_with_sigma(si_pbesol):
|
||||
"""Test RTA with smearing method by Si."""
|
||||
si_pbesol.sigmas = [
|
||||
0.1,
|
||||
]
|
||||
|
@ -47,6 +51,7 @@ def test_kappa_RTA_si_with_sigma(si_pbesol):
|
|||
|
||||
|
||||
def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol):
|
||||
"""Test RTA with smearing method and full-pp by Si."""
|
||||
si_pbesol.sigmas = [
|
||||
0.1,
|
||||
]
|
||||
|
@ -57,6 +62,7 @@ def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol):
|
|||
|
||||
|
||||
def test_kappa_RTA_si_with_sigma_iso(si_pbesol):
|
||||
"""Test RTA with smearing method and isotope scattering by Si."""
|
||||
si_pbesol.sigmas = [
|
||||
0.1,
|
||||
]
|
||||
|
@ -66,11 +72,13 @@ def test_kappa_RTA_si_with_sigma_iso(si_pbesol):
|
|||
|
||||
|
||||
def test_kappa_RTA_si_compact_fc(si_pbesol_compact_fc):
|
||||
"""Test RTA with compact-fc by Si."""
|
||||
kappa = _get_kappa(si_pbesol_compact_fc, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_si_nosym(si_pbesol, si_pbesol_nosym):
|
||||
"""Test RTA without considering symmetry by Si."""
|
||||
si_pbesol_nosym.fc2 = si_pbesol.fc2
|
||||
si_pbesol_nosym.fc3 = si_pbesol.fc3
|
||||
kappa = _get_kappa(si_pbesol_nosym, [4, 4, 4]).reshape(-1, 3).sum(axis=1)
|
||||
|
@ -79,6 +87,7 @@ def test_kappa_RTA_si_nosym(si_pbesol, si_pbesol_nosym):
|
|||
|
||||
|
||||
def test_kappa_RTA_si_nomeshsym(si_pbesol, si_pbesol_nomeshsym):
|
||||
"""Test RTA without considering mesh symmetry by Si."""
|
||||
si_pbesol_nomeshsym.fc2 = si_pbesol.fc2
|
||||
si_pbesol_nomeshsym.fc3 = si_pbesol.fc3
|
||||
kappa = _get_kappa(si_pbesol_nomeshsym, [4, 4, 4]).ravel()
|
||||
|
@ -87,6 +96,7 @@ def test_kappa_RTA_si_nomeshsym(si_pbesol, si_pbesol_nomeshsym):
|
|||
|
||||
|
||||
def test_kappa_RTA_si_N_U(si_pbesol):
|
||||
"""Test RTA with N and U scatterings by Si."""
|
||||
ph3 = si_pbesol
|
||||
mesh = [4, 4, 4]
|
||||
is_N_U = True
|
||||
|
@ -210,11 +220,13 @@ def test_kappa_RTA_si_N_U(si_pbesol):
|
|||
|
||||
|
||||
def test_kappa_RTA_nacl(nacl_pbe):
|
||||
"""Test RTA by NaCl."""
|
||||
kappa = _get_kappa(nacl_pbe, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(nacl_pbe_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_nacl_with_sigma(nacl_pbe):
|
||||
"""Test RTA with smearing method by NaCl."""
|
||||
nacl_pbe.sigmas = [
|
||||
0.1,
|
||||
]
|
||||
|
@ -226,11 +238,13 @@ def test_kappa_RTA_nacl_with_sigma(nacl_pbe):
|
|||
|
||||
|
||||
def test_kappa_RTA_aln(aln_lda):
|
||||
"""Test RTA by AlN."""
|
||||
kappa = _get_kappa(aln_lda, [7, 7, 5]).ravel()
|
||||
np.testing.assert_allclose(aln_lda_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_aln_with_sigma(aln_lda):
|
||||
"""Test RTA with smearing method by AlN."""
|
||||
aln_lda.sigmas = [
|
||||
0.1,
|
||||
]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""Tests for SSCHA."""
|
Loading…
Reference in New Issue