3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 04:13:47 +01:00

Added several tests

Tests for 'select_bands()' and class 'ProjectorShell' have been added.
The function and class methods have been fixed accordingly to pass
the tests.
This commit is contained in:
Oleg E. Peil 2015-02-19 16:18:01 +01:00 committed by Michel Ferrero
parent 90c93c4693
commit 5c3b3d0b8d
17 changed files with 2881 additions and 5 deletions

View File

@ -93,7 +93,13 @@ def select_bands(eigvals, emin, emax):
ib_win, nb_min, nb_max : ib_win, nb_min, nb_max :
""" """
# Sanity check
if emin > eigvals.max() or emax < eigvals.min():
raise Exception("Energy window does not overlap with the band structure")
nk, nband, ns_band = eigvals.shape nk, nband, ns_band = eigvals.shape
print nk, nband, ns_band
print emin, emax
ib_win = np.zeros((nk, ns_band, 2), dtype=np.int32) ib_win = np.zeros((nk, ns_band, 2), dtype=np.int32)
nb_min = 10000000 nb_min = 10000000
@ -105,11 +111,14 @@ def select_bands(eigvals, emin, emax):
if en >= emin: if en >= emin:
break break
ib1 = ib ib1 = ib
for ib in xrange(ib1, nb_max): for ib in xrange(ib1, nband):
en = eigvals[ik, ib, isp] en = eigvals[ik, ib, isp]
if en <= emax: if en > emax:
break break
ib2 = ib else:
# If we reached the last band add 1 to get the correct bound
ib += 1
ib2 = ib - 1
ib_win[ik, isp, 0] = ib1 ib_win[ik, isp, 0] = ib1
ib_win[ik, isp, 1] = ib2 ib_win[ik, isp, 1] = ib2
@ -248,7 +257,7 @@ class ProjectorShell:
self.lm2 = (self.lorb+1)**2 self.lm2 = (self.lorb+1)**2
# Pre-select a subset of projectors (this should be an array view => no memory is wasted) # Pre-select a subset of projectors (this should be an array view => no memory is wasted)
self.proj_arr = proj_raw[self.ion_list, :, :, :, lm1:lm2] self.proj_arr = proj_raw[self.ion_list, :, :, :, self.lm1:self.lm2]
################################################################################ ################################################################################
# #
@ -282,6 +291,7 @@ class ProjectorShell:
self.proj_win[:, isp, ik, ib1_win:ib2_win, :] = self.proj_arr[:, isp, ik, ib1:ib2, :] self.proj_win[:, isp, ik, ib1_win:ib2_win, :] = self.proj_arr[:, isp, ik, ib1:ib2, :]
# !!! This sucks but I have to change the order of 'ib' and 'ilm' indices here # !!! This sucks but I have to change the order of 'ib' and 'ilm' indices here
# This should perhaps be done right after the projector array is read from PLOCAR
self.proj_win.transpose((0, 1, 2, 4, 3)) self.proj_win.transpose((0, 1, 2, 4, 3))

View File

@ -271,7 +271,7 @@ class Kpoints:
line = ibz_file.next() line = ibz_file.next()
self.itet[it, :] = map(int, line.split()[:5]) self.itet[it, :] = map(int, line.split()[:5])
except StopIteration, ValueError: except StopIteration, ValueError:
print " Error reading tetrahedra. No tetrahedron data is used" print " No tetrahedron data found in %s. Skipping..."%(ibz_filename)
self.ntet = 0 self.ntet = 0
# data = { 'nktot': nktot, # data = { 'nktot': nktot,

View File

@ -0,0 +1,2 @@
*.pyc
*.test

View File

@ -0,0 +1,609 @@
1 1 1 0
0.1333597E+02 0.2587511E-09 0.2587511E-09 0.2587511E-09 0.5000000E-15
1.000000000000000E-004
CAR
V
17.10090628 -34.14880953 301 5.84395237 1.00000000
-34.149 0.0000E+00 0.0000E+00
-33.978 0.0000E+00 0.0000E+00
-33.807 0.0000E+00 0.0000E+00
-33.636 0.0000E+00 0.0000E+00
-33.465 0.0000E+00 0.0000E+00
-33.295 0.0000E+00 0.0000E+00
-33.124 0.0000E+00 0.0000E+00
-32.953 0.0000E+00 0.0000E+00
-32.782 0.3428E-37 0.5857E-38
-32.611 0.1961E-24 0.3349E-25
-32.440 0.2784E-14 0.4757E-15
-32.270 0.8681E-07 0.1483E-07
-32.099 0.3941E-02 0.6732E-03
-31.928 -0.2188E+00 -0.3670E-01
-31.757 0.8736E+01 0.1456E+01
-31.586 0.8403E+01 0.2891E+01
-31.415 0.2792E+01 0.3368E+01
-31.245 0.6307E+01 0.4445E+01
-31.074 0.7856E+01 0.5787E+01
-30.903 0.1212E+01 0.5994E+01
-30.732 0.3246E-01 0.6000E+01
-30.561 0.3448E-04 0.6000E+01
-30.390 0.2050E-10 0.6000E+01
-30.220 0.0000E+00 0.6000E+01
-30.049 0.0000E+00 0.6000E+01
-29.878 0.0000E+00 0.6000E+01
-29.707 0.0000E+00 0.6000E+01
-29.536 0.0000E+00 0.6000E+01
-29.366 0.0000E+00 0.6000E+01
-29.195 0.0000E+00 0.6000E+01
-29.024 0.0000E+00 0.6000E+01
-28.853 0.0000E+00 0.6000E+01
-28.682 0.0000E+00 0.6000E+01
-28.511 0.0000E+00 0.6000E+01
-28.341 0.0000E+00 0.6000E+01
-28.170 0.0000E+00 0.6000E+01
-27.999 0.0000E+00 0.6000E+01
-27.828 0.0000E+00 0.6000E+01
-27.657 0.0000E+00 0.6000E+01
-27.486 0.0000E+00 0.6000E+01
-27.316 0.0000E+00 0.6000E+01
-27.145 0.0000E+00 0.6000E+01
-26.974 0.0000E+00 0.6000E+01
-26.803 0.0000E+00 0.6000E+01
-26.632 0.0000E+00 0.6000E+01
-26.461 0.0000E+00 0.6000E+01
-26.291 0.0000E+00 0.6000E+01
-26.120 0.0000E+00 0.6000E+01
-25.949 0.0000E+00 0.6000E+01
-25.778 0.0000E+00 0.6000E+01
-25.607 0.0000E+00 0.6000E+01
-25.436 0.0000E+00 0.6000E+01
-25.266 0.0000E+00 0.6000E+01
-25.095 0.0000E+00 0.6000E+01
-24.924 0.0000E+00 0.6000E+01
-24.753 0.0000E+00 0.6000E+01
-24.582 0.0000E+00 0.6000E+01
-24.411 0.0000E+00 0.6000E+01
-24.241 0.0000E+00 0.6000E+01
-24.070 0.0000E+00 0.6000E+01
-23.899 0.0000E+00 0.6000E+01
-23.728 0.0000E+00 0.6000E+01
-23.557 0.0000E+00 0.6000E+01
-23.386 0.0000E+00 0.6000E+01
-23.216 0.0000E+00 0.6000E+01
-23.045 0.0000E+00 0.6000E+01
-22.874 0.0000E+00 0.6000E+01
-22.703 0.0000E+00 0.6000E+01
-22.532 0.0000E+00 0.6000E+01
-22.361 0.0000E+00 0.6000E+01
-22.191 0.0000E+00 0.6000E+01
-22.020 0.0000E+00 0.6000E+01
-21.849 0.0000E+00 0.6000E+01
-21.678 0.0000E+00 0.6000E+01
-21.507 0.0000E+00 0.6000E+01
-21.336 0.0000E+00 0.6000E+01
-21.166 0.0000E+00 0.6000E+01
-20.995 0.0000E+00 0.6000E+01
-20.824 0.0000E+00 0.6000E+01
-20.653 0.0000E+00 0.6000E+01
-20.482 0.0000E+00 0.6000E+01
-20.311 0.0000E+00 0.6000E+01
-20.141 0.0000E+00 0.6000E+01
-19.970 0.0000E+00 0.6000E+01
-19.799 0.0000E+00 0.6000E+01
-19.628 0.0000E+00 0.6000E+01
-19.457 0.0000E+00 0.6000E+01
-19.286 0.0000E+00 0.6000E+01
-19.116 0.0000E+00 0.6000E+01
-18.945 0.0000E+00 0.6000E+01
-18.774 0.0000E+00 0.6000E+01
-18.603 0.0000E+00 0.6000E+01
-18.432 0.0000E+00 0.6000E+01
-18.261 0.0000E+00 0.6000E+01
-18.091 0.0000E+00 0.6000E+01
-17.920 0.0000E+00 0.6000E+01
-17.749 0.0000E+00 0.6000E+01
-17.578 0.0000E+00 0.6000E+01
-17.407 0.0000E+00 0.6000E+01
-17.236 0.0000E+00 0.6000E+01
-17.066 0.0000E+00 0.6000E+01
-16.895 0.0000E+00 0.6000E+01
-16.724 0.0000E+00 0.6000E+01
-16.553 0.0000E+00 0.6000E+01
-16.382 0.0000E+00 0.6000E+01
-16.211 0.0000E+00 0.6000E+01
-16.041 0.0000E+00 0.6000E+01
-15.870 0.0000E+00 0.6000E+01
-15.699 0.0000E+00 0.6000E+01
-15.528 0.0000E+00 0.6000E+01
-15.357 0.0000E+00 0.6000E+01
-15.186 0.0000E+00 0.6000E+01
-15.016 0.0000E+00 0.6000E+01
-14.845 0.0000E+00 0.6000E+01
-14.674 0.0000E+00 0.6000E+01
-14.503 0.0000E+00 0.6000E+01
-14.332 0.0000E+00 0.6000E+01
-14.161 0.0000E+00 0.6000E+01
-13.991 0.0000E+00 0.6000E+01
-13.820 0.0000E+00 0.6000E+01
-13.649 0.0000E+00 0.6000E+01
-13.478 0.0000E+00 0.6000E+01
-13.307 0.0000E+00 0.6000E+01
-13.136 0.0000E+00 0.6000E+01
-12.966 0.0000E+00 0.6000E+01
-12.795 0.0000E+00 0.6000E+01
-12.624 0.0000E+00 0.6000E+01
-12.453 0.0000E+00 0.6000E+01
-12.282 0.0000E+00 0.6000E+01
-12.111 0.0000E+00 0.6000E+01
-11.941 0.0000E+00 0.6000E+01
-11.770 0.0000E+00 0.6000E+01
-11.599 0.0000E+00 0.6000E+01
-11.428 0.0000E+00 0.6000E+01
-11.257 0.0000E+00 0.6000E+01
-11.086 0.0000E+00 0.6000E+01
-10.916 0.0000E+00 0.6000E+01
-10.745 0.0000E+00 0.6000E+01
-10.574 0.0000E+00 0.6000E+01
-10.403 0.0000E+00 0.6000E+01
-10.232 0.0000E+00 0.6000E+01
-10.061 0.0000E+00 0.6000E+01
-9.891 0.0000E+00 0.6000E+01
-9.720 0.0000E+00 0.6000E+01
-9.549 0.0000E+00 0.6000E+01
-9.378 0.0000E+00 0.6000E+01
-9.207 0.0000E+00 0.6000E+01
-9.036 0.0000E+00 0.6000E+01
-8.866 0.0000E+00 0.6000E+01
-8.695 0.0000E+00 0.6000E+01
-8.524 0.0000E+00 0.6000E+01
-8.353 0.0000E+00 0.6000E+01
-8.182 0.0000E+00 0.6000E+01
-8.011 0.0000E+00 0.6000E+01
-7.841 0.0000E+00 0.6000E+01
-7.670 0.0000E+00 0.6000E+01
-7.499 0.0000E+00 0.6000E+01
-7.328 0.0000E+00 0.6000E+01
-7.157 0.0000E+00 0.6000E+01
-6.986 0.0000E+00 0.6000E+01
-6.816 0.0000E+00 0.6000E+01
-6.645 0.0000E+00 0.6000E+01
-6.474 0.0000E+00 0.6000E+01
-6.303 0.0000E+00 0.6000E+01
-6.132 0.0000E+00 0.6000E+01
-5.961 0.0000E+00 0.6000E+01
-5.791 0.0000E+00 0.6000E+01
-5.620 0.0000E+00 0.6000E+01
-5.449 0.0000E+00 0.6000E+01
-5.278 0.0000E+00 0.6000E+01
-5.107 0.0000E+00 0.6000E+01
-4.936 0.0000E+00 0.6000E+01
-4.766 0.0000E+00 0.6000E+01
-4.595 0.0000E+00 0.6000E+01
-4.424 0.0000E+00 0.6000E+01
-4.253 0.0000E+00 0.6000E+01
-4.082 0.0000E+00 0.6000E+01
-3.911 0.0000E+00 0.6000E+01
-3.741 0.0000E+00 0.6000E+01
-3.570 0.0000E+00 0.6000E+01
-3.399 0.0000E+00 0.6000E+01
-3.228 0.0000E+00 0.6000E+01
-3.057 0.0000E+00 0.6000E+01
-2.886 0.0000E+00 0.6000E+01
-2.716 0.0000E+00 0.6000E+01
-2.545 0.0000E+00 0.6000E+01
-2.374 0.0000E+00 0.6000E+01
-2.203 0.0000E+00 0.6000E+01
-2.032 0.0000E+00 0.6000E+01
-1.861 0.0000E+00 0.6000E+01
-1.691 0.1508E-31 0.6000E+01
-1.520 0.4300E-20 0.6000E+01
-1.349 0.2901E-11 0.6000E+01
-1.178 0.3715E-05 0.6000E+01
-1.007 0.2036E-02 0.6000E+01
-0.836 0.1134E+00 0.6020E+01
-0.666 0.3236E+00 0.6075E+01
-0.495 -0.5496E-02 0.6074E+01
-0.324 0.5193E-04 0.6074E+01
-0.153 0.2420E-09 0.6074E+01
0.018 0.0000E+00 0.6074E+01
0.189 0.0000E+00 0.6074E+01
0.359 0.0000E+00 0.6074E+01
0.530 0.0000E+00 0.6074E+01
0.701 0.0000E+00 0.6074E+01
0.872 0.0000E+00 0.6074E+01
1.043 0.0000E+00 0.6074E+01
1.213 0.0000E+00 0.6074E+01
1.384 0.1441E-25 0.6074E+01
1.555 0.3694E-15 0.6074E+01
1.726 0.2113E-07 0.6074E+01
1.897 0.1843E-02 0.6074E+01
2.068 -0.1717E+00 0.6045E+01
2.238 0.4911E+01 0.6884E+01
2.409 0.4385E+00 0.6959E+01
2.580 0.2317E-01 0.6963E+01
2.751 0.1027E-04 0.6963E+01
2.922 0.1649E-07 0.6963E+01
3.093 0.1161E-02 0.6963E+01
3.263 -0.9886E-01 0.6946E+01
3.434 0.2549E+01 0.7382E+01
3.605 0.1134E+00 0.7401E+01
3.776 0.1880E+01 0.7722E+01
3.947 0.1410E+01 0.7963E+01
4.118 0.2885E+01 0.8456E+01
4.288 -0.6849E-01 0.8444E+01
4.459 0.1593E-01 0.8447E+01
4.630 -0.3213E+00 0.8392E+01
4.801 0.1107E+02 0.1028E+02
4.972 0.1346E+01 0.1051E+02
5.143 0.3027E-01 0.1052E+02
5.313 0.6891E-04 0.1052E+02
5.484 0.8093E-04 0.1052E+02
5.655 0.1912E-01 0.1052E+02
5.826 0.1840E+01 0.1084E+02
5.997 0.4326E+01 0.1158E+02
6.168 0.3115E+00 0.1163E+02
6.338 0.6462E-02 0.1163E+02
6.509 0.1132E-04 0.1163E+02
6.680 0.8927E-11 0.1163E+02
6.851 0.7510E-09 0.1163E+02
7.022 0.2862E-03 0.1163E+02
7.193 -0.1755E-01 0.1163E+02
7.363 0.3080E+01 0.1215E+02
7.534 0.2128E+01 0.1252E+02
7.705 -0.1424E+00 0.1249E+02
7.876 0.4758E+01 0.1330E+02
8.047 0.1429E+01 0.1355E+02
8.218 0.4090E+01 0.1425E+02
8.388 0.9009E+01 0.1579E+02
8.559 0.2760E+01 0.1626E+02
8.730 0.4220E+01 0.1698E+02
8.901 -0.9675E-01 0.1696E+02
9.072 0.8982E-03 0.1696E+02
9.243 0.5584E-08 0.1696E+02
9.413 0.0000E+00 0.1696E+02
9.584 0.0000E+00 0.1696E+02
9.755 0.0000E+00 0.1696E+02
9.926 0.0000E+00 0.1696E+02
10.097 0.4864E-37 0.1696E+02
10.268 0.2294E-24 0.1696E+02
10.438 0.2678E-14 0.1696E+02
10.609 0.6806E-07 0.1696E+02
10.780 0.2349E-02 0.1696E+02
10.951 -0.1323E+00 0.1694E+02
11.122 0.2769E+01 0.1741E+02
11.293 -0.4470E-01 0.1741E+02
11.463 0.7455E-02 0.1741E+02
11.634 0.1064E-05 0.1741E+02
11.805 0.1554E-12 0.1741E+02
11.976 0.0000E+00 0.1741E+02
12.147 0.0000E+00 0.1741E+02
12.318 0.0000E+00 0.1741E+02
12.488 0.0000E+00 0.1741E+02
12.659 0.0000E+00 0.1741E+02
12.830 0.0000E+00 0.1741E+02
13.001 0.0000E+00 0.1741E+02
13.172 0.0000E+00 0.1741E+02
13.343 0.0000E+00 0.1741E+02
13.513 0.0000E+00 0.1741E+02
13.684 0.0000E+00 0.1741E+02
13.855 0.1244E-33 0.1741E+02
14.026 0.1396E-21 0.1741E+02
14.197 0.3803E-12 0.1741E+02
14.368 0.2119E-05 0.1741E+02
14.538 0.1137E-01 0.1741E+02
14.709 0.3659E-02 0.1741E+02
14.880 0.3617E+01 0.1803E+02
15.051 -0.1653E+00 0.1800E+02
15.222 0.2517E-02 0.1800E+02
15.393 0.5772E-07 0.1800E+02
15.563 0.1926E-14 0.1800E+02
15.734 0.0000E+00 0.1800E+02
15.905 0.0000E+00 0.1800E+02
16.076 0.0000E+00 0.1800E+02
16.247 0.0000E+00 0.1800E+02
16.418 0.0000E+00 0.1800E+02
16.588 0.0000E+00 0.1800E+02
16.759 0.0000E+00 0.1800E+02
16.930 0.0000E+00 0.1800E+02
17.101 0.0000E+00 0.1800E+02
17.10090628 -34.14880953 301 5.84395237 1.00000000
-34.149 0.0000E+00 0.0000E+00 0.0000E+00
-33.978 0.0000E+00 0.0000E+00 0.0000E+00
-33.807 0.0000E+00 0.0000E+00 0.0000E+00
-33.636 0.0000E+00 0.0000E+00 0.0000E+00
-33.465 0.0000E+00 0.0000E+00 0.0000E+00
-33.295 0.0000E+00 0.0000E+00 0.0000E+00
-33.124 0.0000E+00 0.0000E+00 0.0000E+00
-32.953 0.0000E+00 0.0000E+00 0.0000E+00
-32.782 0.2282E-40 0.3359E-37 0.5411E-41
-32.611 0.1305E-27 0.1921E-24 0.3095E-28
-32.440 0.1853E-17 0.2728E-14 0.4398E-18
-32.270 0.5762E-10 0.8504E-07 0.1383E-10
-32.099 0.2518E-05 0.3861E-02 0.7137E-06
-31.928 -0.1566E-03 -0.2142E+00 -0.2459E-04
-31.757 0.3856E-02 0.8567E+01 0.3103E-02
-31.586 0.1543E-02 0.8270E+01 0.4254E-02
-31.415 -0.3177E-04 0.2760E+01 0.1220E-02
-31.245 0.3742E-04 0.6273E+01 0.1032E-02
-31.074 0.1298E-03 0.7836E+01 0.2060E-03
-30.903 -0.2630E-05 0.1210E+01 -0.3012E-05
-30.732 0.2432E-07 0.3240E-01 0.4557E-07
-30.561 0.1332E-12 0.3442E-04 0.2841E-12
-30.390 0.2660E-32 0.2046E-10 0.1981E-19
-30.220 0.0000E+00 0.0000E+00 0.0000E+00
-30.049 0.0000E+00 0.0000E+00 0.0000E+00
-29.878 0.0000E+00 0.0000E+00 0.0000E+00
-29.707 0.0000E+00 0.0000E+00 0.0000E+00
-29.536 0.0000E+00 0.0000E+00 0.0000E+00
-29.366 0.0000E+00 0.0000E+00 0.0000E+00
-29.195 0.0000E+00 0.0000E+00 0.0000E+00
-29.024 0.0000E+00 0.0000E+00 0.0000E+00
-28.853 0.0000E+00 0.0000E+00 0.0000E+00
-28.682 0.0000E+00 0.0000E+00 0.0000E+00
-28.511 0.0000E+00 0.0000E+00 0.0000E+00
-28.341 0.0000E+00 0.0000E+00 0.0000E+00
-28.170 0.0000E+00 0.0000E+00 0.0000E+00
-27.999 0.0000E+00 0.0000E+00 0.0000E+00
-27.828 0.0000E+00 0.0000E+00 0.0000E+00
-27.657 0.0000E+00 0.0000E+00 0.0000E+00
-27.486 0.0000E+00 0.0000E+00 0.0000E+00
-27.316 0.0000E+00 0.0000E+00 0.0000E+00
-27.145 0.0000E+00 0.0000E+00 0.0000E+00
-26.974 0.0000E+00 0.0000E+00 0.0000E+00
-26.803 0.0000E+00 0.0000E+00 0.0000E+00
-26.632 0.0000E+00 0.0000E+00 0.0000E+00
-26.461 0.0000E+00 0.0000E+00 0.0000E+00
-26.291 0.0000E+00 0.0000E+00 0.0000E+00
-26.120 0.0000E+00 0.0000E+00 0.0000E+00
-25.949 0.0000E+00 0.0000E+00 0.0000E+00
-25.778 0.0000E+00 0.0000E+00 0.0000E+00
-25.607 0.0000E+00 0.0000E+00 0.0000E+00
-25.436 0.0000E+00 0.0000E+00 0.0000E+00
-25.266 0.0000E+00 0.0000E+00 0.0000E+00
-25.095 0.0000E+00 0.0000E+00 0.0000E+00
-24.924 0.0000E+00 0.0000E+00 0.0000E+00
-24.753 0.0000E+00 0.0000E+00 0.0000E+00
-24.582 0.0000E+00 0.0000E+00 0.0000E+00
-24.411 0.0000E+00 0.0000E+00 0.0000E+00
-24.241 0.0000E+00 0.0000E+00 0.0000E+00
-24.070 0.0000E+00 0.0000E+00 0.0000E+00
-23.899 0.0000E+00 0.0000E+00 0.0000E+00
-23.728 0.0000E+00 0.0000E+00 0.0000E+00
-23.557 0.0000E+00 0.0000E+00 0.0000E+00
-23.386 0.0000E+00 0.0000E+00 0.0000E+00
-23.216 0.0000E+00 0.0000E+00 0.0000E+00
-23.045 0.0000E+00 0.0000E+00 0.0000E+00
-22.874 0.0000E+00 0.0000E+00 0.0000E+00
-22.703 0.0000E+00 0.0000E+00 0.0000E+00
-22.532 0.0000E+00 0.0000E+00 0.0000E+00
-22.361 0.0000E+00 0.0000E+00 0.0000E+00
-22.191 0.0000E+00 0.0000E+00 0.0000E+00
-22.020 0.0000E+00 0.0000E+00 0.0000E+00
-21.849 0.0000E+00 0.0000E+00 0.0000E+00
-21.678 0.0000E+00 0.0000E+00 0.0000E+00
-21.507 0.0000E+00 0.0000E+00 0.0000E+00
-21.336 0.0000E+00 0.0000E+00 0.0000E+00
-21.166 0.0000E+00 0.0000E+00 0.0000E+00
-20.995 0.0000E+00 0.0000E+00 0.0000E+00
-20.824 0.0000E+00 0.0000E+00 0.0000E+00
-20.653 0.0000E+00 0.0000E+00 0.0000E+00
-20.482 0.0000E+00 0.0000E+00 0.0000E+00
-20.311 0.0000E+00 0.0000E+00 0.0000E+00
-20.141 0.0000E+00 0.0000E+00 0.0000E+00
-19.970 0.0000E+00 0.0000E+00 0.0000E+00
-19.799 0.0000E+00 0.0000E+00 0.0000E+00
-19.628 0.0000E+00 0.0000E+00 0.0000E+00
-19.457 0.0000E+00 0.0000E+00 0.0000E+00
-19.286 0.0000E+00 0.0000E+00 0.0000E+00
-19.116 0.0000E+00 0.0000E+00 0.0000E+00
-18.945 0.0000E+00 0.0000E+00 0.0000E+00
-18.774 0.0000E+00 0.0000E+00 0.0000E+00
-18.603 0.0000E+00 0.0000E+00 0.0000E+00
-18.432 0.0000E+00 0.0000E+00 0.0000E+00
-18.261 0.0000E+00 0.0000E+00 0.0000E+00
-18.091 0.0000E+00 0.0000E+00 0.0000E+00
-17.920 0.0000E+00 0.0000E+00 0.0000E+00
-17.749 0.0000E+00 0.0000E+00 0.0000E+00
-17.578 0.0000E+00 0.0000E+00 0.0000E+00
-17.407 0.0000E+00 0.0000E+00 0.0000E+00
-17.236 0.0000E+00 0.0000E+00 0.0000E+00
-17.066 0.0000E+00 0.0000E+00 0.0000E+00
-16.895 0.0000E+00 0.0000E+00 0.0000E+00
-16.724 0.0000E+00 0.0000E+00 0.0000E+00
-16.553 0.0000E+00 0.0000E+00 0.0000E+00
-16.382 0.0000E+00 0.0000E+00 0.0000E+00
-16.211 0.0000E+00 0.0000E+00 0.0000E+00
-16.041 0.0000E+00 0.0000E+00 0.0000E+00
-15.870 0.0000E+00 0.0000E+00 0.0000E+00
-15.699 0.0000E+00 0.0000E+00 0.0000E+00
-15.528 0.0000E+00 0.0000E+00 0.0000E+00
-15.357 0.0000E+00 0.0000E+00 0.0000E+00
-15.186 0.0000E+00 0.0000E+00 0.0000E+00
-15.016 0.0000E+00 0.0000E+00 0.0000E+00
-14.845 0.0000E+00 0.0000E+00 0.0000E+00
-14.674 0.0000E+00 0.0000E+00 0.0000E+00
-14.503 0.0000E+00 0.0000E+00 0.0000E+00
-14.332 0.0000E+00 0.0000E+00 0.0000E+00
-14.161 0.0000E+00 0.0000E+00 0.0000E+00
-13.991 0.0000E+00 0.0000E+00 0.0000E+00
-13.820 0.0000E+00 0.0000E+00 0.0000E+00
-13.649 0.0000E+00 0.0000E+00 0.0000E+00
-13.478 0.0000E+00 0.0000E+00 0.0000E+00
-13.307 0.0000E+00 0.0000E+00 0.0000E+00
-13.136 0.0000E+00 0.0000E+00 0.0000E+00
-12.966 0.0000E+00 0.0000E+00 0.0000E+00
-12.795 0.0000E+00 0.0000E+00 0.0000E+00
-12.624 0.0000E+00 0.0000E+00 0.0000E+00
-12.453 0.0000E+00 0.0000E+00 0.0000E+00
-12.282 0.0000E+00 0.0000E+00 0.0000E+00
-12.111 0.0000E+00 0.0000E+00 0.0000E+00
-11.941 0.0000E+00 0.0000E+00 0.0000E+00
-11.770 0.0000E+00 0.0000E+00 0.0000E+00
-11.599 0.0000E+00 0.0000E+00 0.0000E+00
-11.428 0.0000E+00 0.0000E+00 0.0000E+00
-11.257 0.0000E+00 0.0000E+00 0.0000E+00
-11.086 0.0000E+00 0.0000E+00 0.0000E+00
-10.916 0.0000E+00 0.0000E+00 0.0000E+00
-10.745 0.0000E+00 0.0000E+00 0.0000E+00
-10.574 0.0000E+00 0.0000E+00 0.0000E+00
-10.403 0.0000E+00 0.0000E+00 0.0000E+00
-10.232 0.0000E+00 0.0000E+00 0.0000E+00
-10.061 0.0000E+00 0.0000E+00 0.0000E+00
-9.891 0.0000E+00 0.0000E+00 0.0000E+00
-9.720 0.0000E+00 0.0000E+00 0.0000E+00
-9.549 0.0000E+00 0.0000E+00 0.0000E+00
-9.378 0.0000E+00 0.0000E+00 0.0000E+00
-9.207 0.0000E+00 0.0000E+00 0.0000E+00
-9.036 0.0000E+00 0.0000E+00 0.0000E+00
-8.866 0.0000E+00 0.0000E+00 0.0000E+00
-8.695 0.0000E+00 0.0000E+00 0.0000E+00
-8.524 0.0000E+00 0.0000E+00 0.0000E+00
-8.353 0.0000E+00 0.0000E+00 0.0000E+00
-8.182 0.0000E+00 0.0000E+00 0.0000E+00
-8.011 0.0000E+00 0.0000E+00 0.0000E+00
-7.841 0.0000E+00 0.0000E+00 0.0000E+00
-7.670 0.0000E+00 0.0000E+00 0.0000E+00
-7.499 0.0000E+00 0.0000E+00 0.0000E+00
-7.328 0.0000E+00 0.0000E+00 0.0000E+00
-7.157 0.0000E+00 0.0000E+00 0.0000E+00
-6.986 0.0000E+00 0.0000E+00 0.0000E+00
-6.816 0.0000E+00 0.0000E+00 0.0000E+00
-6.645 0.0000E+00 0.0000E+00 0.0000E+00
-6.474 0.0000E+00 0.0000E+00 0.0000E+00
-6.303 0.0000E+00 0.0000E+00 0.0000E+00
-6.132 0.0000E+00 0.0000E+00 0.0000E+00
-5.961 0.0000E+00 0.0000E+00 0.0000E+00
-5.791 0.0000E+00 0.0000E+00 0.0000E+00
-5.620 0.0000E+00 0.0000E+00 0.0000E+00
-5.449 0.0000E+00 0.0000E+00 0.0000E+00
-5.278 0.0000E+00 0.0000E+00 0.0000E+00
-5.107 0.0000E+00 0.0000E+00 0.0000E+00
-4.936 0.0000E+00 0.0000E+00 0.0000E+00
-4.766 0.0000E+00 0.0000E+00 0.0000E+00
-4.595 0.0000E+00 0.0000E+00 0.0000E+00
-4.424 0.0000E+00 0.0000E+00 0.0000E+00
-4.253 0.0000E+00 0.0000E+00 0.0000E+00
-4.082 0.0000E+00 0.0000E+00 0.0000E+00
-3.911 0.0000E+00 0.0000E+00 0.0000E+00
-3.741 0.0000E+00 0.0000E+00 0.0000E+00
-3.570 0.0000E+00 0.0000E+00 0.0000E+00
-3.399 0.0000E+00 0.0000E+00 0.0000E+00
-3.228 0.0000E+00 0.0000E+00 0.0000E+00
-3.057 0.0000E+00 0.0000E+00 0.0000E+00
-2.886 0.0000E+00 0.0000E+00 0.0000E+00
-2.716 0.0000E+00 0.0000E+00 0.0000E+00
-2.545 0.0000E+00 0.0000E+00 0.0000E+00
-2.374 0.0000E+00 0.0000E+00 0.0000E+00
-2.203 0.0000E+00 0.0000E+00 0.0000E+00
-2.032 0.0000E+00 0.0000E+00 0.0000E+00
-1.861 0.0000E+00 0.0000E+00 0.0000E+00
-1.691 0.8099E-32 0.1367E-62 0.1622E-42
-1.520 0.2309E-20 0.3896E-51 0.4625E-31
-1.349 0.1558E-11 0.2629E-42 0.3121E-22
-1.178 0.1995E-05 0.3366E-36 0.3996E-16
-1.007 0.1093E-02 0.1845E-33 0.2190E-13
-0.836 0.6089E-01 0.1027E-31 0.1220E-11
-0.666 0.1738E+00 0.2932E-31 0.3481E-11
-0.495 -0.2951E-02 -0.4980E-33 -0.5912E-13
-0.324 0.2789E-04 0.4705E-35 0.5586E-15
-0.153 0.1299E-09 0.2193E-40 0.2603E-20
0.018 0.0000E+00 0.0000E+00 0.0000E+00
0.189 0.0000E+00 0.0000E+00 0.0000E+00
0.359 0.0000E+00 0.0000E+00 0.0000E+00
0.530 0.0000E+00 0.0000E+00 0.0000E+00
0.701 0.0000E+00 0.0000E+00 0.0000E+00
0.872 0.0000E+00 0.0000E+00 0.0000E+00
1.043 0.0000E+00 0.0000E+00 0.0000E+00
1.213 0.0000E+00 0.0000E+00 0.0000E+00
1.384 0.3864E-26 0.8487E-27 0.4497E-26
1.555 0.9904E-16 0.2176E-16 0.1153E-15
1.726 0.5665E-08 0.1244E-08 0.6594E-08
1.897 0.4940E-03 0.1085E-03 0.5750E-03
2.068 -0.4603E-01 -0.1011E-01 -0.5358E-01
2.238 0.1317E+01 0.2892E+00 0.1533E+01
2.409 0.1176E+00 0.2582E-01 0.1368E+00
2.580 0.6212E-02 0.1365E-02 0.7230E-02
2.751 0.2753E-05 0.6047E-06 0.3204E-05
2.922 0.8456E-09 0.1593E-08 0.8831E-08
3.093 0.5951E-04 0.1122E-03 0.6221E-03
3.263 -0.5066E-02 -0.9550E-02 -0.5296E-01
3.434 0.1306E+00 0.2462E+00 0.1365E+01
3.605 0.7168E-02 0.1351E-01 0.5448E-01
3.776 0.1498E-02 0.1115E-02 0.1449E+01
3.947 0.3581E-01 0.2981E-02 0.1090E+01
4.118 0.1593E+00 0.1326E-01 0.2235E+01
4.288 -0.3799E-02 -0.3160E-03 -0.5305E-01
4.459 0.3529E-04 0.1850E-02 0.9953E-02
4.630 0.2305E-09 -0.3490E-01 -0.2077E+00
4.801 0.1012E-11 0.9395E+00 0.7761E+01
4.972 -0.4885E-13 -0.4536E-01 0.1311E+01
5.143 0.1235E-14 0.1147E-02 0.2449E-01
5.313 0.5375E-11 0.5226E-07 0.6163E-04
5.484 0.4760E-05 0.1406E-04 0.3678E-04
5.655 0.1115E-02 0.3295E-02 0.8762E-02
5.826 0.1092E+00 0.3226E+00 0.8285E+00
5.997 0.1975E+00 0.5835E+00 0.2436E+01
6.168 -0.1863E-02 -0.5502E-02 0.3082E+00
6.338 0.2204E-04 0.6510E-04 0.5891E-02
6.509 0.7017E-10 0.2073E-09 0.1064E-04
6.680 0.9358E-23 0.1488E-18 0.8389E-11
6.851 0.1030E-21 0.3246E-10 0.6418E-09
7.022 0.3923E-16 0.1237E-04 0.2446E-03
7.193 -0.2406E-14 -0.7587E-03 -0.1500E-01
7.363 0.2299E-10 0.1331E+00 0.2633E+01
7.534 0.2215E-05 0.9189E-01 0.1819E+01
7.705 -0.2154E-03 -0.4014E-03 -0.1353E+00
7.876 0.6585E-02 0.3074E-01 0.4480E+01
8.047 0.7363E-03 0.3778E-02 0.1344E+01
8.218 0.3293E-04 0.8301E-02 0.3896E+01
8.388 0.1716E-07 0.7527E-01 0.8529E+01
8.559 0.3604E-10 0.7904E-02 0.2641E+01
8.730 0.4255E-10 0.4352E-01 0.4011E+01
8.901 -0.9775E-12 -0.9930E-03 -0.9195E-01
9.072 0.9084E-14 0.9189E-05 0.8537E-03
9.243 0.5648E-19 0.5713E-10 0.5308E-08
9.413 0.0000E+00 0.0000E+00 0.0000E+00
9.584 0.0000E+00 0.0000E+00 0.0000E+00
9.755 0.0000E+00 0.0000E+00 0.0000E+00
9.926 0.0000E+00 0.0000E+00 0.0000E+00
10.097 0.9369E-38 0.9180E-38 0.1894E-37
10.268 0.4418E-25 0.4329E-25 0.8930E-25
10.438 0.5159E-15 0.5055E-15 0.1043E-14
10.609 0.1311E-07 0.1285E-07 0.2650E-07
10.780 0.4524E-03 0.4432E-03 0.9144E-03
10.951 -0.2549E-01 -0.2498E-01 -0.5153E-01
11.122 0.5333E+00 0.5226E+00 0.1078E+01
11.293 -0.8611E-02 -0.8437E-02 -0.1741E-01
11.463 0.1436E-02 0.1407E-02 0.2902E-02
11.634 0.2049E-06 0.2008E-06 0.4142E-06
11.805 0.2993E-13 0.2933E-13 0.6050E-13
11.976 0.0000E+00 0.0000E+00 0.0000E+00
12.147 0.0000E+00 0.0000E+00 0.0000E+00
12.318 0.0000E+00 0.0000E+00 0.0000E+00
12.488 0.0000E+00 0.0000E+00 0.0000E+00
12.659 0.0000E+00 0.0000E+00 0.0000E+00
12.830 0.0000E+00 0.0000E+00 0.0000E+00
13.001 0.0000E+00 0.0000E+00 0.0000E+00
13.172 0.0000E+00 0.0000E+00 0.0000E+00
13.343 0.0000E+00 0.0000E+00 0.0000E+00
13.513 0.0000E+00 0.0000E+00 0.0000E+00
13.684 0.0000E+00 0.0000E+00 0.0000E+00
13.855 0.3209E-47 0.3498E-34 0.5894E-34
14.026 0.3601E-35 0.3925E-22 0.6614E-22
14.197 0.9807E-26 0.1069E-12 0.1802E-12
14.368 0.5466E-19 0.5958E-06 0.1004E-05
14.538 0.2931E-15 0.3195E-02 0.5384E-02
14.709 0.9435E-16 0.1028E-02 0.1733E-02
14.880 0.9327E-13 0.1017E+01 0.1713E+01
15.051 -0.4263E-14 -0.4647E-01 -0.7831E-01
15.222 0.6490E-16 0.7075E-03 0.1192E-02
15.393 0.1489E-20 0.1623E-07 0.2734E-07
15.563 0.4966E-28 0.5413E-15 0.9122E-15
15.734 0.0000E+00 0.0000E+00 0.0000E+00
15.905 0.0000E+00 0.0000E+00 0.0000E+00
16.076 0.0000E+00 0.0000E+00 0.0000E+00
16.247 0.0000E+00 0.0000E+00 0.0000E+00
16.418 0.0000E+00 0.0000E+00 0.0000E+00
16.588 0.0000E+00 0.0000E+00 0.0000E+00
16.759 0.0000E+00 0.0000E+00 0.0000E+00
16.930 0.0000E+00 0.0000E+00 0.0000E+00
17.101 0.0000E+00 0.0000E+00 0.0000E+00

View File

@ -0,0 +1,50 @@
1 1 1 1
0.1333597E+02 0.2587511E-09 0.2587511E-09 0.2587511E-09 0.5000000E-15
1.000000000000000E-004
CAR
V
11 4 9
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.3703704E-01
1 -31.099965
2 -31.099965
3 -31.099965
4 -0.813470
5 5.974027
6 5.974027
7 5.974027
8 7.986328
9 7.986328
0.3333333E+00 0.0000000E+00 0.0000000E+00 0.4444444E+00
1 -31.819277
2 -31.322999
3 -31.105684
4 2.193081
5 4.784864
6 5.839340
7 7.833446
8 8.202781
9 8.589551
0.3333333E+00 0.3333333E+00 0.0000000E+00 0.2962963E+00
1 -31.750021
2 -31.750021
3 -31.217560
4 3.978315
5 4.708263
6 4.708263
7 8.262522
8 8.262522
9 14.771374
-0.3333333E+00 0.3333333E+00 0.3333333E+00 0.2222222E+00
1 -31.719893
2 -31.577292
3 -31.577292
4 3.383714
5 3.756320
6 7.355029
7 7.355029
8 8.411511
9 11.054129

View File

@ -0,0 +1,7 @@
Automatically generated mesh
4
Reciprocal lattice
0.00000000000000 0.00000000000000 0.00000000000000 1
0.33333333333333 0.00000000000000 0.00000000000000 12
0.33333333333333 0.33333333333333 0.00000000000000 8
-0.33333333333333 0.33333333333333 0.33333333333333 6

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,10 @@
V SF test
2.9878
-0.5 0.5 0.5
0.5 -0.5 0.5
0.5 0.5 -0.5
V
1
Direct
0.0 0.0 0.0

View File

@ -0,0 +1,8 @@
[Shell 1]
LSHELL = 2
IONS = 1
EMIN = -15.0
EMAX = 5.0

View File

@ -0,0 +1,56 @@
r"""
Module defining a custom TestCase with extra functionality.
"""
import unittest
import numpy as np
import difflib
class MyTestCase(unittest.TestCase):
"""
Custom TestCase class supporting additional equality checks:
- numpy array equality
- file equality
"""
def __init__(self, *args, **kwargs):
"""
Initializes a custom equality function for comparing numpy arrays.
"""
super(MyTestCase, self).__init__(*args, **kwargs)
self.addTypeEqualityFunc(np.ndarray, self.is_arrays_equal)
def is_arrays_equal(self, arr1, arr2, msg=None):
"""
Raises self.failureException is arrays arr1 and arr2
are not equal.
"""
if not np.allclose(arr1, arr2):
raise self.failureException(msg)
def assertFileEqual(self, file1, file2):
"""
Compares two files using difflib.
Empty lines are ignored.
Files are assumed to be relatively small;
the data is truncated for files larger than MAX_SIZE bytes.
"""
MAX_SIZE = 100000
with open(file1, 'r') as f1:
str1 = f1.read(MAX_SIZE)
with open(file2, 'r') as f2:
str2 = f2.read(MAX_SIZE)
#
# Make a diff
#
# Remove empty lines
lstr1 = filter(lambda s: s.strip() != '', str1.splitlines(True))
lstr2 = filter(lambda s: s.strip() != '', str2.splitlines(True))
# diff
delta = difflib.unified_diff(lstr1, lstr2)
# combine delta's to a string
diff = ''.join(delta)
# if 'diff' is non-empty, files are different
if diff:
return self.fail("Files '%s' and '%s' differ"%(file1, file2))

View File

@ -0,0 +1,115 @@
pars: {'ion_list': array([0]), 'user_index': 1, 'lshell': 2}
3 8
1 (2.5198055198e-08+0j)
2 (2.51956215891e-08+0j)
3 (-1.39707700703e-12+0j)
4 (2.51956464581e-08+0j)
5 (-9.58669992349e-14+0j)
1 (0.423249542713+0j)
2 (0.441459685564+0j)
3 (5.45383349593e-10+0j)
4 (0.441459536552+0j)
5 (-5.07696386694e-15+0j)
1 (-0.624317586422+0j)
2 (0.299283236265+0j)
3 (3.00651912255e-08+0j)
4 (0.299281418324+0j)
5 (-5.44629513472e-14+0j)
1 (-2.9753928743e-07+0j)
2 (-0.495364636183+0j)
3 (1.61749496311e-14+0j)
4 (0.495365083218+0j)
5 (2.86656725024e-08+0j)
1 (2.31630860326e-12+0j)
2 (-2.07712407274e-08+0j)
3 (6.79555596435e-05+0j)
4 (2.07689296872e-08+0j)
5 (-0.686951518059+0j)
1 (-2.55608547661e-08+0j)
2 (1.27339729872e-08+0j)
3 (-0.749936163425+0j)
4 (1.27377095538e-08+0j)
5 (-6.18639533059e-05+0j)
3 8
1 (-7.42354511196e-10+0j)
2 (-0.407458901405+0j)
3 (-0.132825627923+0j)
4 (-1.12258624618e-09+0j)
5 (0.230060741305+0j)
1 (-0.529840826988+0j)
2 (1.02242869726e-09+0j)
3 (1.47169805231e-08+0j)
4 (0.529840826988+0j)
5 (8.58095106082e-09+0j)
1 (-5.59593660299e-09+0j)
2 (-0.46026712656+0j)
3 (-0.189698129892+0j)
4 (-3.64733043767e-09+0j)
5 (0.328566819429+0j)
1 (-5.92653073284e-08+0j)
2 (-0.511403858662+0j)
3 (0.342116594315+0j)
4 (-5.81566510505e-08+0j)
5 (-0.592563331127+0j)
1 (9.17969966707e-09+0j)
2 (3.7528921637e-10+0j)
3 (0.743389487267+0j)
4 (-7.80711495452e-09+0j)
5 (0.429196119308+0j)
1 (-0.60352396965+0j)
2 (5.06060757743e-07+0j)
3 (1.02901012156e-07+0j)
4 (-0.60352396965+0j)
5 (-1.76288821763e-07+0j)
3 7
1 (-0.157831609249+0j)
2 (0.157831639051+0j)
3 (1.93573299612e-08+0j)
4 (0.157831639051+0j)
5 (5.40782289825e-14+0j)
1 (-1.07380124348e-07+0j)
2 (-0.227066069841+0j)
3 (-1.22580686934e-07+0j)
4 (0.227065965533+0j)
5 (0.299297988415+0j)
1 (0.115845791996+0j)
2 (0.057922616601+0j)
3 (0.13223952055+0j)
4 (0.0579231306911+0j)
5 (3.36705625159e-07+0j)
1 (0.159106343985+0j)
2 (0.0795532241464+0j)
3 (-0.240490317345+0j)
4 (0.0795530825853+0j)
5 (1.18692518924e-07+0j)
1 (3.98122104173e-08+0j)
2 (-0.241537705064+0j)
3 (-6.01558127755e-08+0j)
4 (0.241537734866+0j)
5 (-0.421558618546+0j)
3 7
1 (7.91286647317e-10+0j)
2 (3.03037844818e-10+0j)
3 (0.204362645745+0j)
4 (4.89190632447e-10+0j)
5 (-0.353966474533+0j)
1 (9.13699960137e-09+0j)
2 (1.0438577086e-10+0j)
3 (-0.42577791214+0j)
4 (-6.95880419954e-09+0j)
5 (-0.245822981+0j)
1 (0.368288576603+0j)
2 (1.67113629601e-08+0j)
3 (-1.44080747333e-10+0j)
4 (0.365979760885+0j)
5 (1.25375620996e-09+0j)
1 (0.365983724594+0j)
2 (-2.74820233237e-09+0j)
3 (1.77222470032e-09+0j)
4 (-0.368292748928+0j)
5 (7.90098320103e-10+0j)
1 (-3.99936368467e-08+0j)
2 (0.546248733997+0j)
3 (-2.91795543284e-09+0j)
4 (-2.16134438347e-07+0j)
5 (1.55786352707e-08+0j)

View File

@ -0,0 +1 @@
PYTHONPATH=../../python:../../c:$PYTHONPATH python $1

View File

@ -0,0 +1,34 @@
import vaspio
from inpconf import ConfigParameters
import mytest
################################################################################
#
# TestDataConsistency
#
################################################################################
class TestDataConsistency(mytest.MyTestCase):
"""
Function:
def read_plocar(filename)
Scenarios:
- **if** file PLOCAR does not exist **raise** IOError
- **if** PLOCAR is truncated **raise** IOError
- **if** the precision flag is not 4 or 8 **raise** ValueError
- **if** PLOCAR with prec=8 is read **compare** the output
- **if** PLOCAR with prec=4 is read **compare** the output
"""
# Scenario 1
def test_example(self):
conf_file = 'example.cfg'
pars = ConfigParameters(conf_file)
pars.parse_input()
vasp_data = vaspio.VaspData('./')
print pars.shells
print pars.groups

View File

@ -0,0 +1,10 @@
r"""
Test suite for module `plotools`.
"""
import unittest
if __name__ == '__main__':
suite = unittest.TestLoader().discover('./')
# unittest.TextTestRunner(verbosity=2, buffer=True).run(suite)
unittest.TextTestRunner(verbosity=2, buffer=False).run(suite)

View File

@ -0,0 +1,56 @@
import numpy as np
import vaspio
from inpconf import ConfigParameters
from plotools import select_bands, ProjectorShell
import mytest
################################################################################
#
# TestProjectorShell
#
################################################################################
class TestProjectorShell(mytest.MyTestCase):
"""
Class:
ProjectorShell(sh_pars, proj_raw)
Scenarios:
- compare output for a correct input
"""
# Scenario 1
def test_example(self):
conf_file = 'example.cfg'
pars = ConfigParameters(conf_file)
pars.parse_input()
vasp_data = vaspio.VaspData('./')
efermi = vasp_data.doscar.efermi
eigvals = vasp_data.eigenval.eigs - efermi
emin = pars.groups[0]['emin']
emax = pars.groups[0]['emax']
ib_win, nb_min, nb_max = select_bands(eigvals, emin, emax)
proj_sh = ProjectorShell(pars.shells[0], vasp_data.plocar.plo)
proj_sh.select_projectors(ib_win, nb_min, nb_max)
testout = 'projshells.out.test'
nion, ns, nk, nbtot, nlm = proj_sh.proj_win.shape
with open(testout, 'wt') as f:
f.write("pars: %s\n"%(pars.shells[0]))
for ion in xrange(nion):
for isp in xrange(ns):
for ik in xrange(nk):
ib1 = ib_win[ik, 0, 0]
ib2 = ib_win[ik, 0, 1]
f.write("%i %i\n"%(ib1, ib2))
for ib in xrange(ib2 - nb_min + 1):
for ilm in xrange(nlm):
p = proj_sh.proj_win[ion, isp, ik, ib, ilm]
f.write("%5i %s\n"%(ilm+1, p))
expected_file = 'projshells.out'
self.assertFileEqual(testout, expected_file)

View File

@ -0,0 +1,73 @@
import numpy as np
import vaspio
from inpconf import ConfigParameters
from plotools import select_bands
import mytest
################################################################################
#
# TestSelectBands
#
################################################################################
class TestSelectBands(mytest.MyTestCase):
"""
Function:
def select_bands(eigvals, emin, emax)
Scenarios:
- compare output for a correct input
- **if** emin > max(eigvals) **raise** Exception
- **if** emax > min(eigvals) **raise** Exception
"""
# Scenario 1
def test_example(self):
conf_file = 'example.cfg'
pars = ConfigParameters(conf_file)
pars.parse_input()
vasp_data = vaspio.VaspData('./')
efermi = vasp_data.doscar.efermi
eigvals = vasp_data.eigenval.eigs - efermi
emin = pars.groups[0]['emin']
emax = pars.groups[0]['emax']
ib_win, nb_min, nb_max = select_bands(eigvals, emin, emax)
nb_min_exp = 3
nb_max_exp = 8
ib_win_exp = np.array([[[3, 8]], [[3, 8]], [[3, 7]], [[3, 7]]])
self.assertEqual(nb_min, nb_min_exp)
self.assertEqual(nb_max, nb_max_exp)
self.assertEqual(ib_win, ib_win_exp)
# Scenario 2
def test_emin_too_large(self):
conf_file = 'example.cfg'
pars = ConfigParameters(conf_file)
pars.parse_input()
vasp_data = vaspio.VaspData('./')
efermi = vasp_data.doscar.efermi
eigvals = vasp_data.eigenval.eigs - efermi
emin = 20.0
emax = 25.0
with self.assertRaisesRegexp(Exception, "Energy window does not overlap"):
ib_win, nb_min, nb_max = select_bands(eigvals, emin, emax)
# Scenario 3
def test_emax_too_small(self):
conf_file = 'example.cfg'
pars = ConfigParameters(conf_file)
pars.parse_input()
vasp_data = vaspio.VaspData('./')
efermi = vasp_data.doscar.efermi
eigvals = vasp_data.eigenval.eigs - efermi
emin = -50.0
emax = -55.0
with self.assertRaisesRegexp(Exception, "Energy window does not overlap"):
ib_win, nb_min, nb_max = select_bands(eigvals, emin, emax)