Add a minimum test for ALM fc_calculator

This commit is contained in:
Atsushi Togo 2022-01-07 15:05:55 +09:00
parent 19fc8c7f4f
commit 3bbfc367db
3 changed files with 70 additions and 1 deletions

View File

@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: |
conda install --yes -c conda-forge python=${{ matrix.python-version }}
conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 h5py scipy pytest codecov pytest-cov spglib
conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 h5py scipy pytest codecov pytest-cov spglib alm
pip install https://github.com/phonopy/phonopy/archive/develop.zip --user
- name: Set up phono3py
run: |

View File

@ -131,6 +131,28 @@ def si_pbesol_111(request):
)
@pytest.fixture(scope="session")
def si_pbesol_111_alm(request):
"""Return Phono3py instance of Si 1x1x1.
* with symmetry
* full fc
* use alm if available on test side
"""
pytest.importorskip("alm")
yaml_filename = os.path.join(current_dir, "phono3py_params_Si111.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_iterha_111():
"""Return Phono3py instance of Si 1x1x1.

View File

@ -19,3 +19,50 @@ def test_cutoff_fc3_zero(nacl_pbe):
cutoff_fc3_by_zero(fc3, ph.supercell, 5)
abs_delta = np.abs(ph.fc3 - fc3).sum()
assert np.abs(5259.2234163 - abs_delta) < 1e-3
def test_fc3(si_pbesol_111):
"""Test fc3 with Si PBEsol 1x1x1."""
ph = si_pbesol_111
fc3_ref = [
[
[0.10725082233071165, -3.17309835814091e-17, 9.184999404573031e-17],
[0.008964145692710241, -0.14304691148751, -0.13849893745060796],
[-0.008964145692710304, -0.13849893745060804, -0.14304691148750995],
],
[
[-0.008964145692710266, -0.14304691148750992, -0.13849893745060804],
[-0.03394571572679527, -1.5305320668253703e-17, -2.419577848263484e-17],
[-0.3317461672212566, -0.026002572441157376, -0.026002572441157404],
],
[
[0.008964145692710323, -0.13849893745060782, -0.14304691148750995],
[-0.3317461672212566, 0.026002572441157404, 0.026002572441157387],
[-0.033945715726795195, -1.4289784633358948e-16, 1.3426036902612163e-17],
],
]
np.testing.assert_allclose(ph.fc3[0, 1, 7], fc3_ref, atol=1e-8, rtol=0)
# @pytest.mark.skipif(not FC_CALCULATOR_ALM_AVAILABLE, reason="not found ALM package")
def test_fc3_alm(si_pbesol_111_alm):
"""Test fc3 with Si PBEsol 1x1x1 calcualted using ALM."""
ph = si_pbesol_111_alm
fc3_ref = [
[
[0.10725082233069763, 0.0, 0.0],
[-0.04225274805794354, -0.09187668739926935, -0.13865710308133664],
[0.04225274805794354, -0.13865710308133664, -0.09187668739926935],
],
[
[0.04225274805794354, -0.09187668739926935, -0.13865710308133664],
[-0.17073503897042558, 0.0, 0.0],
[-0.33192165463027573, 0.02516976132993421, 0.02516976132993421],
],
[
[-0.04225274805794354, -0.13865710308133664, -0.09187668739926935],
[-0.33192165463027573, -0.02516976132993421, -0.02516976132993421],
[-0.17073503897042558, 0.0, 0.0],
],
]
np.testing.assert_allclose(ph.fc3[0, 1, 7], fc3_ref, atol=1e-8, rtol=0)