TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
chiAB_tau.cpp
1// Copyright (c) 2018--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 "./chiAB_tau.hpp"
7#include "./../types.hpp"
8
9using namespace triqs::utility;
10
11namespace triqs_ctint::measures {
12
13 chiAB_tau::chiAB_tau(params_t const &params_, qmc_config_t &qmc_config_, container_set *results)
14 : params(params_), qmc_config(qmc_config_), tau_mesh{params_.beta, Boson, params_.n_tau_chi2} {
15
16 if (params.chi_A_vec.size() == 0 or params.chi_B_vec.size() == 0)
17 TRIQS_RUNTIME_ERROR << " Empty operator vector detected in chiAB measurement \n";
18
19 for (auto A : params.chi_A_vec) A_vec.emplace_back(get_terms(A, params.gf_struct));
20 for (auto B : params.chi_B_vec) B_vec.emplace_back(get_terms(B, params.gf_struct));
21
22 // Init measurement container and capture view
23 results->chiAB_tau = gf<imtime>{tau_mesh, make_shape(A_vec.size(), B_vec.size())};
24 chiAB_tau_.rebind(results->chiAB_tau.value());
25 chiAB_tau_() = 0;
26 }
27
28 void chiAB_tau::accumulate(mc_weight_t sign) {
29 // Accumulate sign
30 Z += sign;
31
32 for (auto [j, B] : enumerate(B_vec))
33 for (auto &[coef_B, bl_pair_B, idx_pair_B] : B) {
34
35 auto [idx_cdag_B, idx_c_B] = idx_pair_B;
36 auto cdag_B = cdag_t{tau_t::get_zero_plus(), idx_cdag_B};
37 auto c_B = c_t{tau_t::get_zero(), idx_c_B};
38 auto [bl_cdag_B, bl_c_B] = bl_pair_B;
39
40 for (auto [i, A] : enumerate(A_vec))
41 for (auto &[coef_A, bl_pair_A, idx_pair_A] : A) {
42
43 auto [idx_cdag_A, idx_c_A] = idx_pair_A;
44 auto cdag_A = cdag_t{tau_t::get_zero_plus(), idx_cdag_A};
45 auto c_A = c_t{tau_t::get_zero(), idx_c_A};
46 auto [bl_cdag_A, bl_c_A] = bl_pair_A;
47
48 // Determine the block order in the quartet of operators
49 bool is_AABB = (bl_cdag_A == bl_c_A && bl_cdag_B == bl_c_B);
50 bool is_ABAB = (bl_cdag_A == bl_c_B && bl_cdag_B == bl_c_A);
51 bool is_AAAA = is_AABB && is_ABAB;
52
53 // Define the determinants to operate on
54 auto &det_1 = qmc_config.dets[bl_cdag_A];
55 auto &det_2 = is_AABB ? qmc_config.dets[bl_cdag_B] : qmc_config.dets[bl_c_A];
56
57 for (auto tau : tau_mesh) {
58 auto tau_point = make_tau_t(double(tau));
59 auto taup_point = tau_point;
60
61 // Time-Ordering
62 tau_point.n += 3; // tau -> tau^{+++}
63 taup_point.n += 2; // taup -> tau^{++}
64
65 if (tau.index() == params.n_tau_chi2 - 1) {
66 tau_point = tau_t::get_beta_minus();
67 taup_point = tau_t::get_beta_minus_minus();
68 }
69
70 cdag_A.tau = tau_point;
71 c_A.tau = taup_point;
72
73 // TODO Extend for measurement of pairing response functions
74 if (is_AAAA)
75 chiAB_tau_[tau](i, j) += coef_A * coef_B * sign * det_1.try_insert2(0, 1, 0, 1, c_A, c_B, cdag_A, cdag_B);
76 else if (is_AABB)
77 chiAB_tau_[tau](i, j) += coef_A * coef_B * sign * det_1.try_insert(0, 0, c_A, cdag_A) * det_2.try_insert(0, 0, c_B, cdag_B);
78 else if (is_ABAB) // In this case we have to swap c_A and c_B, which leads to a minus sign
79 chiAB_tau_[tau](i, j) -= coef_A * coef_B * sign * det_1.try_insert(0, 0, c_B, cdag_A) * det_2.try_insert(0, 0, c_A, cdag_B);
80 // Note: All other block combinations vanish
81
82 det_1.reject_last_try();
83 det_2.reject_last_try();
84 }
85 }
86 }
87 }
88
89 void chiAB_tau::collect_results(mpi::communicator const &comm) {
90 // Collect results and normalize
91 Z = mpi::all_reduce(Z, comm);
92 chiAB_tau_ = mpi::all_reduce(chiAB_tau_, comm);
93 chiAB_tau_ = chiAB_tau_ / Z;
94 }
95
96} // namespace triqs_ctint::measures
void accumulate(mc_weight_t sign)
Accumulate M_tau using binning.
Definition chiAB_tau.cpp:28
void collect_results(mpi::communicator const &comm)
Collect results and normalize.
Definition chiAB_tau.cpp:89
static constexpr tau_t get_zero()
Return \tau = 0.
Definition vertex.hpp:48
static constexpr tau_t get_beta_minus_minus()
Return \tau = beta^{–} = \beta - 2*\delta.
Definition vertex.hpp:63
static constexpr tau_t get_beta_minus()
Return \tau = beta^{-} = \beta - \delta.
Definition vertex.hpp:60
static constexpr tau_t get_zero_plus()
Return \tau = 0^{+} = 0 + \delta.
Definition vertex.hpp:51