TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
gf_struct.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 Simons Foundation
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You may obtain a copy of the License at
14// https://www.gnu.org/licenses/gpl-3.0.txt
15//
16// Authors: Michel Ferrero, Nils Wentzell
17
22
23#pragma once
24
25#include <h5/h5.hpp>
26
27#include <string>
28#include <utility>
29#include <variant>
30#include <vector>
31
32namespace triqs::gfs {
33
41 using gf_struct_t = std::vector<std::pair<std::string, long>>;
42
54 inline void h5_read_gf_struct(h5::group g, std::string const &name, gf_struct_t &gf_struct) {
55 {
56 auto gobj = g.open_group(name);
57 if (gobj.has_subgroup("0")) {
58 auto bl0 = gobj.open_group("0");
59 // Each block of old gf_struct type has subgroup "1"
60 if (bl0.has_subgroup("1")) {
61 auto gf_struct_bkwd = std::vector<std::pair<std::string, std::vector<std::variant<int, std::string>>>>{};
62 h5::read(g, name, gf_struct_bkwd);
63 gf_struct.clear();
64 for (auto &[bl, idx_lst] : gf_struct_bkwd) gf_struct.push_back({bl, idx_lst.size()});
65 return;
66 }
67 }
68 }
69 h5::read(g, name, gf_struct);
70 }
71
72} // namespace triqs::gfs
gf_struct_t gf_struct() const
Get the block structure.
std::vector< std::pair< std::string, long > > gf_struct_t
Type describing the structure of a block Green's function.
Definition gf_struct.hpp:41
void h5_read_gf_struct(h5::group g, std::string const &name, gf_struct_t &gf_struct)
Read a triqs::gfs::gf_struct_t from HDF5, with a backward-compatibility layer for the old format.
Definition gf_struct.hpp:54