3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-04 19:43:38 +01:00

add deg_shells to block_structure

This commit is contained in:
Gernot J. Kraberger 2018-02-22 14:51:18 +01:00
parent 7599336e55
commit ad2ee87bc7
2 changed files with 39 additions and 28 deletions

View File

@ -7,7 +7,7 @@ from warnings import warn
class BlockStructure(object):
""" Contains information about the Green function structure.
This class contains information about the structure of the solver
This class contains information about the structure of the solver
and sumk Green functions and the mapping between them.
Parameters
@ -33,19 +33,21 @@ class BlockStructure(object):
solver_to_sumk_block : list of dict
solver_to_sumk_block[ish][from_block] = to_block
maps from the solver block to the sumk block
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):
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
self.sumk_to_solver = sumk_to_solver
self.solver_to_sumk_block = solver_to_sumk_block
self.deg_shells = deg_shells
@classmethod
def full_structure(cls,gf_struct,corr_to_inequiv):
@ -99,20 +101,21 @@ class BlockStructure(object):
gf_struct_sumk = gs_sumk_all,
solver_to_sumk = copy.deepcopy(solver_to_sumk),
sumk_to_solver = solver_to_sumk,
solver_to_sumk_block = s2sblock)
solver_to_sumk_block = s2sblock,
deg_shells = [[] for ish in range(len(gf_struct))])
def pick_gf_struct_solver(self,new_gf_struct):
""" Pick selected orbitals within blocks.
""" Pick selected orbitals within blocks.
This throws away parts of the Green's function that (for some
reason - be sure that you know what you're doing) shouldn't be
reason - be sure that you know what you're doing) shouldn't be
included in the calculation.
To drop an entire block, just don't include it.
To drop a certain index within a block, just don't include it.
If it was before:
If it was before:
[{'up':[0,1],'down':[0,1],'left':[0,1]}]
to choose the 0th index of the up block and the 1st index of
@ -130,11 +133,11 @@ class BlockStructure(object):
Parameters
----------
new_gf_struct : list of dict
formatted the same as gf_struct_solver:
formatted the same as gf_struct_solver:
new_gf_struct[ish][block]=list of indices in that block.
"""
for ish in range(len(self.gf_struct_solver)):
gf_struct = new_gf_struct[ish]
@ -154,24 +157,24 @@ class BlockStructure(object):
new_ind = gf_struct[blk].index(ind)
self.sumk_to_solver[ish][k]=(blk,new_ind)
else:
self.sumk_to_solver[ish][k]=(None,None)
self.sumk_to_solver[ish][k]=(None,None)
# reindexing gf_struct so that it starts with 0
for k in gf_struct:
gf_struct[k]=range(len(gf_struct[k]))
self.gf_struct_solver[ish]=gf_struct
def pick_gf_struct_sumk(self,new_gf_struct):
""" Pick selected orbitals within blocks.
""" Pick selected orbitals within blocks.
This throws away parts of the Green's function that (for some
reason - be sure that you know what you're doing) shouldn't be
reason - be sure that you know what you're doing) shouldn't be
included in the calculation.
To drop an entire block, just don't include it.
To drop a certain index within a block, just don't include it.
If it was before:
If it was before:
[{'up':[0,1],'down':[0,1],'left':[0,1]}]
to choose the 0th index of the up block and the 1st index of
@ -188,11 +191,11 @@ class BlockStructure(object):
Parameters
----------
new_gf_struct : list of dict
formatted the same as gf_struct_solver:
formatted the same as gf_struct_solver:
new_gf_struct[ish][block]=list of indices in that block.
However, the indices are not according to the solver Gf
However, the indices are not according to the solver Gf
but the sumk Gf.
"""
@ -218,7 +221,7 @@ class BlockStructure(object):
Parameters
----------
mapping : list of dict
the dict consists of elements
the dict consists of elements
(from_block,from_index) : (to_block,to_index)
that maps from one structure to the other
"""
@ -254,7 +257,7 @@ class BlockStructure(object):
def create_gf(self,ish=0,gf_function=GfImFreq,**kwargs):
""" Create a zero BlockGf having the gf_struct_solver structure.
When using GfImFreq as gf_function, typically you have to
When using GfImFreq as gf_function, typically you have to
supply beta as keyword argument.
Parameters
@ -284,7 +287,7 @@ class BlockStructure(object):
.. warning::
Elements that are zero in the new structure due to
the new block structure will be just ignored, thus
the new block structure will be just ignored, thus
approximated to zero.
Parameters
@ -292,11 +295,11 @@ class BlockStructure(object):
G : BlockGf
the Gf that should be converted
G_struct : GfStructure
the structure ofthat G
the structure of that G
ish : int
shell index
show_warnings : bool
whether to show warnings when elements of the Green's
whether to show warnings when elements of the Green's
function get thrown away
**kwargs :
options passed to the constructor for the new Gf
@ -325,8 +328,8 @@ class BlockStructure(object):
return G_new
def approximate_as_diagonal(self):
""" Create a structure for a GF with zero off-diagonal elements.
""" Create a structure for a GF with zero off-diagonal elements.
.. warning::
In general, this will throw away non-zero elements of the
@ -361,7 +364,7 @@ class BlockStructure(object):
if not compare(x,y):
return False
return True
elif isinstance(one,int):
elif isinstance(one,int):
return one==two
elif isinstance(one,str):
return one==two
@ -375,7 +378,7 @@ class BlockStructure(object):
warn('Cannot compare {}'.format(type(one)))
return False
for prop in [ "gf_struct_sumk", "gf_struct_solver",
for prop in [ "gf_struct_sumk", "gf_struct_solver",
"solver_to_sumk", "sumk_to_solver", "solver_to_sumk_block"]:
if not compare(getattr(self,prop),getattr(other,prop)):
return False
@ -388,8 +391,8 @@ class BlockStructure(object):
""" Reduce to dict for HDF5 export."""
ret = {}
for element in [ "gf_struct_sumk", "gf_struct_solver",
"solver_to_sumk_block"]:
for element in [ "gf_struct_sumk", "gf_struct_solver",
"solver_to_sumk_block","deg_shells"]:
ret[element] = getattr(self,element)
def construct_mapping(mapping):
@ -436,6 +439,8 @@ class BlockStructure(object):
keys = sorted(element[ish].keys(),key=keyfun)
for k in keys:
s+=' '+str(k)+str(element[ish][k])+'\n'
s+= "deg_shells "+str( self.deg_shells)+'\n'
return s
from pytriqs.archive.hdf_archive_schemes import register_class

View File

@ -1610,3 +1610,9 @@ class SumkDFT(object):
def __set_solver_to_sumk_block(self,value):
self.block_structure.solver_to_sumk_block = value
solver_to_sumk_block = property(__get_solver_to_sumk_block,__set_solver_to_sumk_block)
def __get_deg_shells(self):
return self.block_structure.deg_shells
def __set_deg_shells(self,value):
self.block_structure.deg_shells = value
deg_shells = property(__get_deg_shells,__set_deg_shells)