TRIQS/triqs_cthyb 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
G_tau.cpp
1/*******************************************************************************
2 *
3 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
4 *
5 * Copyright (C) 2014, H. U.R. Strand, P. Seth, I. Krivenko, 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 "./G_tau.hpp"
23
24namespace triqs_cthyb {
25
26 using namespace triqs::gfs;
27 using namespace triqs::mesh;
28
29 measure_G_tau::measure_G_tau(qmc_data const &data, int n_tau, gf_struct_t const &gf_struct, container_set_t &results)
30 : data(data), average_sign(0) {
31 results.G_tau_accum = block_gf<imtime, G_target_t>({data.config.beta(), Fermion, n_tau}, gf_struct);
32 G_tau.rebind(*results.G_tau_accum);
33 G_tau() = 0.0;
34
35 results.asymmetry_G_tau = block_gf{G_tau};
36 asymmetry_G_tau.rebind(*results.asymmetry_G_tau);
37 }
38
39 void measure_G_tau::accumulate(mc_weight_t s) {
40 s *= data.atomic_reweighting;
41 average_sign += s;
42
43 for (auto block_idx : range(G_tau.size())) {
44 foreach (data.dets[block_idx], [this, s, block_idx](op_t const &x, op_t const &y, det_scalar_t M) {
45 // beta-periodicity is implicit in the argument, just fix the sign properly
46 auto val = (y.first >= x.first ? s : -s) * M;
47 double dtau = double(y.first - x.first);
48 this->G_tau[block_idx][closest_mesh_pt(dtau)](y.second, x.second) += val;
49 })
50 ;
51 }
52 }
53
54 void measure_G_tau::collect_results(mpi::communicator const &c) {
55
56 G_tau = mpi::all_reduce(G_tau, c);
57 average_sign = mpi::all_reduce(average_sign, c);
58
59 for (auto &G_tau_block : G_tau) {
60 double beta = G_tau_block.mesh().beta();
61 G_tau_block /= -real(average_sign) * beta * G_tau_block.mesh().delta();
62
63 // Multiply first and last bins by 2 to account for full bins
64 int last = G_tau_block.mesh().size() - 1;
65 G_tau_block[0] *= 2;
66 G_tau_block[last] *= 2;
67
68 // Enforce discontinuity in Green function
69 G_tau_block[0] = 0.5 * matrix_t(G_tau_block[0] - 1 - G_tau_block[last]);
70 G_tau_block[last] = -1 - G_tau_block[0];
71 }
72
73 // We enforce the fundamental Green function property G(tau)[i,j] = G(tau)*[j,i]
74 // and store the symmetry violation separately
75 asymmetry_G_tau = make_hermitian(G_tau) - G_tau;
76 G_tau = G_tau + asymmetry_G_tau;
77 }
78
79} // namespace triqs_cthyb
Container for all results accumulated by the simulation.