3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-29 08:24:54 +02:00
dft_tools/test/plovasp/vaspio/test_kpoints.py
Oleg E. Peil f86038a7fd Fixed tests to make them runnable with build pytriqs
All imports inside the test cases refer now to paths relative
to TRIQS python library path. For example,

`import vaspio`

is replaced with

`import applications.dft.converters.plovasp.vasio`

In this way all tests can be executed wtih `build_pytriqs` provided
that the package is installed (the same practice as with other
'dft_tools' tests).

Also, the underscore can now be removed from subdirectory names
because there is no more conflict with module names.
2016-03-10 12:24:05 +01:00

62 lines
1.7 KiB
Python

r"""
Tests for class 'Ibzkpt' from module 'vaspio'
"""
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
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()
kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
testout = _rpath + 'IBZKPT.example.out.test'
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))
expected = _rpath + 'IBZKPT.example.out'
self.assertFileEqual(testout, expected)
# Scenario 2
def test_notet(self):
ibz_file = 'IBZKPT.notet'
kpoints = Kpoints()
kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
testout = _rpath + 'IBZKPT.notet.out.test'
with open(testout, 'w') as f:
writeline = lambda s: f.write(s + '\n')
writeline("nktot = %s"%(kpoints.nktot))
writeline("kpts:\n%s"%(kpoints.kpts))
expected = _rpath + 'IBZKPT.notet.out'
self.assertFileEqual(testout, expected)