TRIQS/triqs_tprf 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
fourier_interpolation.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 "fourier_interpolation.hpp"
23
24namespace triqs_tprf {
25
26// ----------------------------------------------------
27// fourier interpolation
28
29array<std::complex<double>, 6> cluster_mesh_fourier_interpolation(array<double, 2> k_vecs, chi_wr_cvt chi) {
30
31 int nk = k_vecs.shape()[0];
32 int nb = chi.target().shape()[0];
33 int nw = std::get<0>(chi.mesh()).size();
34
35 auto wmesh = std::get<0>(chi.mesh());
36 auto rmesh = std::get<1>(chi.mesh());
37
38 array<std::complex<double>, 6> chi_out(nw, nk, nb, nb, nb, nb);
39
40#pragma omp parallel for
41 for(int kidx = 0; kidx < nk; kidx++) {
42
43 chi_out(range::all, kidx, range::all, range::all, range::all, range::all) *= 0.;
44
45 auto k = k_vecs(kidx, range::all);
46
47 for (auto r : rmesh) {
48
49 /*
50#pragma omp parallel for
51 for (int idx = 0; idx < rmesh.size(); idx++) {
52 auto iter = rmesh.begin(); iter += idx; auto r = *iter;
53 */
54
55 auto dot_prod = k[0]*r[0] + k[1]*r[1] + k[2]*r[2];
56 auto exponent = exp( - std::complex<double>(0., dot_prod) );
57
58 for (auto w : wmesh) {
59 int widx = w.data_index();
60 for (int a : range(nb))
61 for (int b : range(nb))
62 for (int c : range(nb))
63 for (int d : range(nb)) chi_out(widx, kidx, a, b, c, d) += exponent * chi[w, r](a, b, c, d);
64 }
65 }
66 }
67 return chi_out;
68}
69
70} // namespace triqs_tprf