mirror of
https://github.com/triqs/dft_tools
synced 2024-12-23 04:43:42 +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:
parent
2b490d1485
commit
f0de5c62b5
@ -5,6 +5,7 @@ from ast import literal_eval
|
|||||||
import pytriqs.utility.mpi as mpi
|
import pytriqs.utility.mpi as mpi
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
|
|
||||||
|
|
||||||
class BlockStructure(object):
|
class BlockStructure(object):
|
||||||
""" Contains information about the Green function structure.
|
""" Contains information about the Green function structure.
|
||||||
|
|
||||||
@ -37,12 +38,13 @@ class BlockStructure(object):
|
|||||||
maps from the solver block to the sumk block
|
maps from the solver block to the sumk block
|
||||||
for *inequivalent* correlated shell ish
|
for *inequivalent* correlated shell ish
|
||||||
"""
|
"""
|
||||||
def __init__(self,gf_struct_sumk=None,
|
|
||||||
gf_struct_solver=None,
|
def __init__(self, gf_struct_sumk=None,
|
||||||
solver_to_sumk=None,
|
gf_struct_solver=None,
|
||||||
sumk_to_solver=None,
|
solver_to_sumk=None,
|
||||||
solver_to_sumk_block=None,
|
sumk_to_solver=None,
|
||||||
deg_shells=None):
|
solver_to_sumk_block=None,
|
||||||
|
deg_shells=None):
|
||||||
self.gf_struct_sumk = gf_struct_sumk
|
self.gf_struct_sumk = gf_struct_sumk
|
||||||
self.gf_struct_solver = gf_struct_solver
|
self.gf_struct_solver = gf_struct_solver
|
||||||
self.solver_to_sumk = solver_to_sumk
|
self.solver_to_sumk = solver_to_sumk
|
||||||
@ -50,6 +52,73 @@ class BlockStructure(object):
|
|||||||
self.solver_to_sumk_block = solver_to_sumk_block
|
self.solver_to_sumk_block = solver_to_sumk_block
|
||||||
self.deg_shells = deg_shells
|
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
|
@classmethod
|
||||||
def full_structure(cls,gf_struct,corr_to_inequiv):
|
def full_structure(cls,gf_struct,corr_to_inequiv):
|
||||||
""" Construct structure that maps to itself.
|
""" Construct structure that maps to itself.
|
||||||
@ -360,8 +429,7 @@ class BlockStructure(object):
|
|||||||
# we offer the possibility to convert to convert from sumk_dft
|
# we offer the possibility to convert to convert from sumk_dft
|
||||||
from_sumk = False
|
from_sumk = False
|
||||||
if isinstance(G_struct, str) and G_struct == 'sumk':
|
if isinstance(G_struct, str) and G_struct == 'sumk':
|
||||||
gf_struct_in = {block: indices
|
gf_struct_in = self.gf_struct_sumk_dict[ish]
|
||||||
for block, indices in self.gf_struct_sumk[ish]}
|
|
||||||
from_sumk = True
|
from_sumk = True
|
||||||
else:
|
else:
|
||||||
gf_struct_in = G_struct.gf_struct_solver[ish]
|
gf_struct_in = G_struct.gf_struct_solver[ish]
|
||||||
|
@ -2057,3 +2057,19 @@ class SumkDFT(object):
|
|||||||
def __set_deg_shells(self,value):
|
def __set_deg_shells(self,value):
|
||||||
self.block_structure.deg_shells = value
|
self.block_structure.deg_shells = value
|
||||||
deg_shells = property(__get_deg_shells,__set_deg_shells)
|
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
|
||||||
|
@ -64,6 +64,14 @@ for i in range(3):
|
|||||||
G3 = original_bs.convert_gf(G_sumk, 'sumk', beta=40, n_points=3)
|
G3 = original_bs.convert_gf(G_sumk, 'sumk', beta=40, n_points=3)
|
||||||
assert_block_gfs_are_close(G1, G3)
|
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__
|
# check __eq__
|
||||||
assert full == full, 'equality not correct (equal structures not equal)'
|
assert full == full, 'equality not correct (equal structures not equal)'
|
||||||
|
Loading…
Reference in New Issue
Block a user