File: test_vasp_xc.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (55 lines) | stat: -rw-r--r-- 1,358 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pytest

calc = pytest.mark.calculator


def dict_is_subset(d1, d2):
    """True if all the key-value pairs in dict 1 are in dict 2"""
    for key, value in d1.items():
        if key not in d2:
            return False
        elif d2[key] != value:
            return False
    else:
        return True


@calc('vasp')
def test_vasp_xc(factory):
    """
    Run some tests to ensure that the xc setting in the VASP calculator
    works.

    """

    calc_vdw = factory.calc(xc='optb86b-vdw')

    assert dict_is_subset({
        'param1': 0.1234,
        'param2': 1.0
    }, calc_vdw.float_params)

    calc_hse = factory.calc(xc='hse06',
                            hfscreen=0.1,
                            gga='RE',
                            encut=400,
                            sigma=0.5)

    assert dict_is_subset({
        'hfscreen': 0.1,
        'encut': 400,
        'sigma': 0.5
    }, calc_hse.float_params)
    assert dict_is_subset({'gga': 'RE'}, calc_hse.string_params)

    calc_pw91 = factory.calc(xc='pw91',
                             kpts=(2, 2, 2),
                             gamma=True,
                             lreal='Auto')
    assert dict_is_subset(
        {
            'pp': 'PW91',
            'kpts': (2, 2, 2),
            'gamma': True,
            'reciprocal': False
        }, calc_pw91.input_params)