From 70d4aba545cd26f88db0577cf3bd605331351c16 Mon Sep 17 00:00:00 2001 From: Priyanka Seth Date: Tue, 7 Oct 2014 09:18:53 +0200 Subject: [PATCH] Determining delta from gf (currently only BlockGf and GfImFreq) --- pytriqs/gf/local/CMakeLists.txt | 2 +- pytriqs/gf/local/__init__.py | 18 +++++------------- pytriqs/gf/local/block_gf.py | 5 ----- pytriqs/gf/local/functions.py | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 pytriqs/gf/local/functions.py diff --git a/pytriqs/gf/local/CMakeLists.txt b/pytriqs/gf/local/CMakeLists.txt index 20cdf46a..1387a7ff 100644 --- a/pytriqs/gf/local/CMakeLists.txt +++ b/pytriqs/gf/local/CMakeLists.txt @@ -9,12 +9,12 @@ SET(PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/_gf_legendre.py ${CMAKE_CURRENT_SOURCE_DIR}/_gf_refreq.py ${CMAKE_CURRENT_SOURCE_DIR}/_gf_retime.py - #${CMAKE_CURRENT_SOURCE_DIR}/gf_two_real_times.py ${CMAKE_CURRENT_SOURCE_DIR}/_gf_plot.py ${CMAKE_CURRENT_SOURCE_DIR}/_gf_common.py ${CMAKE_CURRENT_SOURCE_DIR}/inverse.py ${CMAKE_CURRENT_SOURCE_DIR}/lazy_expressions.py ${CMAKE_CURRENT_SOURCE_DIR}/tools.py + ${CMAKE_CURRENT_SOURCE_DIR}/functions.py ) # Install python sources diff --git a/pytriqs/gf/local/__init__.py b/pytriqs/gf/local/__init__.py index 70c684d6..2092df63 100644 --- a/pytriqs/gf/local/__init__.py +++ b/pytriqs/gf/local/__init__.py @@ -29,24 +29,16 @@ It is imported with the command:: from gf import * from inverse import inverse -#from gf_imfreq import GfImFreq -#from gf_imtime import GfImTime -#from gf_refreq import GfReFreq -#from gf_retime import GfReTime -#from gf_two_real_times import GfTwoRealTime -#from gf_legendre import GfLegendre from block_gf import BlockGf from descriptors import Omega, iOmega_n, SemiCircular, Wilson, Fourier, InverseFourier, LegendreToMatsubara, MatsubaraToLegendre +from functions import delta -#__all__ = ['TailGf','GfImFreq','MeshImFreq'] - -__all__ = ['Omega','iOmega_n','SemiCircular','Wilson','Fourier','InverseFourier','LegendreToMatsubara','MatsubaraToLegendre','lazy_expressions','TailGf', +__all__ = ['Omega','iOmega_n','SemiCircular','Wilson','Fourier','InverseFourier','LegendreToMatsubara','MatsubaraToLegendre', + 'lazy_expressions','TailGf', 'GfImFreq','MeshImFreq', 'GfImTime', 'MeshImTime', 'GfReFreq', 'MeshReFreq', 'GfReTime', 'MeshReTime', 'make_gf_from_inverse_fourier', - 'BlockGf','inverse'] #,'GfTwoRealTime'] - -#__all__ = ['Omega','iOmega_n','SemiCircular','Wilson','Fourier','InverseFourier','LegendreToMatsubara','MatsubaraToLegendre','lazy_expressions','TailGf','GfImFreq','GfImTime','GfReFreq','GfReTime','GfLegendre','BlockGf','inverse'] #,'GfTwoRealTime'] - + 'BlockGf','inverse', + 'delta'] diff --git a/pytriqs/gf/local/block_gf.py b/pytriqs/gf/local/block_gf.py index 50964ebb..be4fcc30 100644 --- a/pytriqs/gf/local/block_gf.py +++ b/pytriqs/gf/local/block_gf.py @@ -364,11 +364,6 @@ class BlockGf(object): self.__check_attr("invert") for i,g in self : g.invert() - def delta(self) : - """Compute delta from G0""" - self.__check_attr("delta") - return self.__class__( name_block_generator = [ (n, g.delta()) for n,g in self], make_copies=False) - def transpose(self): """Transpose of the BlockGf""" self.__check_attr("transpose") diff --git a/pytriqs/gf/local/functions.py b/pytriqs/gf/local/functions.py new file mode 100644 index 00000000..303ac87c --- /dev/null +++ b/pytriqs/gf/local/functions.py @@ -0,0 +1,17 @@ +from inverse import inverse +from block_gf import BlockGf +from gf import GfImFreq +from descriptor_base import A_Omega_Plus_B + +def delta(g) : + """Compute delta from G0""" + if type(g) == BlockGf: + return BlockGf(name_block_generator = [ (n, delta(g0)) for n,g0 in g], make_copies=False) + elif type(g) == GfImFreq: + g0_iw_inv = inverse(g) + delta_iw = g0_iw_inv.copy() + delta_iw <<= A_Omega_Plus_B(g0_iw_inv.tail[-1], g0_iw_inv.tail[0]) + delta_iw -= g0_iw_inv + return delta_iw + else: + raise TypeError, "No function delta for g0 object of type %s"%type(g)