TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
average_k.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 "./average_k.hpp"
7
8namespace triqs_ctint::measures {
9
10 average_k::average_k(params_t const &, qmc_config_t const &qmc_config_, container_set *results)
11 : qmc_config(qmc_config_), average_k_(results->average_k), average_k_error_(results->average_k_error), k_bins_(dcomplex{0.0}, 128, 1) {
12 average_k_ = 0.0;
13 }
14
15 void average_k::accumulate(mc_weight_t) {
16 auto k = qmc_config.perturbation_order();
17 average_k_ += k;
18 k_bins_ << dcomplex(double(k));
19 ++N;
20 }
21
22 void average_k::collect_results(mpi::communicator const &comm) {
23 average_k_ = mpi::all_reduce(average_k_, comm);
24 N = mpi::all_reduce(N, comm);
25 average_k_ = average_k_ / N;
26
27 auto [m, err, tau] = k_bins_.mean_error_and_tau(comm);
28 average_k_error_ = std::abs(err);
29 }
30
31 std::string average_k::report() const {
32 std::ostringstream os;
33 os << "Average perturbation order: " << average_k_ / N;
34 return os.str();
35 }
36
37} // namespace triqs_ctint::measures
Measure of the average perturbation order.
Definition average_k.hpp:14
std::string report() const
Report current value representation.
Definition average_k.cpp:31
void accumulate(mc_weight_t)
Accumulate average perturbation order.
Definition average_k.cpp:15
void collect_results(mpi::communicator const &comm)
Reduce and normalize.
Definition average_k.cpp:22