2015-11-18 19:02:21 +01:00
|
|
|
|
|
|
|
import os
|
2020-06-10 17:45:53 +02:00
|
|
|
from . import rpath
|
2015-11-18 19:02:21 +01:00
|
|
|
_rpath = os.path.dirname(rpath.__file__) + '/'
|
|
|
|
|
|
|
|
import numpy as np
|
2018-09-06 13:48:24 +02:00
|
|
|
from triqs_dft_tools.converters.plovasp.vaspio import VaspData
|
|
|
|
from triqs_dft_tools.converters.plovasp.elstruct import ElectronicStructure
|
|
|
|
from triqs_dft_tools.converters.plovasp.inpconf import ConfigParameters
|
|
|
|
from triqs_dft_tools.converters.plovasp.proj_shell import ProjectorShell
|
|
|
|
from triqs_dft_tools.converters.plovasp.proj_group import ProjectorGroup
|
2020-04-08 21:47:15 +02:00
|
|
|
from h5 import HDFArchive
|
2020-06-10 17:45:53 +02:00
|
|
|
from . import mytest
|
2015-11-18 19:02:21 +01:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TestProjectorGroup
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
class TestProjectorGroupTwoSite(mytest.MyTestCase):
|
|
|
|
"""
|
|
|
|
Tests for a two-site problem.
|
|
|
|
|
|
|
|
Class:
|
|
|
|
|
|
|
|
ProjectorGroup(sh_pars, proj_raw)
|
|
|
|
|
|
|
|
Scenarios:
|
2015-11-19 12:11:55 +01:00
|
|
|
- **test** that orthogonalization with NORMION = False is correct
|
|
|
|
- **test** that orthogonalization with NORMION = True is correct
|
2015-11-18 19:02:21 +01:00
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
conf_file = _rpath + 'example_two_site.cfg'
|
|
|
|
self.pars = ConfigParameters(conf_file)
|
|
|
|
self.pars.parse_input()
|
2016-03-24 21:37:20 +01:00
|
|
|
vasp_data = VaspData(_rpath + 'two_site/')
|
|
|
|
self.el_struct = ElectronicStructure(vasp_data)
|
2015-11-18 19:02:21 +01:00
|
|
|
|
2016-03-24 21:37:20 +01:00
|
|
|
efermi = self.el_struct.efermi
|
|
|
|
self.eigvals = self.el_struct.eigvals - efermi
|
2016-12-31 10:51:38 +01:00
|
|
|
struct = self.el_struct.structure
|
|
|
|
kmesh = self.el_struct.kmesh
|
2015-11-18 19:02:21 +01:00
|
|
|
|
2016-12-31 10:51:38 +01:00
|
|
|
self.proj_sh = ProjectorShell(self.pars.shells[0], vasp_data.plocar.plo, vasp_data.plocar.proj_params, kmesh, struct, 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 19:02:21 +01:00
|
|
|
|
|
|
|
# Scenario 1
|
|
|
|
def test_ortho(self):
|
2015-11-20 18:59:46 +01:00
|
|
|
self.proj_gr.normion = False
|
2015-11-18 19:02:21 +01:00
|
|
|
self.proj_gr.orthogonalize()
|
|
|
|
|
|
|
|
dens_mat, overl = self.proj_sh.density_matrix(self.el_struct)
|
|
|
|
|
2017-02-07 10:31:28 +01:00
|
|
|
testout = _rpath + 'projortho_2site.test.h5'
|
|
|
|
with HDFArchive(testout, 'w') as h5test:
|
|
|
|
h5test['density_matrix'] = dens_mat
|
|
|
|
h5test['overlap_matrix'] = overl
|
2015-11-18 19:02:21 +01:00
|
|
|
|
2017-02-07 10:31:28 +01:00
|
|
|
# FIXME: redundant
|
2015-11-18 19:02:21 +01:00
|
|
|
self.assertEqual(overl[0, 0, ...], np.eye(5))
|
|
|
|
self.assertEqual(overl[0, 1, ...], np.eye(5))
|
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
expected_file = _rpath + 'projortho_2site.ref.h5'
|
2017-02-07 10:31:28 +01:00
|
|
|
self.assertH5FileEqual(testout, expected_file)
|
2015-11-18 19:02:21 +01:00
|
|
|
|
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)
|
|
|
|
|
2017-02-07 10:31:28 +01:00
|
|
|
testout = _rpath + 'projortho_normion.test.h5'
|
|
|
|
with HDFArchive(testout, 'w') as h5test:
|
|
|
|
h5test['density_matrix'] = dens_mat
|
|
|
|
h5test['overlap_matrix'] = overl
|
2015-11-19 12:11:55 +01:00
|
|
|
|
2017-02-07 10:31:28 +01:00
|
|
|
# FIXME: redundant
|
2015-11-19 12:11:55 +01:00
|
|
|
self.assertEqual(overl[0, 0, ...], np.eye(5))
|
|
|
|
self.assertEqual(overl[0, 1, ...], np.eye(5))
|
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
expected_file = _rpath + 'projortho_normion.ref.h5'
|
2017-02-07 10:31:28 +01:00
|
|
|
self.assertH5FileEqual(testout, expected_file)
|
2015-11-19 12:11:55 +01:00
|
|
|
|
2015-11-18 19:02:21 +01:00
|
|
|
|