3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-30 00:44:34 +02:00
dft_tools/python/converters/vasp/test/plotools/test_projgroups.py
Oleg E. Peil 0c4e3ad006 Changed order of indices of 'proj_arr' array
When a ProjectorShell is created it creates a view of the full
projector array with orbital 'ilm' and band 'ib' indices interchanged.
The reason for this is that this corresponds more naturally to the
definition of the projector P_{m\nu} and also allows for multiplications
of projector matrices without additional transposition.

The tests have been modified accordingly.
2015-10-11 13:55:04 +02:00

76 lines
2.8 KiB
Python

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