TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
imtime.cpp
Go to the documentation of this file.
1// Copyright (c) 2016-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2016-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2023 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Philipp Dumitrescu, Michel Ferrero, Olivier Parcollet, Nils Wentzell
19
24
25#include "./imtime.hpp"
27#include "../gf/gf.hpp"
28#include "../../mesh/imtime.hpp"
29
30#include <cstddef>
31
32namespace triqs::gfs {
33
34 using nda::array;
35
36 //-------------------------------------------------------
37 // For Imaginary Time functions
38 // ------------------------------------------------------
40
41 auto const &old_m = g.mesh();
42 gf<mesh::imtime> new_gf{{old_m.beta(), old_m.statistic(), static_cast<long>(new_n_tau)}, g.target_shape()};
43 auto const &new_m = new_gf.mesh();
44 new_gf.data()() = 0;
45 long prev_index = 0;
46 long norm = 0;
47 for (auto const &tau : old_m) {
48 long index = std::lround(static_cast<double>(tau) / new_m.delta());
49 if (index == prev_index) {
50 norm++;
51 } else {
52 new_gf[index - 1] /= static_cast<double>(norm);
53 prev_index = index;
54 norm = 1;
55 }
56 new_gf[index] += g[tau];
57 }
58 if (norm != 1) new_gf[new_m.size() - 1] /= norm;
59 return new_gf;
60 }
61
62} // namespace triqs::gfs
A read-only, non-owning view of a Green's function.
mesh_t const & mesh() const
Get the mesh of the Green's function.
std::array< long, Target::rank > target_shape() const
Get the shape of the target.
The owning Green's function container.
Definition gf.hpp:194
data_t & data() &
Get the data array.
Definition gf.hpp:280
mesh_t const & mesh() const
Get the mesh of the Green's function.
Definition gf.hpp:274
Provides the triqs::gfs::gf_const_view container, a read-only non-owning view of a Green's function.
Provides imaginary-time Green's function utilities.
Provides the Green's function class.
gf< mesh::imtime > rebinning_tau(gf_const_view< mesh::imtime > const &g, size_t new_n_tau)
Rebin an imaginary-time Green's function onto a coarser uniform mesh.
Definition imtime.cpp:39
Provides a mesh type on the imaginary time axis.