File: test_phonopy_load.py

package info (click to toggle)
phonopy 2.48.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,556 kB
  • sloc: python: 44,403; xml: 12,080; ansic: 3,227; cpp: 525; sh: 213; makefile: 20
file content (36 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Tests of Phonopy API."""

from pathlib import Path

import pytest

import phonopy

cwd = Path(__file__).parent


def test_unit_conversion_factor():
    """Test phonopy_load with phonopy_params.yaml."""
    ph = phonopy.load(
        cwd / ".." / "phonopy_params_NaCl-fd.yaml.xz", produce_fc=False, log_level=2
    )
    assert ph.calculator is None
    assert ph.unit_conversion_factor == pytest.approx(15.6333023)

    with pytest.warns(DeprecationWarning):
        ph = phonopy.load(
            cwd / ".." / "phonopy_params_NaCl-fd.yaml.xz",
            factor=100,
            produce_fc=False,
            log_level=2,
        )
        assert ph.unit_conversion_factor == pytest.approx(100)


def test_unit_conversion_factor_QE():
    """Test phonopy_load with QE phonopy_params.yaml."""
    ph = phonopy.load(
        cwd / ".." / "phonopy_params_NaCl-QE.yaml.xz", produce_fc=False, log_level=2
    )
    assert ph.calculator == "qe"
    assert ph.unit_conversion_factor == pytest.approx(108.9707718)