TRIQS/triqs_tprf 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
freq_conv.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 "freq_conv.hpp"
23
24using namespace nda::clef;
25
26namespace {
27placeholder<0> a;
28placeholder<1> b;
29placeholder<2> c;
30placeholder<3> d;
31
32placeholder<4> w;
33placeholder<5> n;
34placeholder<6> np;
35
36placeholder<7> n1;
37placeholder<8> n2;
38placeholder<9> n3;
39} // namespace
40
41namespace triqs_tprf {
42
43// ----------------------------------------------------
44// AB matrix_valued from block_gf
45
46g_iw_t block_iw_AB_to_matrix_valued(b_g_iw_vt bg_AB) {
47
48 int n = 0;
49 for( auto bidx : range(bg_AB.size()) ) {
50 auto g_AB = bg_AB(bidx);
51 n += g_AB.target_shape()[0];
52 }
53
54 gf<imfreq, matrix_valued> g{bg_AB(0).mesh(), {n, n}};
55 g *= 0.0;
56
57 int idx = 0;
58 for( auto bidx : range(bg_AB.size()) ) {
59 auto g_AB = bg_AB(bidx);
60 int size = g_AB.target_shape()[0];
61
62 g.data()(range::all, range(idx, idx+size), range(idx, idx+size))
63 = g_AB.data()(range::all, range::all, range::all);
64
65 idx += size;
66 }
67
68 return g;
69}
70
71// ----------------------------------------------------
72// AABB to ABBA
73
97
98void block_3nu_AABB_to_tensor_valued(b_g2_iw_vt bg2_AABB, g2_iw_vt g2) {
99
100 g2 *= 0.0;
101
102 // set AABB components
103
104 // Clef with repeated indices is broken: https://github.com/TRIQS/triqs/issues/475
105 //g2(n1, n2, n3)(b1, b1, b2, b2) << bg2_AABB(b1, b2)(n1, n2, n3)(0, 0, 0, 0); // set AABB comp
106
107 // kronecker functionc fix clef deficiency
108 g2(n1, n2, n3)(a, b, c, d) << kronecker(a,b) * kronecker(c,d) *
109 bg2_AABB(a, c)(n1, n2, n3)(0, 0, 0, 0);
110
111 // ABBA from AABB
112
113 // Clef with repeated indices is broken: https://github.com/TRIQS/triqs/issues/475
114 //g2(n1, n2, n3)(b1, b2, b2, b1) << (1-kronecker(b1, b2)) * -g2(n1, n1 - n2 + n3, n3)(b1, b1, b2, b2);
115
116 g2(n1, n2, n3)(a, b, c, d) << g2(n1, n2, n3)(a, b, c, d) +
117 kronecker(a,d) * kronecker(b,c) * (1 - kronecker(a, c)) *
118 -g2(n1, n1 - n2 + n3, n3)(a, d, c, b);
119
120}
121
122// ----------------------------------------------------
123
124void get_magnetic_component(g2_iw_vt g2, g2_iw_vt g2_m) {
125 g2_m(n1, n2, n3) << g2(n1, n2, n3)(0, 0, 0, 0) - g2(n1, n2, n3)(0, 0, 1, 1);
126}
127
128// ----------------------------------------------------
129// Particle-hole (PH)
130
131template <> void from_3nu<Channel_t::PH>(g2_iw_vt g2_ch, g2_iw_cvt g2) {
132 g2_ch(w, n, np) << g2(n, n + w, np + w);
133}
134
135// ----------------------------------------------------
136// Particle-hole-bar (PHbar)
137
138template <> void from_3nu<Channel_t::PH_bar>(g2_iw_vt g2_ch, g2_iw_cvt g2) {
139 g2_ch(w, n, np) << g2(n, np, np + w);
140}
141
142// ----------------------------------------------------
143// Particle-particle (PP)
144
145template <> void from_3nu<Channel_t::PP>(g2_iw_vt g2_ch, g2_iw_cvt g2) {
146 g2_ch(w, n, np) << g2(n, np, w - np);
147}
148
149void from_3nu_PH(g2_iw_vt g2_ch, g2_iw_vt g2) { from_3nu<Channel_t::PH>(g2_ch, g2); }
150void from_3nu_PH_bar(g2_iw_vt g2_ch, g2_iw_vt g2) { from_3nu<Channel_t::PH_bar>(g2_ch, g2); }
151void from_3nu_PP(g2_iw_vt g2_ch, g2_iw_vt g2) { from_3nu<Channel_t::PP>(g2_ch, g2); }
152
153} // namespace triqs_tprf