mirror of https://github.com/phonopy/phono3py.git
Update tests
This commit is contained in:
parent
b2548d4b6e
commit
092dd3e396
|
@ -2,10 +2,18 @@ import os
|
|||
import pytest
|
||||
import phonopy
|
||||
import phono3py
|
||||
from phonopy.interface.phonopy_yaml import read_cell_yaml
|
||||
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def agno2_cell():
|
||||
cell = read_cell_yaml(os.path.join(current_dir, "AgNO2_cell.yaml"))
|
||||
return cell
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def si_pbesol():
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_si_pbesol.yaml")
|
||||
|
|
|
@ -22,7 +22,8 @@ def test_jdos(si_pbesol):
|
|||
si_pbesol.phonon_primitive,
|
||||
si_pbesol.mesh_numbers,
|
||||
si_pbesol.fc2,
|
||||
num_frequency_points=10)
|
||||
num_frequency_points=10,
|
||||
log_level=1)
|
||||
jdos.run([1, 103])
|
||||
# print(", ".join(["%.7f" % fp for fp in jdos.frequency_points]))
|
||||
np.testing.assert_allclose(freq_points, jdos.frequency_points,
|
||||
|
|
|
@ -1,34 +1,46 @@
|
|||
import unittest
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
from phonopy.interface.phonopy_yaml import read_cell_yaml
|
||||
from phono3py.phonon3.triplets import (get_grid_point_from_address,
|
||||
get_grid_point_from_address_py)
|
||||
get_grid_point_from_address_py,
|
||||
get_triplets_at_q)
|
||||
|
||||
data_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class TestTriplets(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._cell = read_cell_yaml(os.path.join(data_dir, "POSCAR.yaml"))
|
||||
def test_get_grid_point_from_address(agno2_cell):
|
||||
"""
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
Compare get_grid_point_from_address from spglib and that
|
||||
written in python with mesh numbers.
|
||||
|
||||
def test_get_grid_point_from_address(self):
|
||||
self._mesh = (10, 10, 10)
|
||||
print("Compare get_grid_point_from_address from spglib and that "
|
||||
"written in python")
|
||||
print("with mesh numbers [%d %d %d]" % self._mesh)
|
||||
"""
|
||||
|
||||
for address in list(np.ndindex(self._mesh)):
|
||||
gp_spglib = get_grid_point_from_address(address, self._mesh)
|
||||
gp_py = get_grid_point_from_address_py(address, self._mesh)
|
||||
# print("%s %d %d" % (address, gp_spglib, gp_py))
|
||||
self.assertEqual(gp_spglib, gp_py)
|
||||
mesh = (10, 10, 10)
|
||||
|
||||
for address in list(np.ndindex(mesh)):
|
||||
gp_spglib = get_grid_point_from_address(address, mesh)
|
||||
gp_py = get_grid_point_from_address_py(address, mesh)
|
||||
# print("%s %d %d" % (address, gp_spglib, gp_py))
|
||||
np.testing.assert_equal(gp_spglib, gp_py)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestTriplets)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
def test_get_triplets_at_q(si_pbesol_111):
|
||||
pcell = si_pbesol_111.primitive
|
||||
reclat = np.linalg.inv(pcell.cell)
|
||||
psym = si_pbesol_111.primitive_symmetry
|
||||
grid_point = 1
|
||||
mesh = [4, 4, 4]
|
||||
|
||||
triplets, weights = get_triplets_at_q(
|
||||
grid_point,
|
||||
mesh,
|
||||
psym.get_pointgroup_operations(),
|
||||
reclat)[:2]
|
||||
|
||||
triplets_ref = [1, 0, 3, 1, 1, 64, 1, 4, 15, 1,
|
||||
5, 14, 1, 6, 13, 1, 7, 12, 1, 8,
|
||||
11, 1, 9, 66, 1, 24, 59, 1, 26, 88]
|
||||
weights_ref = [2, 2, 6, 6, 6, 6, 6, 6, 12, 12]
|
||||
np.testing.assert_equal(triplets.ravel(), triplets_ref)
|
||||
np.testing.assert_equal(weights, weights_ref)
|
||||
|
|
Loading…
Reference in New Issue