TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
gf_tut_matsub_1.cpp
1#include <triqs/gfs.hpp>
2#include <triqs/mesh.hpp>
3using namespace triqs;
4using namespace triqs::gfs;
5using nda::clef::placeholder;
6
7int main() {
8
9 // Create a Matsubara-frequency mesh
10 double beta = 1; // inverse temperature
11 int n_iw = 100; // number of Matsubara frequencies
12 auto iw_mesh = mesh::imfreq{beta, Fermion, n_iw};
13
14 // Create and fill a 1x1 Matsubara Green function
15 auto g = gf{iw_mesh, {1, 1}};
16 placeholder<0> iw_;
17 g[iw_] << 1 / (iw_ - 3);
18 std::cout << g(0) << std::endl;
19
20 // An equivalent way to initialize
21 g() = 0.0;
22 for (auto w : g.mesh()) g[w] = 1 / (w - 3);
23 std::cout << g(0) << std::endl;
24
25 //an incorrect way : throws exception as expected
26 //g(w) returns a const_view: () are to be used for interpolation, see bottom of the page
27 //for (auto w : g.mesh()) g(w) = 1/(w-3);
28}
The owning Green's function container.
Definition gf.hpp:194
Imaginary frequency mesh type.
Definition imfreq.hpp:102
Umbrella header for the Green's function library.
Umbrella header for the TRIQS mesh types.
constexpr nda::clef::placeholder< 3 > w
Placeholder for the frequency .