3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 20:34:38 +01:00

block_structure: add gf_struct_***_list and _dict

now sumk is given in the list format and
solver is given in the dict format
This commit is contained in:
Gernot J. Kraberger 2018-08-29 19:36:20 +02:00
parent 2b490d1485
commit f0de5c62b5
3 changed files with 100 additions and 8 deletions

View File

@ -5,6 +5,7 @@ from ast import literal_eval
import pytriqs.utility.mpi as mpi
from warnings import warn
class BlockStructure(object):
""" Contains information about the Green function structure.
@ -37,12 +38,13 @@ class BlockStructure(object):
maps from the solver block to the sumk block
for *inequivalent* correlated shell ish
"""
def __init__(self,gf_struct_sumk=None,
gf_struct_solver=None,
solver_to_sumk=None,
sumk_to_solver=None,
solver_to_sumk_block=None,
deg_shells=None):
def __init__(self, gf_struct_sumk=None,
gf_struct_solver=None,
solver_to_sumk=None,
sumk_to_solver=None,
solver_to_sumk_block=None,
deg_shells=None):
self.gf_struct_sumk = gf_struct_sumk
self.gf_struct_solver = gf_struct_solver
self.solver_to_sumk = solver_to_sumk
@ -50,6 +52,73 @@ class BlockStructure(object):
self.solver_to_sumk_block = solver_to_sumk_block
self.deg_shells = deg_shells
@property
def gf_struct_solver_list(self):
""" The structure of the solver Green's function
This is returned as a
list (for each shell)
of lists (for each block)
of tuples (block_name, block_indices).
That is,
``gf_struct_solver_list[ish][b][0]``
is the name of the block number ``b`` of shell ``ish``, and
``gf_struct_solver_list[ish][b][1]``
is a list of its indices.
The list for each shell is sorted alphabetically by block name.
"""
# we sort by block name in order to get a reproducible result
return [sorted([(k, v) for k, v in gfs.iteritems()], key=lambda x: x[0])
for gfs in self.gf_struct_solver]
@property
def gf_struct_sumk_list(self):
""" The structure of the sumk Green's function
This is returned as a
list (for each shell)
of lists (for each block)
of tuples (block_name, block_indices)
That is,
``gf_struct_sumk_list[ish][b][0]``
is the name of the block number ``b`` of shell ``ish``, and
``gf_struct_sumk_list[ish][b][1]``
is a list of its indices.
"""
return self.gf_struct_sumk
@property
def gf_struct_solver_dict(self):
""" The structure of the solver Green's function
This is returned as a
list (for each shell)
of dictionaries.
That is,
``gf_struct_solver_dict[ish][bname]``
is a list of the indices of block ``bname`` of shell ``ish``.
"""
return self.gf_struct_solver
@property
def gf_struct_sumk_dict(self):
""" The structure of the sumk Green's function
This is returned as a
list (for each shell)
of dictionaries.
That is,
``gf_struct_sumk_dict[ish][bname]``
is a list of the indices of block ``bname`` of shell ``ish``.
"""
return [{block: indices for block, indices in gfs}
for gfs in self.gf_struct_sumk]
@classmethod
def full_structure(cls,gf_struct,corr_to_inequiv):
""" Construct structure that maps to itself.
@ -360,8 +429,7 @@ class BlockStructure(object):
# we offer the possibility to convert to convert from sumk_dft
from_sumk = False
if isinstance(G_struct, str) and G_struct == 'sumk':
gf_struct_in = {block: indices
for block, indices in self.gf_struct_sumk[ish]}
gf_struct_in = self.gf_struct_sumk_dict[ish]
from_sumk = True
else:
gf_struct_in = G_struct.gf_struct_solver[ish]

View File

@ -2057,3 +2057,19 @@ class SumkDFT(object):
def __set_deg_shells(self,value):
self.block_structure.deg_shells = value
deg_shells = property(__get_deg_shells,__set_deg_shells)
@property
def gf_struct_solver_list(self):
return self.block_structure.gf_struct_solver_list
@property
def gf_struct_sumk_list(self):
return self.block_structure.gf_struct_sumk_list
@property
def gf_struct_solver_dict(self):
return self.block_structure.gf_struct_solver_dict
@property
def gf_struct_sumk_dict(self):
return self.block_structure.gf_struct_sumk_dict

View File

@ -64,6 +64,14 @@ for i in range(3):
G3 = original_bs.convert_gf(G_sumk, 'sumk', beta=40, n_points=3)
assert_block_gfs_are_close(G1, G3)
assert original_bs.gf_struct_sumk_list ==\
[[('up', [0, 1, 2]), ('down', [0, 1, 2])]]
assert original_bs.gf_struct_solver_dict ==\
[{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}]
assert original_bs.gf_struct_sumk_dict ==\
[{'down': [0, 1, 2], 'up': [0, 1, 2]}]
assert original_bs.gf_struct_solver_list ==\
[[('down_0', [0, 1]), ('down_1', [0]), ('up_0', [0, 1]), ('up_1', [0])]]
# check __eq__
assert full == full, 'equality not correct (equal structures not equal)'