25#define STRINGIZE(x) STR(x)
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>
31#include <triqs/stat/histograms.hpp>
32#include <triqs/atom_diag/atom_diag.hpp>
34#include <itertools/itertools.hpp>
40namespace triqs_cthyb {
42 using namespace triqs::gfs;
43 using namespace triqs::mesh;
44 using namespace triqs::utility;
45 using namespace triqs::stat;
46 using namespace itertools;
48 using atom_diag = triqs::atom_diag::atom_diag<is_h_scalar_complex>;
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>;
55 using indices_type = triqs::operators::indices_t;
56 using gf_struct_t = triqs::hilbert_space::gf_struct_t;
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>;
65 using imtime_cube_mesh_t = prod<imtime, imtime, imtime>;
66 using G2_tau_t = block2_gf<imtime_cube_mesh_t, tensor_valued<4>>;
68 using imfreq_cube_mesh_t = prod<imfreq, imfreq, imfreq>;
69 using G2_iw_t = block2_gf<imfreq_cube_mesh_t, tensor_valued<4>>;
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>>;
74 enum class G2_channel { PP, PH, AllFermionic };
77 enum class block_order { AABB, ABBA };
79 inline void h5_write(h5::group h5group, std::string name, block_order
const &bo) { h5_write(h5group, name,
static_cast<int>(bo)); }
81 inline void h5_read(h5::group h5group, std::string name, block_order &bo) {
83 h5_read(h5group, name, idx);
84 bo =
static_cast<block_order
>(idx);
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) {
97 std::vector<std::vector<gf<Var_t, tensor_valued<4>>>> gf_vecvec;
98 std::vector<std::string> block_names;
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) {
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;
109 gf_vecvec.emplace_back(std::move(gf_vec));
111 return make_block2_gf(block_names, block_names, std::move(gf_vecvec));