TRIQS/triqs_cthyb 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
types.hpp
1/*******************************************************************************
2 *
3 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
4 *
5 * Copyright (C) 2017, H. U.R. Strand, N. Wentzell
6 *
7 * TRIQS is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * TRIQS. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
22#pragma once
23
24#define STR(x) #x
25#define STRINGIZE(x) STR(x)
26
27#include <triqs/gfs.hpp>
28#include <triqs/mesh.hpp>
29#include <triqs/utility/time_pt.hpp>
30#include <triqs/hilbert_space/fundamental_operator_set.hpp> // gf_struct_t
31#include <triqs/stat/histograms.hpp>
32#include <triqs/atom_diag/atom_diag.hpp>
33
34#include <itertools/itertools.hpp>
35
36#include "config.hpp"
37
38#include <variant>
39
40namespace triqs_cthyb {
41
42 using namespace triqs::gfs;
43 using namespace triqs::mesh;
44 using namespace triqs::utility;
45 using namespace triqs::stat;
46 using namespace itertools;
47
48 using atom_diag = triqs::atom_diag::atom_diag<is_h_scalar_complex>;
49
50 using triqs::hilbert_space::gf_struct_t;
51 using triqs::utility::time_pt;
52 using op_t = std::pair<time_pt, int>;
53 using histo_map_t = std::map<std::string, histogram>;
54
55 using indices_type = triqs::operators::indices_t;
56 using gf_struct_t = triqs::hilbert_space::gf_struct_t;
57
58 // One-particle Green's function types
59 using G_tau_t = block_gf<imtime, matrix_valued>;
60 using G_tau_G_target_t = block_gf<imtime, G_target_t>;
61 using G_iw_t = block_gf<imfreq, matrix_valued>;
62 using G_l_t = block_gf<triqs::gfs::legendre, matrix_valued>;
63
64 // Two-particle Green's function types
65 using imtime_cube_mesh_t = prod<imtime, imtime, imtime>;
66 using G2_tau_t = block2_gf<imtime_cube_mesh_t, tensor_valued<4>>;
67
68 using imfreq_cube_mesh_t = prod<imfreq, imfreq, imfreq>;
69 using G2_iw_t = block2_gf<imfreq_cube_mesh_t, tensor_valued<4>>;
70
71 using imfreq_legendre_mesh_t = prod<imfreq, triqs::gfs::legendre, triqs::gfs::legendre>;
72 using G2_iwll_t = block2_gf<imfreq_legendre_mesh_t, tensor_valued<4>>;
73
74 enum class G2_channel { PP, PH, AllFermionic }; // G2 sampling channels
75
77 enum class block_order { AABB, ABBA };
78
79 inline void h5_write(h5::group h5group, std::string name, block_order const &bo) { h5_write(h5group, name, static_cast<int>(bo)); }
80
81 inline void h5_read(h5::group h5group, std::string name, block_order &bo) {
82 int idx;
83 h5_read(h5group, name, idx);
84 bo = static_cast<block_order>(idx);
85 }
86
87} // namespace triqs_cthyb
88
89namespace triqs {
90 namespace gfs {
91
93 template <typename Var_t>
94 block2_gf<Var_t, tensor_valued<4>> make_block2_gf(Var_t const &m, triqs::hilbert_space::gf_struct_t const &gf_struct,
95 triqs_cthyb::block_order order = triqs_cthyb::block_order::AABB) {
96
97 std::vector<std::vector<gf<Var_t, tensor_valued<4>>>> gf_vecvec;
98 std::vector<std::string> block_names;
99
100 for (auto const &[bl1, bl1_size] : gf_struct) {
101 block_names.push_back(bl1);
102 std::vector<gf<Var_t, tensor_valued<4>>> gf_vec;
103 for (auto const &[bl2, bl2_size] : gf_struct) {
104 switch (order) {
105 case triqs_cthyb::block_order::AABB: gf_vec.emplace_back(m, make_shape(bl1_size, bl1_size, bl2_size, bl2_size)); break;
106 case triqs_cthyb::block_order::ABBA: gf_vec.emplace_back(m, make_shape(bl1_size, bl2_size, bl2_size, bl1_size)); break;
107 }
108 }
109 gf_vecvec.emplace_back(std::move(gf_vec));
110 }
111 return make_block2_gf(block_names, block_names, std::move(gf_vecvec));
112 }
113
114 } // namespace gfs
115} // namespace triqs