mirror of https://github.com/phonopy/phono3py.git
Add tests for fc-calculator-options str for individually fc2 and fc3
This commit is contained in:
parent
0ba6cbfef9
commit
70098946d5
116
test/conftest.py
116
test/conftest.py
|
@ -226,28 +226,6 @@ def si_pbesol_111_222_fd(request):
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm_fd(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
||||
* with symmetry
|
||||
* full fc
|
||||
* use alm for fc2 if available on test side
|
||||
|
||||
"""
|
||||
pytest.importorskip("alm")
|
||||
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_params_Si-111-222.yaml")
|
||||
enable_v2 = request.config.getoption("--v1")
|
||||
return phono3py.load(
|
||||
yaml_filename,
|
||||
store_dense_gp_map=enable_v2,
|
||||
store_dense_svecs=enable_v2,
|
||||
fc_calculator="alm|",
|
||||
log_level=1,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
@ -270,6 +248,28 @@ def si_pbesol_111_222_alm(request):
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm_fd(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
||||
* with symmetry
|
||||
* full fc
|
||||
* use alm for fc2 if available on test side
|
||||
|
||||
"""
|
||||
pytest.importorskip("alm")
|
||||
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_params_Si-111-222.yaml")
|
||||
enable_v2 = request.config.getoption("--v1")
|
||||
return phono3py.load(
|
||||
yaml_filename,
|
||||
store_dense_gp_map=enable_v2,
|
||||
store_dense_svecs=enable_v2,
|
||||
fc_calculator="alm|",
|
||||
log_level=1,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_fd_alm(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
@ -292,6 +292,78 @@ def si_pbesol_111_222_fd_alm(request):
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm_cutoff(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
||||
* with symmetry
|
||||
* full fc
|
||||
* use alm if available on test side
|
||||
* cutoff=3
|
||||
|
||||
"""
|
||||
pytest.importorskip("alm")
|
||||
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_params_Si-111-222.yaml")
|
||||
enable_v2 = request.config.getoption("--v1")
|
||||
return phono3py.load(
|
||||
yaml_filename,
|
||||
store_dense_gp_map=enable_v2,
|
||||
store_dense_svecs=enable_v2,
|
||||
fc_calculator="alm",
|
||||
fc_calculator_options="cutoff = 3",
|
||||
log_level=1,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm_cutoff_fc2(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
||||
* with symmetry
|
||||
* full fc
|
||||
* use alm if available on test side
|
||||
* cutoff=3 only for fc2
|
||||
|
||||
"""
|
||||
pytest.importorskip("alm")
|
||||
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_params_Si-111-222.yaml")
|
||||
enable_v2 = request.config.getoption("--v1")
|
||||
return phono3py.load(
|
||||
yaml_filename,
|
||||
store_dense_gp_map=enable_v2,
|
||||
store_dense_svecs=enable_v2,
|
||||
fc_calculator="alm",
|
||||
fc_calculator_options="cutoff = 3|",
|
||||
log_level=1,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def si_pbesol_111_222_alm_cutoff_fc3(request):
|
||||
"""Return Phono3py instance of Si 1x1x1.
|
||||
|
||||
* with symmetry
|
||||
* full fc
|
||||
* use alm if available on test side
|
||||
* cutoff=3 only for fc3
|
||||
|
||||
"""
|
||||
pytest.importorskip("alm")
|
||||
|
||||
yaml_filename = os.path.join(current_dir, "phono3py_params_Si-111-222.yaml")
|
||||
enable_v2 = request.config.getoption("--v1")
|
||||
return phono3py.load(
|
||||
yaml_filename,
|
||||
store_dense_gp_map=enable_v2,
|
||||
store_dense_svecs=enable_v2,
|
||||
fc_calculator="alm",
|
||||
fc_calculator_options="|cutoff = 3",
|
||||
log_level=1,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def nacl_pbe(request):
|
||||
"""Return Phono3py instance of NaCl 2x2x2.
|
||||
|
|
|
@ -213,6 +213,49 @@ def test_phonon_smat_fd_alm(si_pbesol_111_222_fd_alm: Phono3py):
|
|||
np.testing.assert_allclose(ph.fc2[0, 33], fc2_ref, atol=1e-6, rtol=0)
|
||||
|
||||
|
||||
def test_phonon_smat_alm_cutoff(si_pbesol_111_222_alm_cutoff: Phono3py):
|
||||
"""Test phonon smat and ALM with Si PBEsol 1x1x1-2x2x2 cutoff."""
|
||||
ph = si_pbesol_111_222_alm_cutoff
|
||||
np.testing.assert_allclose(ph.fc3[0, 1, 7], 0, atol=1e-6, rtol=0)
|
||||
np.testing.assert_allclose(ph.fc2[0, 33], 0, atol=1e-6, rtol=0)
|
||||
|
||||
|
||||
def test_phonon_smat_alm_cutoff_fc2(si_pbesol_111_222_alm_cutoff_fc2: Phono3py):
|
||||
"""Test phonon smat and ALM with Si PBEsol 1x1x1-2x2x2 cutoff fc2."""
|
||||
ph = si_pbesol_111_222_alm_cutoff_fc2
|
||||
fc3_ref = [
|
||||
[
|
||||
[0.10725082, 0.0, 0.0],
|
||||
[-0.04225275, -0.09187669, -0.1386571],
|
||||
[0.04225275, -0.1386571, -0.09187669],
|
||||
],
|
||||
[
|
||||
[0.04225275, -0.09187669, -0.1386571],
|
||||
[-0.17073504, 0.0, 0.0],
|
||||
[-0.33192165, 0.02516976, 0.02516976],
|
||||
],
|
||||
[
|
||||
[-0.04225275, -0.1386571, -0.09187669],
|
||||
[-0.33192165, -0.02516976, -0.02516976],
|
||||
[-0.17073504, 0.0, 0.0],
|
||||
],
|
||||
]
|
||||
np.testing.assert_allclose(ph.fc3[0, 1, 7], fc3_ref, atol=1e-6, rtol=0)
|
||||
np.testing.assert_allclose(ph.fc2[0, 33], 0, atol=1e-6, rtol=0)
|
||||
|
||||
|
||||
def test_phonon_smat_alm_cutoff_fc3(si_pbesol_111_222_alm_cutoff_fc3: Phono3py):
|
||||
"""Test phonon smat and ALM with Si PBEsol 1x1x1-2x2x2 cutoff fc3."""
|
||||
ph = si_pbesol_111_222_alm_cutoff_fc3
|
||||
np.testing.assert_allclose(ph.fc3[0, 1, 7], 0, atol=1e-6, rtol=0)
|
||||
fc2_ref = [
|
||||
[-0.20333398, -0.0244225, -0.0244225],
|
||||
[-0.0244225, -0.02219682, -0.024112],
|
||||
[-0.0244225, -0.024112, -0.02219682],
|
||||
]
|
||||
np.testing.assert_allclose(ph.fc2[0, 33], fc2_ref, atol=1e-6, rtol=0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pinv_solver", ["numpy", "lapacke"])
|
||||
def test_fc3_lapacke_solver(si_pbesol_111: Phono3py, pinv_solver: str):
|
||||
"""Test fc3 with Si PBEsol 1x1x1 using lapacke solver."""
|
||||
|
|
Loading…
Reference in New Issue