TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
legendre.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: Michel Ferrero, Olivier Parcollet, Nils Wentzell
19
24
25#include "./legendre.hpp"
26#include "../gf/defs.hpp"
28#include "../gf/gf_view.hpp"
31
32namespace triqs::gfs {
33
34 using nda::array;
35
36 //-------------------------------------------------------
37 // For Legendre functions
38 // ------------------------------------------------------
39
40 // compute a tail from the Legendre GF
41 // this is Eq. 8 of our paper
42 array<dcomplex, 3> get_tail(gf_const_view<mesh::legendre> gl, int order) {
43
44 auto sh = gl.data().shape();
45 sh[0] = order;
46 array<dcomplex, 3> t{sh};
47 t() = 0.0;
48
49 for (int p = 0; p < order; p++)
50 for (auto l : gl.mesh())
51 t(p, ellipsis{}) += (triqs::utility::legendre_t(static_cast<int>(l.index()), p) / std::pow(gl.mesh().beta(), p)) * gl[l];
52
53 return t;
54 }
55
56 // Impose a discontinuity G(\tau=0)-G(\tau=\beta)
57 void enforce_discontinuity(gf_view<mesh::legendre> gl, nda::array_const_view<double, 2> disc) {
58
59 double norm = 0.0;
60 nda::vector<double> t(gl.data().shape()[0]);
61 for (int i = 0; i < t.size(); ++i) {
62 t(i) = triqs::utility::legendre_t(i, 1) / gl.mesh().beta();
63 norm += t(i) * t(i);
64 }
65
66 nda::array<dcomplex, 2> corr(disc.shape());
67 corr() = 0;
68 for (auto l : gl.mesh()) corr += t(l.index()) * gl[l];
69
70 for (auto l : gl.mesh()) gl.data()(l.index(), range::all, range::all) += (disc - corr) * t(l.index()) / norm;
71 }
72
73} // namespace triqs::gfs
A read-only, non-owning view of a Green's function.
A mutable, non-owning view of a Green's function.
Definition gf_view.hpp:48
data_t & data() &
Get the data array view.
Definition gf_view.hpp:131
mesh_t const & mesh() const
Get the mesh of the Green's function.
Definition gf_view.hpp:125
Provides common type aliases, forward declarations and internal helpers for the Green's function cont...
Provides the triqs::gfs::gf_const_view container, a read-only non-owning view of a Green's function.
Provides a mutable non-owning view of a Green's function.
Provides functions specific to Legendre-basis Green's functions.
void enforce_discontinuity(gf_view< mesh::legendre > gl, nda::array_const_view< double, 2 > disc)
Enforce a prescribed jump at for a Legendre Green's function.
Definition legendre.cpp:57
double legendre_t(int l, int p)
Get the quantity from Eq.(E8) in the paper https://doi.org/10.1103/PhysRevB.84.075145.
Definition legendre.cpp:53
Provides a mesh type for Legendre polynomials as basis functions.
Provides Legendre polynomials and related functions.