TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
gf_tut_matsub_2.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 on the product mesh
15 auto g2 = gf{iw_mesh * iw_mesh, {1, 1}};
16
17 //the shortest way to fill a gf
18 placeholder<0> iw_;
19 placeholder<1> inu_;
20 g2[iw_, inu_] << 1 / (iw_ + inu_ - 4);
21 std::cout << g2(0, 0) << std::endl;
22
23 // An equivalent way to initialize
24 g2() = 0.0;
25 for (auto [w, nu] : g2.mesh()) g2[w, nu] = 1 / (w + nu - 4);
26 std::cout << g2(0, 0) << std::endl;
27}
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 .