2015-08-10 11:32:08 +02:00
|
|
|
r"""
|
|
|
|
Tests for class 'Ibzkpt' from module 'vaspio'
|
|
|
|
"""
|
2015-10-16 11:52:33 +02:00
|
|
|
import os
|
|
|
|
import rpath
|
|
|
|
_rpath = os.path.dirname(rpath.__file__) + '/'
|
|
|
|
|
2015-08-10 11:32:08 +02:00
|
|
|
import mytest
|
|
|
|
import numpy as np
|
|
|
|
from vaspio import Kpoints
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TestIbzkpt
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
class TestIbzkpt(mytest.MyTestCase):
|
|
|
|
"""
|
|
|
|
Function:
|
|
|
|
|
|
|
|
def read_plocar(filename)
|
|
|
|
|
|
|
|
Scenarios:
|
|
|
|
- full IBZKPT file with tetrahedra
|
|
|
|
- partial IBZKPT file with k-points only
|
|
|
|
|
|
|
|
"""
|
|
|
|
# Scenario 1
|
|
|
|
def test_example(self):
|
|
|
|
ibz_file = 'IBZKPT.example'
|
|
|
|
kpoints = Kpoints()
|
2015-10-16 11:52:33 +02:00
|
|
|
kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
|
2015-08-10 11:32:08 +02:00
|
|
|
|
2015-10-16 11:52:33 +02:00
|
|
|
testout = _rpath + 'IBZKPT.example.out.test'
|
2015-08-10 11:32:08 +02:00
|
|
|
with open(testout, 'w') as f:
|
|
|
|
writeline = lambda s: f.write(s + '\n')
|
|
|
|
writeline("nktot = %s"%(kpoints.nktot))
|
|
|
|
writeline("ntet = %s"%(kpoints.ntet))
|
|
|
|
writeline("volt = %s"%(kpoints.volt))
|
|
|
|
writeline("kpts:\n%s"%(kpoints.kpts))
|
|
|
|
writeline("tets:\n%s"%(kpoints.itet))
|
|
|
|
|
2015-10-16 11:52:33 +02:00
|
|
|
expected = _rpath + 'IBZKPT.example.out'
|
2015-08-10 11:32:08 +02:00
|
|
|
self.assertFileEqual(testout, expected)
|
|
|
|
|
|
|
|
# Scenario 2
|
|
|
|
def test_notet(self):
|
|
|
|
ibz_file = 'IBZKPT.notet'
|
|
|
|
kpoints = Kpoints()
|
2015-10-16 11:52:33 +02:00
|
|
|
kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
|
2015-08-10 11:32:08 +02:00
|
|
|
|
2015-10-16 11:52:33 +02:00
|
|
|
testout = _rpath + 'IBZKPT.notet.out.test'
|
2015-08-10 11:32:08 +02:00
|
|
|
with open(testout, 'w') as f:
|
|
|
|
writeline = lambda s: f.write(s + '\n')
|
|
|
|
writeline("nktot = %s"%(kpoints.nktot))
|
|
|
|
writeline("kpts:\n%s"%(kpoints.kpts))
|
|
|
|
|
2015-10-16 11:52:33 +02:00
|
|
|
expected = _rpath + 'IBZKPT.notet.out'
|
2015-08-10 11:32:08 +02:00
|
|
|
self.assertFileEqual(testout, expected)
|
|
|
|
|
|
|
|
|