6#include "./M4pp_iw.hpp"
9namespace triqs_ctint::measures {
11 M4pp_iw::M4pp_iw(params_t
const ¶ms_, qmc_config_t
const &qmc_config_, container_set *results)
12 : params(params_), qmc_config(qmc_config_), buf_arrarr(params_.n_blocks()) {
15 mesh::imfreq iW_mesh{params.beta, Boson, params.n_iW_M4};
16 mesh::imfreq iw_mesh{params.beta, Fermion, params.n_iw_M4};
17 mesh::prod<imfreq, imfreq, imfreq> M4pp_iw_mesh{iW_mesh, iw_mesh, iw_mesh};
20 results->M4pp_iw = make_block2_gf(M4pp_iw_mesh, params.gf_struct);
21 M4pp_iw_.rebind(results->M4pp_iw.value());
25 mesh::imfreq iw_mesh_large{params.beta, Fermion, params.n_iW_M4 + params.n_iw_M4 + 1};
26 mesh::prod<imfreq, imfreq> M_mesh{iw_mesh_large, iw_mesh_large};
29 M = block_gf{M_mesh, params.gf_struct};
32 for (
int bl : range(params.n_blocks())) {
33 auto init_target_func = [&](
int i,
int j) {
34 return nfft_buf_t<2>{slice_target_to_scalar(M[bl], i, j).data(), params.nfft_buf_size, params.beta, params.nfft_tol};
36 buf_arrarr(bl) = array_adapter{M[bl].target_shape(), init_target_func};
46 for (
int bl : range(params.n_blocks()))
48 foreach (qmc_config.dets[bl],
49 [&](c_t
const &c_i, cdag_t
const &cdag_j,
auto const &Ginv_ji) {
50 buf_arrarr(bl)(cdag_j.u, c_i.u).push_back({double(cdag_j.tau), params.beta - double(c_i.tau)}, -Ginv_ji);
52 for (
auto &buf_arr : buf_arrarr)
53 for (auto &buf : buf_arr) buf.flush();
55 auto const &iW_mesh = std::get<0>(M4pp_iw_(0, 0).mesh());
56 auto const &iw_mesh = std::get<1>(M4pp_iw_(0, 0).mesh());
58 for (
int bl1 : range(params.n_blocks()))
59 for (
int bl2 : range(params.n_blocks())) {
60 int bl1_size = M[bl1].target_shape()[0];
61 int bl2_size = M[bl2].target_shape()[0];
62 auto const &M1 = M[bl1];
63 auto const &M2 = M[bl2];
64 auto &M4 = M4pp_iw_(bl1, bl2);
66 for (
auto iW : iW_mesh)
67 for (
auto iw : iw_mesh)
68 for (
auto iwp : iw_mesh)
69 for (
int i : range(bl1_size))
70 for (
int j : range(bl1_size)) {
71 auto M1val = M1[iW - iwp, iw.value()](j, i);
73 for (
int k : range(bl2_size))
74 for (
int l : range(bl2_size)) {
75 M4[iW, iw, iwp](i, j, k, l) += sign * M1val * M2[iwp.value(), iW - iw](l, k);
76 if (bl1 == bl2) { M4[iW, iw, iwp](i, j, k, l) -= sign * M1[iwp.value(), iw.value()](l, i) * M2[iW - iwp, iW - iw](j, k); }
84 Z = mpi::all_reduce(Z, comm);
85 M4pp_iw_ = mpi::all_reduce(M4pp_iw_, comm);
86 M4pp_iw_ = M4pp_iw_ / (Z * params.beta);
void accumulate(mc_weight_t sign)
Accumulate M_tau using binning.
void collect_results(mpi::communicator const &comm)
Collect results and normalize.