TRIQS/triqs_tprf 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
chi_from_gg2.cpp
1/*******************************************************************************
2 *
3 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
4 *
5 * Copyright (C) 2017, H. U.R. Strand
6 *
7 * TRIQS is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * TRIQS. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
22#include "chi_from_gg2.hpp"
23
24using namespace nda::clef;
25
26namespace {
27placeholder<0> a;
28placeholder<1> b;
29placeholder<2> c;
30placeholder<3> d;
31
32placeholder<4> Omega;
33placeholder<5> n;
34placeholder<6> np;
35
36placeholder<7> tau;
37} // namespace
38
39namespace triqs_tprf {
40
41// ----------------------------------------------------
42// Particle-hole (PH)
43
44template <> g2_iw_t chi0_from_gg2<Channel_t::PH>(g_iw_cvt g, g2_iw_cvt g2) {
45 double beta = g.mesh().beta();
46 auto chi0 = make_gf(g2.mesh(), g2.target());
47
48 chi0(Omega, n, np)(a, b, c, d)
49 << -beta * kronecker(n, np) * g(n)(d, a) * g(Omega + n)(b, c);
50
51 return chi0;
52}
53
54template <> g2_iw_t chi_from_gg2<Channel_t::PH>(g_iw_cvt g, g2_iw_cvt g2) {
55 double beta = g.mesh().beta();
56 auto chi = make_gf(g2.mesh(), g2.target());
57
58 chi(Omega, n, np)(a, b, c, d)
59 << g2(Omega, n, np)(a, b, c, d) -
60 beta * kronecker(Omega) * g(n)(b, a) * g(np)(d, c);
61
62 return chi;
63}
64
65chi2_tau_t chi0_tau_from_g_tau_PH(g_tau_cvt g_tau) {
66
67 int nb = g_tau.target().shape()[0];
68 double beta = g_tau.mesh().beta();
69 int ntau = g_tau.mesh().size();
70
71 chi2_tau_t chi0_tau{{beta, Boson, ntau}, {nb, nb, nb, nb}};
72
73 chi0_tau(tau)(a, b, c, d) << g_tau(tau)(d, a) * g_tau(beta - tau)(b, c);
74
75 return chi0_tau;
76}
77
78// ----------------------------------------------------
79// Particle-particle (PP)
80
81template <> g2_iw_t chi0_from_gg2<Channel_t::PP>(g_iw_cvt g, g2_iw_cvt g2) {
82 double beta = g.mesh().beta();
83 auto chi0 = make_gf(g2.mesh(), g2.target());
84
85 chi0(Omega, n, np)(a, b, c, d)
86 << -beta * kronecker(n, np) * g(n)(d, a) * g(Omega - n)(b, c);
87
88 return chi0;
89}
90
91template <> g2_iw_t chi_from_gg2<Channel_t::PP>(g_iw_cvt g, g2_iw_cvt g2) {
92 double beta = g.mesh().beta();
93 auto chi = make_gf(g2.mesh(), g2.target());
94
95 chi(Omega, n, np)(a, b, c, d)
96 << g2(Omega, n, np)(a, b, c, d) -
97 beta * kronecker(n + np, Omega) * g(n)(b, a) * g(np)(d, c);
98
99 return chi;
100}
101
102
103// ----------------------------------------------------
104// functions for (easier) Python wrapping
105
106g2_iw_t chi0_from_gg2_PH(g_iw_vt g, g2_iw_vt g2) { return chi0_from_gg2<Channel_t::PH>(g, g2); }
107g2_iw_t chi0_from_gg2_PP(g_iw_vt g, g2_iw_vt g2) { return chi0_from_gg2<Channel_t::PP>(g, g2); }
108
109g2_iw_t chi_from_gg2_PH(g_iw_vt g, g2_iw_vt g2) { return chi_from_gg2<Channel_t::PH>(g, g2); }
110g2_iw_t chi_from_gg2_PP(g_iw_vt g, g2_iw_vt g2) { return chi_from_gg2<Channel_t::PP>(g, g2); }
111
112} // namespace triqs_tprf