File: test_basis_sets_O4.py

package info (click to toggle)
python-symfc 1.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,980 kB
  • sloc: python: 10,485; makefile: 12
file content (122 lines) | stat: -rw-r--r-- 4,759 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""Tests of FCBasisSetO3."""

from pathlib import Path

import numpy as np
import pytest

from symfc.basis_sets import FCBasisSetO4
from symfc.utils.utils import SymfcAtoms

cwd = Path(__file__).parent


def test_fc_basis_set_o4():
    """Test symmetry adapted basis sets of FCBasisSetO4."""
    a = 5.4335600299999998
    lattice = np.array([[a, 0, 0], [0, a, 0], [0, 0, a]])
    positions = np.array(
        [
            [0.875, 0.875, 0.875],
            [0.875, 0.375, 0.375],
            [0.375, 0.875, 0.375],
            [0.375, 0.375, 0.875],
            [0.125, 0.125, 0.125],
            [0.125, 0.625, 0.625],
            [0.625, 0.125, 0.625],
            [0.625, 0.625, 0.125],
        ]
    )
    numbers = [1, 1, 1, 1, 1, 1, 1, 1]
    supercell = SymfcAtoms(cell=lattice, scaled_positions=positions, numbers=numbers)
    sbs = FCBasisSetO4(supercell, log_level=1).run()

    assert sbs.basis_set.shape[0] == 115
    assert sbs.basis_set.shape[1] == 72
    compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
    assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(18.0)

    sbs = FCBasisSetO4(supercell, cutoff=3.5, log_level=1).run()
    assert sbs.basis_set.shape[0] == 11
    assert sbs.basis_set.shape[1] == 2
    compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
    assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(0.5)


def test_fc_basis_set_o4_wurtzite():
    """Test symmetry adapted basis sets of FCBasisSetO4."""
    lattice = np.array(
        [
            [3.786186160293827, 0, 0],
            [-1.893093080146913, 3.278933398271515, 0],
            [0, 0, 6.212678269409001],
        ]
    )
    positions = np.array(
        [
            [0.333333333333333, 0.666666666666667, 0.002126465711614],
            [0.666666666666667, 0.333333333333333, 0.502126465711614],
            [0.333333333333333, 0.666666666666667, 0.376316514288389],
            [0.666666666666667, 0.333333333333333, 0.876316514288389],
        ]
    )
    numbers = [1, 1, 2, 2]
    supercell = SymfcAtoms(cell=lattice, scaled_positions=positions, numbers=numbers)
    sbs = FCBasisSetO4(supercell, log_level=1).run()

    assert sbs.basis_set.shape[0] == 120
    assert sbs.basis_set.shape[1] == 34
    compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
    assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(34.0)

    sbs = FCBasisSetO4(supercell, cutoff=3.0, log_level=1).run()
    assert sbs.basis_set.shape[0] == 34
    assert sbs.basis_set.shape[1] == 2
    compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
    assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(2.0)


def test_fc_basis_set_o3_wurtzite_221():
    """Test symmetry adapted basis sets of FCBasisSetO3."""
    lattice = np.array(
        [
            [7.572372320587654, 0.0, 0.0],
            [-3.786186160293826, 6.55786679654303, 0.0],
            [0.0, 0.0, 6.212678269409001],
        ]
    )
    positions = np.array(
        [
            [0.166666666666666, 0.333333333333333, 0.002126465711614],
            [0.666666666666667, 0.333333333333333, 0.002126465711614],
            [0.166666666666666, 0.833333333333333, 0.002126465711614],
            [0.666666666666667, 0.833333333333333, 0.002126465711614],
            [0.333333333333333, 0.166666666666666, 0.502126465711614],
            [0.833333333333333, 0.166666666666666, 0.502126465711614],
            [0.333333333333333, 0.666666666666667, 0.502126465711614],
            [0.833333333333333, 0.666666666666667, 0.502126465711614],
            [0.166666666666666, 0.333333333333333, 0.376316514288389],
            [0.666666666666667, 0.333333333333333, 0.376316514288389],
            [0.166666666666666, 0.833333333333333, 0.376316514288389],
            [0.666666666666667, 0.833333333333333, 0.376316514288389],
            [0.333333333333333, 0.166666666666666, 0.876316514288389],
            [0.833333333333333, 0.166666666666666, 0.876316514288389],
            [0.333333333333333, 0.666666666666667, 0.876316514288389],
            [0.833333333333333, 0.666666666666667, 0.876316514288389],
        ]
    )
    numbers = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]
    supercell = SymfcAtoms(cell=lattice, scaled_positions=positions, numbers=numbers)

    """
    sbs = FCBasisSetO4(supercell, cutoff=4.5, log_level=1).run()
    assert sbs.basis_set.shape[0] == 3733
    assert sbs.basis_set.shape[1] == 2749
    """
    sbs = FCBasisSetO4(supercell, cutoff=4.0, log_level=1).run()
    assert sbs.basis_set.shape[0] == 948
    assert sbs.basis_set.shape[1] == 515

    sbs = FCBasisSetO4(supercell, cutoff=3.5, log_level=1).run()
    assert sbs.basis_set.shape[0] == 61
    assert sbs.basis_set.shape[1] == 4