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

fix misusage of GfImFreq in create_gf

This commit is contained in:
Alexander Hampel 2022-10-05 16:28:31 -04:00
parent 2497484626
commit 97afc3061e
2 changed files with 16 additions and 9 deletions

View File

@ -27,7 +27,7 @@ Block structure class and helper functions
import copy import copy
import numpy as np import numpy as np
from triqs.gf import GfImFreq, BlockGf from triqs.gf import BlockGf, Gf, GfImFreq
from ast import literal_eval from ast import literal_eval
import triqs.utility.mpi as mpi import triqs.utility.mpi as mpi
from warnings import warn from warnings import warn
@ -639,14 +639,15 @@ class BlockStructure(object):
self.solver_to_sumk_block[ish] = so2su_block self.solver_to_sumk_block[ish] = so2su_block
self.deg_shells[ish] = [] self.deg_shells[ish] = []
def create_gf(self, ish=0, gf_function=GfImFreq, space='solver', **kwargs): def create_gf(self, ish=0, gf_function=Gf, space='solver', **kwargs):
""" Create a zero BlockGf having the correct structure. """ Create a zero BlockGf having the correct structure.
For ``space='solver'``, the structure is according to For ``space='solver'``, the structure is according to
``gf_struct_solver``, else according to ``gf_struct_sumk``. ``gf_struct_solver``, else according to ``gf_struct_sumk``.
When using GfImFreq as gf_function, typically you have to Default constructor is Gf which needs a mesh to be provided along.
supply beta as keyword argument. When using GfImFreq as gf_function, you have to
supply at least beta as keyword argument.
Parameters Parameters
---------- ----------
@ -656,7 +657,7 @@ class BlockStructure(object):
if ``space='sumk'``, the index of the correlated shell if ``space='sumk'``, the index of the correlated shell
gf_function : constructor gf_function : constructor
function used to construct the Gf objects constituting the function used to construct the Gf objects constituting the
individual blocks; default: GfImFreq individual blocks; default: Gf
space : 'solver' or 'sumk' space : 'solver' or 'sumk'
which space the structure should correspond to which space the structure should correspond to
**kwargs : **kwargs :
@ -693,7 +694,7 @@ class BlockStructure(object):
return self._create_gf_or_matrix(ish, gf_function, block_function, space) return self._create_gf_or_matrix(ish, gf_function, block_function, space)
def _create_gf_or_matrix(self, ish=0, gf_function=GfImFreq, block_function=BlockGf, space='solver', **kwargs): def _create_gf_or_matrix(self, ish=0, gf_function=Gf, block_function=BlockGf, space='solver', **kwargs):
if space == 'solver': if space == 'solver':
gf_struct = self.gf_struct_solver gf_struct = self.gf_struct_solver
elif space == 'sumk': elif space == 'sumk':
@ -702,6 +703,9 @@ class BlockStructure(object):
raise Exception( raise Exception(
"Argument space has to be either 'solver' or 'sumk'.") "Argument space has to be either 'solver' or 'sumk'.")
if 'mesh' not in kwargs and 'beta' in kwargs:
gf_function = GfImFreq
names = list(gf_struct[ish].keys()) names = list(gf_struct[ish].keys())
blocks = [] blocks = []
for n in names: for n in names:
@ -983,6 +987,9 @@ class BlockStructure(object):
if G_out is None: if G_out is None:
if not 'mesh' in kwargs and not 'beta' in kwargs: if not 'mesh' in kwargs and not 'beta' in kwargs:
kwargs['mesh'] = G.mesh kwargs['mesh'] = G.mesh
elif not 'mesh' in kwargs and 'beta' in kwargs:
kwargs['gf_function'] = GfImFreq
G_out = self.create_gf(ish=ish_to, space=space_to, **kwargs) G_out = self.create_gf(ish=ish_to, space=space_to, **kwargs)
else: else:
self.check_gf(G_out, ish=ish_to, space=space_to) self.check_gf(G_out, ish=ish_to, space=space_to)

View File

@ -18,9 +18,9 @@ full_test = False
# for the SrIrO3_rot.h5 file # # for the SrIrO3_rot.h5 file #
####################################################################### #######################################################################
beta = 40 mesh = MeshImFreq(40, 'Fermion', 1025)
SK = SumkDFT(hdf_file = 'SrIrO3_rot.h5') SK = SumkDFT(hdf_file = 'SrIrO3_rot.h5', mesh=mesh)
Sigma = SK.block_structure.create_gf(beta=beta) Sigma = SK.block_structure.create_gf(mesh=mesh)
SK.put_Sigma([Sigma]) SK.put_Sigma([Sigma])
G = SK.extract_G_loc() G = SK.extract_G_loc()