3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 04:13:47 +01:00

Added two tests for 'get_block_matrix_map()'

Two tests have been added for testing the basic functionality with
NORMION being either False or True.
This commit is contained in:
Oleg E. Peil 2015-11-19 15:56:30 +01:00
parent 81825fcdf2
commit 5585e81f7d
2 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,13 @@
[Group 1]
EWINDOW = -10.0 4.0
SHELLS = 1 2
[Shell 1]
LSHELL = 2
IONS = 1 2
[Shell 2]
LSHELL = 1
IONS = 3 4

View File

@ -0,0 +1,101 @@
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import numpy as np
import vaspio
import elstruct
from inpconf import ConfigParameters
from proj_shell import ProjectorShell
from proj_group import ProjectorGroup
import mytest
################################################################################
#
# TestBlockMap
#
################################################################################
class TestBlockMap(mytest.MyTestCase):
"""
Function:
def ProjectorGroup.get_block_matrix_map()
Scenarios:
- **test** block matrix for NORMION = False
- **test** block matrix for NORMION = True
"""
def setUp(self):
# Mock data
self.mock_eigvals = np.zeros((1, 11, 1))
nproj = 16
self.mock_plo = np.zeros((nproj, 1, 1, 11), dtype=np.complex128)
self.mock_proj_params = [{} for i in xrange(nproj)]
ip = 0
# Mock d-sites
for isite in xrange(2):
for im in xrange(5):
self.mock_proj_params[ip]['label'] = 'd-orb'
self.mock_proj_params[ip]['isite'] = isite + 1
self.mock_proj_params[ip]['l'] = 2
self.mock_proj_params[ip]['m'] = im
ip += 1
# Mock p-sites
for isite in xrange(2, 4):
for im in xrange(3):
self.mock_proj_params[ip]['label'] = 'p-orb'
self.mock_proj_params[ip]['isite'] = isite + 1
self.mock_proj_params[ip]['l'] = 1
self.mock_proj_params[ip]['m'] = im
ip += 1
# Scenario 1
def test_normion_false(self):
conf_file = _rpath + 'block_matrix.cfg'
self.pars = ConfigParameters(conf_file)
self.pars.parse_input()
shells = []
for sh_par in self.pars.shells:
shells.append(ProjectorShell(sh_par, self.mock_plo, self.mock_proj_params, 0))
proj_gr = ProjectorGroup(self.pars.groups[0], shells, self.mock_eigvals, 0)
proj_gr.normion = False
block_maps, ndim = proj_gr.get_block_matrix_map()
ndim_exp = 16
block_maps_exp = [[{'bmat_range': (0, 5), 'shell_ion': (0, 0)},
{'bmat_range': (5, 10), 'shell_ion': (0, 1)},
{'bmat_range': (10, 13), 'shell_ion': (1, 0)},
{'bmat_range': (13, 16), 'shell_ion': (1, 1)}]]
self.assertEqual(ndim, ndim_exp)
self.assertEqual(block_maps, block_maps_exp)
# Scenario 2
def test_normion_true(self):
conf_file = _rpath + 'block_matrix.cfg'
self.pars = ConfigParameters(conf_file)
self.pars.parse_input()
shells = []
for sh_par in self.pars.shells:
shells.append(ProjectorShell(sh_par, self.mock_plo, self.mock_proj_params, 0))
proj_gr = ProjectorGroup(self.pars.groups[0], shells, self.mock_eigvals, 0)
proj_gr.normion = True
block_maps, ndim = proj_gr.get_block_matrix_map()
ndim_exp = 5
block_maps_exp = [[{'bmat_range': (0, 5), 'shell_ion': (0, 0)}],
[{'bmat_range': (0, 5), 'shell_ion': (0, 1)}],
[{'bmat_range': (0, 3), 'shell_ion': (1, 0)}],
[{'bmat_range': (0, 3), 'shell_ion': (1, 1)}]]
self.assertEqual(ndim, ndim_exp)
self.assertEqual(block_maps, block_maps_exp)