2015-11-18 15:46:58 +01:00
|
|
|
|
|
|
|
import os
|
|
|
|
import rpath
|
|
|
|
_rpath = os.path.dirname(rpath.__file__) + '/'
|
|
|
|
|
|
|
|
import numpy as np
|
2016-03-10 16:52:37 +01:00
|
|
|
import applications.dft.converters.plovasp.vaspio as vaspio
|
|
|
|
import applications.dft.converters.plovasp.elstruct as elstruct
|
2016-03-10 12:24:05 +01:00
|
|
|
from applications.dft.converters.plovasp.inpconf import ConfigParameters
|
|
|
|
from applications.dft.converters.plovasp.proj_shell import ProjectorShell
|
|
|
|
from applications.dft.converters.plovasp.proj_group import ProjectorGroup
|
2015-11-18 15:46:58 +01:00
|
|
|
import mytest
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TestProjectorGroup
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
class TestProjectorGroup(mytest.MyTestCase):
|
|
|
|
"""
|
|
|
|
Class:
|
|
|
|
|
|
|
|
ProjectorGroup(sh_pars, proj_raw)
|
|
|
|
|
|
|
|
Scenarios:
|
|
|
|
- **test** that orthogonalization is correct
|
2015-11-19 12:11:55 +01:00
|
|
|
- **test** that NORMION = True gives the same result
|
2015-11-18 15:46:58 +01:00
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
conf_file = _rpath + 'example.cfg'
|
|
|
|
self.pars = ConfigParameters(conf_file)
|
|
|
|
self.pars.parse_input()
|
|
|
|
vasp_data = vaspio.VaspData(_rpath + 'one_site/')
|
|
|
|
self.el_struct = elstruct.ElectronicStructure(vasp_data)
|
|
|
|
|
|
|
|
efermi = vasp_data.doscar.efermi
|
|
|
|
self.eigvals = vasp_data.eigenval.eigs - efermi
|
|
|
|
|
|
|
|
self.proj_sh = ProjectorShell(self.pars.shells[0], vasp_data.plocar.plo, vasp_data.plocar.proj_params, 0)
|
2015-11-19 16:01:05 +01:00
|
|
|
self.proj_gr = ProjectorGroup(self.pars.groups[0], [self.proj_sh], self.eigvals)
|
2015-11-18 15:46:58 +01:00
|
|
|
|
|
|
|
# Scenario 1
|
|
|
|
def test_ortho(self):
|
|
|
|
self.proj_gr.orthogonalize()
|
|
|
|
|
|
|
|
dens_mat, overl = self.proj_sh.density_matrix(self.el_struct)
|
|
|
|
|
|
|
|
testout = _rpath + 'projortho.out.test'
|
|
|
|
with open(testout, 'wt') as f:
|
|
|
|
f.write("density matrix: %s\n"%(dens_mat))
|
|
|
|
f.write("overlap matrix: %s\n"%(overl))
|
|
|
|
|
|
|
|
self.assertEqual(overl, np.eye(5))
|
|
|
|
|
|
|
|
expected_file = _rpath + 'projortho.out'
|
|
|
|
self.assertFileEqual(testout, expected_file)
|
|
|
|
|
2015-11-19 12:11:55 +01:00
|
|
|
# Scenario 2
|
|
|
|
def test_ortho_normion(self):
|
|
|
|
self.proj_gr.normion = True
|
|
|
|
self.proj_gr.orthogonalize()
|
|
|
|
|
|
|
|
dens_mat, overl = self.proj_sh.density_matrix(self.el_struct)
|
|
|
|
|
|
|
|
testout = _rpath + 'projortho.out.test'
|
|
|
|
with open(testout, 'wt') as f:
|
|
|
|
f.write("density matrix: %s\n"%(dens_mat))
|
|
|
|
f.write("overlap matrix: %s\n"%(overl))
|
|
|
|
|
|
|
|
self.assertEqual(overl, np.eye(5))
|
|
|
|
|
|
|
|
expected_file = _rpath + 'projortho.out'
|
|
|
|
self.assertFileEqual(testout, expected_file)
|
|
|
|
|
2015-11-18 15:46:58 +01:00
|
|
|
|