From e3be3255daa94470677ceb3a280a47429bcc0fef Mon Sep 17 00:00:00 2001 From: Yann in 't Veld Date: Wed, 24 Jul 2024 05:41:03 -0400 Subject: [PATCH] Fixed imtime_bubble_chi0_wk not returning chi on a symmetrized DLR mesh if Gf in argument has a symmetrized DLR mesh --- c++/triqs_tprf/lattice/chi_imtime.cpp | 4 ++-- c++/triqs_tprf/lattice/chi_imtime.hpp | 2 +- python/triqs_tprf/lattice_desc.py | 2 +- python/triqs_tprf/lattice_utils.py | 10 +++++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/c++/triqs_tprf/lattice/chi_imtime.cpp b/c++/triqs_tprf/lattice/chi_imtime.cpp index a690ed78f..725c6674c 100644 --- a/c++/triqs_tprf/lattice/chi_imtime.cpp +++ b/c++/triqs_tprf/lattice/chi_imtime.cpp @@ -35,7 +35,7 @@ namespace triqs_tprf { // ---------------------------------------------------- // chi0 bubble in DLR imaginary time -chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr) { +chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr, bool symmetrize) { auto _ = all_t{}; @@ -45,7 +45,7 @@ chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr) { int nb = g_tr.target().shape()[0]; double beta = tmesh.beta(); - dlr_imtime btmesh{beta, Boson, tmesh.w_max(), tmesh.eps()}; + dlr_imtime btmesh{beta, Boson, tmesh.w_max(), tmesh.eps(), symmetrize}; chi_Dtr_t chi0_tr{{btmesh, rmesh}, {nb, nb, nb, nb}}; auto g_target = g_tr.target(); diff --git a/c++/triqs_tprf/lattice/chi_imtime.hpp b/c++/triqs_tprf/lattice/chi_imtime.hpp index 561a816ea..03bad53cf 100644 --- a/c++/triqs_tprf/lattice/chi_imtime.hpp +++ b/c++/triqs_tprf/lattice/chi_imtime.hpp @@ -36,7 +36,7 @@ namespace triqs_tprf { @return Generalized susceptibility :math:`\chi^{(0)}_{\bar{a}b\bar{c}d}(\tau, \mathbf{r})` in imaginary time and real-space. */ chi_tr_t chi0_tr_from_grt_PH(g_tr_cvt g_tr); -chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr); +chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr, bool symmetrize=false); chi_wr_t chi0_wr_from_grt_PH(g_tr_cvt g_tr, int nw); /** Generalized susceptibility zero imaginary frequency bubble in the particle-hole channel :math:`\chi^{(0)}_{\bar{a}b\bar{c}d}(\omega=0, \mathbf{r})` diff --git a/python/triqs_tprf/lattice_desc.py b/python/triqs_tprf/lattice_desc.py index 794a149f5..a76b8ba29 100644 --- a/python/triqs_tprf/lattice_desc.py +++ b/python/triqs_tprf/lattice_desc.py @@ -1339,7 +1339,7 @@ out Generalized susceptibility :math:`\chi^{(0)}_{\bar{a}b\bar{c}d}(\tau, \mathbf{r})` in imaginary time and real-space.""") -module.add_function ("triqs_tprf::chi_Dtr_t triqs_tprf::chi0_tr_from_grt_PH (triqs_tprf::g_Dtr_cvt g_tr)") +module.add_function ("triqs_tprf::chi_Dtr_t triqs_tprf::chi0_tr_from_grt_PH (triqs_tprf::g_Dtr_cvt g_tr, bool symmetrize=false)") module.add_function ("std::tuple triqs_tprf::g0_Tk_les_gtr_from_e_k(triqs_tprf::e_k_cvt e_k, triqs::mesh::retime Tmesh, double beta)") diff --git a/python/triqs_tprf/lattice_utils.py b/python/triqs_tprf/lattice_utils.py index 794e92dd7..6af29aeef 100644 --- a/python/triqs_tprf/lattice_utils.py +++ b/python/triqs_tprf/lattice_utils.py @@ -200,6 +200,11 @@ def imtime_bubble_chi0_wk(g_wk, nw=1, save_memory=False, verbose=True): ntau = 2 * nw_g + is_dlr_mesh = type(wmesh) == MeshDLRImFreq + if is_dlr_mesh: + iw_values = np.fromiter(wmesh.values(), dtype=complex) + is_symmetrized = np.allclose(iw_values, -iw_values[::-1]) + # -- Memory Approximation ng_tr = ntau * np.prod(nk) * norb**2 # storing G(tau, r) @@ -252,7 +257,10 @@ def imtime_bubble_chi0_wk(g_wk, nw=1, save_memory=False, verbose=True): else: if not save_memory: if verbose: mpi.report('--> chi0_tr_from_grt_PH (bubble in tau & r)') - chi0_tr = chi0_tr_from_grt_PH(g_tr) + if is_dlr_mesh: + chi0_tr = chi0_tr_from_grt_PH(g_tr, is_symmetrized) + else: + chi0_tr = chi0_tr_from_grt_PH(g_tr) del g_tr if verbose: mpi.report('--> chi_wr_from_chi_tr')