9namespace triqs_ctint::measures {
11 M4_iw::M4_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, Fermion, params.n_iw_M4};
16 mesh::prod<imfreq, imfreq, imfreq> M4_iw_mesh{iw_mesh, iw_mesh, iw_mesh};
19 results->M4_iw = make_block2_gf(M4_iw_mesh, params.gf_struct);
20 M4_iw_.rebind(results->M4_iw.value());
24 mesh::imfreq iw_mesh_large{params.beta, Fermion, 3 * params.n_iw_M4};
25 mesh::prod<imfreq, imfreq> M_mesh{iw_mesh_large, iw_mesh};
28 M = block_gf{M_mesh, params.gf_struct};
31 for (
int bl : range(params.n_blocks())) {
32 auto init_target_func = [&](
int i,
int j) {
33 return nfft_buf_t<2>{slice_target_to_scalar(M[bl], i, j).data(), params.nfft_buf_size, params.beta, params.nfft_tol};
35 buf_arrarr(bl) = array_adapter{M[bl].target_shape(), init_target_func};
45 for (
int bl : range(params.n_blocks()))
47 foreach (qmc_config.dets[bl],
48 [&](c_t
const &c_i, cdag_t
const &cdag_j,
auto const &Ginv_ji) {
49 buf_arrarr(bl)(cdag_j.u, c_i.u).push_back({double(cdag_j.tau), params.beta - double(c_i.tau)}, -Ginv_ji);
51 for (
auto &buf_arr : buf_arrarr)
52 for (auto &buf : buf_arr) buf.flush();
54 auto const &iw_mesh = std::get<0>(M4_iw_(0, 0).mesh());
56 for (
int bl1 : range(params.n_blocks()))
57 for (
int bl2 : range(params.n_blocks())) {
58 int bl1_size = M[bl1].target_shape()[0];
59 int bl2_size = M[bl2].target_shape()[0];
60 auto const &M1 = M[bl1];
61 auto const &M2 = M[bl2];
62 auto &M4 = M4_iw_(bl1, bl2);
64 for (
auto iw1 : iw_mesh)
65 for (
auto iw2 : iw_mesh)
66 for (
auto iw3 : iw_mesh)
67 for (
int i : range(bl1_size))
68 for (
int j : range(bl1_size)) {
69 auto M1val = M1[iw2.value(), iw1](j, i);
71 for (
int k : range(bl2_size))
72 for (
int l : range(bl2_size)) {
73 auto iw4 = iw1 + iw3 - iw2;
74 M4[iw1, iw2, iw3](i, j, k, l) += sign * M1val * M2[iw4, iw3](l, k);
75 if (bl1 == bl2) { M4[iw1, iw2, iw3](i, j, k, l) -= sign * M1[iw4, iw1](l, i) * M2[iw2.value(), iw3](j, k); }
83 Z = mpi::all_reduce(Z, comm);
84 M4_iw_ = mpi::all_reduce(M4_iw_, comm);
85 M4_iw_ = M4_iw_ / (Z * params.beta);
void collect_results(mpi::communicator const &comm)
Collect results and normalize.
void accumulate(mc_weight_t sign)
Accumulate M_tau using binning.