TRIQS/triqs_cthyb 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
G2_iw_nfft.cpp
1/*******************************************************************************
2 *
3 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
4 *
5 * Copyright (C) 2016, P. Seth, I. Krivenko, H. U.R. Strand, M. Ferrero and O. Parcollet
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 "./G2_iw_nfft.hpp"
23
24namespace triqs_cthyb {
25
26 using namespace G2_iw;
27
28 template <G2_channel Channel>
29 measure_G2_iw_nfft<Channel>::measure_G2_iw_nfft(std::optional<G2_iw_t> &G2_iw_opt,
30 qmc_data const &data,
31 G2_measures_t const &G2_measures)
32 : measure_G2_iw_base<Channel>(G2_iw_opt, data, G2_measures) {
33
34 // Initialize the nfft_buffers mirroring the matrix M
35 {
36 std::cout << "G2_iw_nfft NFFT buffer sizes:\n";
37 for (auto bidx : range(M.size())) {
38 std::string bname = M.block_names()[bidx];
39
40 int buf_size = 10; // default
41 if (G2_measures.params.nfft_buf_sizes.count(bname)) {
42 buf_size = G2_measures.params.nfft_buf_sizes.at(bname);
43 }
44 array<long, 2> buf_sizes{M(bidx).target_shape()};
45 buf_sizes() = buf_size;
46
47 std::cout << "block_name = " << bname << " nfft_buf_size = " << buf_size << "\n";
48
49 M_nfft.emplace_back(M(bidx).mesh(), M(bidx).data(), buf_sizes);
50 }
51 }
52 }
53
54 template <G2_channel Channel> void measure_G2_iw_nfft<Channel>::accumulate(mc_weight_t s) {
55
56 auto nfft_fill = [this](det_type const &det, nfft_array_t<2, 2> &nfft_matrix) {
57 const double beta = this->data.config.beta();
58 foreach (det, [&nfft_matrix, beta](op_t const &x, op_t const &y, det_scalar_t M) {
59 nfft_matrix.push_back({beta - double(x.first), double(y.first)}, {x.second, y.second}, M);
60 })
61 ;
62 };
63
64 timer_M.start();
65 // Intermediate M matrices for all blocks
66 M() = 0;
67 for (auto bidx : range(M.size())) {
68 nfft_fill(data.dets[bidx], M_nfft[bidx]);
69 M_nfft[bidx].flush();
70 }
71 timer_M.stop();
72
73 // ---------------------------------------------------------------
74 // Recombine products of scattering matrices
75 // to accumulate two particle quantities
76
77 accumulate_G2(s);
78 }
79
80 template class measure_G2_iw_nfft<G2_channel::AllFermionic>;
81 template class measure_G2_iw_nfft<G2_channel::PP>;
82 template class measure_G2_iw_nfft<G2_channel::PH>;
83
84} // namespace triqs_cthyb