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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
# fmt: off
"""Tests for `read_bands`."""
import io
import numpy as np
from ase.io.castep import read_bands, units_CODATA2002
BUF = """\
Number of k-points 4
Number of spin components 2
Number of electrons 5.500 2.500
Number of eigenvalues 10 10
Fermi energies (in atomic units) 0.182885 0.182885
Unit cell vectors
-2.704198 2.704198 2.704198
2.704198 -2.704198 2.704198
2.704198 2.704198 -2.704198
K-point 1 -0.25000000 -0.25000000 -0.25000000 0.25000000
Spin component 1
0.03797397
0.03809342
0.03809342
0.13390429
0.13390430
0.46846377
0.46852514
0.46852514
0.53647671
1.55837771
Spin component 2
0.12773024
0.12785189
0.12785190
0.24697150
0.24697150
0.53413872
0.53422298
0.53422298
0.59174515
1.58602595
K-point 2 -0.25000000 -0.25000000 0.25000000 0.25000000
Spin component 1
-0.00308414
0.06298593
0.08730381
0.08740240
0.11207930
0.17128862
0.76788026
0.76791965
0.79890351
0.87628010
Spin component 2
0.04322315
0.15531185
0.19576154
0.19587468
0.22857350
0.27180878
0.82703085
0.82706954
0.84689967
0.91245541
K-point 3 -0.25000000 0.25000000 0.25000000 0.25000000
Spin component 1
-0.00308413
0.06298593
0.08730382
0.08740240
0.11207930
0.17128862
0.76788026
0.76791964
0.79890351
0.87628010
Spin component 2
0.04322315
0.15531186
0.19576154
0.19587468
0.22857351
0.27180877
0.82703086
0.82706953
0.84689968
0.91245539
K-point 4 0.25000000 -0.25000000 0.25000000 0.25000000
Spin component 1
-0.00308413
0.06298593
0.08730381
0.08740240
0.11207930
0.17128862
0.76788026
0.76791965
0.79890351
0.87628010
Spin component 2
0.04322315
0.15531185
0.19576154
0.19587468
0.22857351
0.27180878
0.82703085
0.82706954
0.84689968
0.91245540
"""
def test_read_bands():
"""Test `read_bands`."""
Hartree = units_CODATA2002['Eh']
kpts, weights, eigenvalues, efermi = read_bands(io.StringIO(BUF))
kpts_ref = [
[-0.25000000, -0.25000000, -0.25000000],
[-0.25000000, -0.25000000, +0.25000000],
[-0.25000000, +0.25000000, +0.25000000],
[+0.25000000, -0.25000000, +0.25000000],
]
weights_ref = [0.25, 0.25, 0.25, 0.25]
eigenvalues_ref0 = [
+0.03797397,
+0.03809342,
+0.03809342,
+0.13390429,
+0.13390430,
+0.46846377,
+0.46852514,
+0.46852514,
+0.53647671,
+1.55837771,
]
eigenvalues_ref1 = [
+0.12773024,
+0.12785189,
+0.12785190,
+0.24697150,
+0.24697150,
+0.53413872,
+0.53422298,
+0.53422298,
+0.59174515,
+1.58602595,
]
efermi_ref = 0.182885
np.testing.assert_allclose(kpts, kpts_ref)
np.testing.assert_allclose(weights, weights_ref)
assert eigenvalues.shape == (2, 4, 10)
np.testing.assert_allclose(eigenvalues[0, 0] / Hartree, eigenvalues_ref0)
np.testing.assert_allclose(eigenvalues[1, 0] / Hartree, eigenvalues_ref1)
np.testing.assert_allclose(efermi / Hartree, efermi_ref)
|