TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
M_tau.cpp
1// Copyright (c) 2017--present, The Simons Foundation
2// This file is part of TRIQS/ctint and is licensed under the terms of GPLv3 or later.
3// SPDX-License-Identifier: GPL-3.0-or-later
4// See LICENSE in the root of this distribution for details.
5
6#include "./M_tau.hpp"
7
8namespace triqs_ctint::measures {
9
10 M_tau::M_tau(params_t const &params_, qmc_config_t const &qmc_config_, container_set *results) : params(params_), qmc_config(qmc_config_) {
11
12 // Init measurement container and capture view
13 results->M_tau = block_gf<imtime, M_tau_target_t>{{params.beta, Fermion, params.n_tau}, params.gf_struct};
14 M_tau_.rebind(results->M_tau.value());
15 M_tau_() = 0;
16
17 results->M_hartree = make_block_vector<M_tau_scalar_t>(params.gf_struct);
18 for (auto &m : results->M_hartree.value()) M_hartree_.push_back(m);
19 }
20
21 void M_tau::accumulate(mc_weight_t sign) {
22 // Accumulate sign
23 Z += sign;
24
25 // Loop over blocks
26 // for (auto const & [D,M] : triqs::std::zip(config.dets, results->M_tau)) // C++17
27 for (int b = 0; b < M_tau_.size(); ++b) {
28 // Loop over every index pair (x,y) in the determinant matrix
29 // for (auto const & [x,y,Ginv] : D ) // C++17
30 foreach (qmc_config.dets[b], [&](c_t const &c_i, cdag_t const &cdag_j, auto const &Ginv) {
31 // Check for the equal-time case
32 if (c_i.tau == cdag_j.tau) {
33 M_hartree_[b](cdag_j.u, c_i.u) += Ginv * sign;
34 } else {
35
36 // Absolut time-difference tau of the index pair
37 auto [s, dtau] = cyclic_difference(cdag_j.tau, c_i.tau);
38
39 // Project tau to closest point on the binning grid
40 M_tau_[b][closest_mesh_pt(dtau)](cdag_j.u, c_i.u) += Ginv * s * sign;
41 }
42 });
43 }
44 }
45
46 void M_tau::collect_results(mpi::communicator const &comm) {
47 // Collect results and normalize
48 Z = mpi::all_reduce(Z, comm);
49 M_tau_ = mpi::all_reduce(M_tau_, comm);
50 double dtau = M_tau_[0].mesh().delta();
51 M_tau_ = M_tau_ / (-Z * dtau * params.beta);
52 for (auto &m : M_hartree_) {
53 m = mpi::all_reduce(m, comm);
54 m = m / (-Z * params.beta);
55 }
56
57 // Multiply first and last bin by two
58 for (auto &M : M_tau_) {
59 M[0] *= 2.0;
60 M[params.n_tau - 1] *= 2.0;
61 }
62 }
63
64} // namespace triqs_ctint::measures
void accumulate(mc_weight_t sign)
Accumulate M_tau using binning.
Definition M_tau.cpp:21
void collect_results(mpi::communicator const &comm)
Collect results and normalize.
Definition M_tau.cpp:46