TRIQS/triqs_modest 3.3.0
Brillouin zone summation
Loading...
Searching...
No Matches
h5.cpp
Go to the documentation of this file.
1// Copyright (c) 2025--present, The Simons Foundation
2// This file is part of TRIQS/modest and is licensed under the terms of GPLv3 or later.
3// SPDX-License-Identifier: GPL-3.0-or-later
4// See LICENSE in the root of this distribution for details.
5
6#include <h5/h5.hpp>
7#include "downfolding.hpp"
8#include "embedding.hpp"
9#include <H5Tpublic.h> // HDF5 type creation API
10
11template <> h5::hid_t h5::detail::hid_t_of<triqs::modest::embedding::imp_block_t>() {
12 using S = triqs::modest::embedding::imp_block_t;
13 hid_t type = H5Tcreate(H5T_COMPOUND, sizeof(S));
14 H5Tinsert(type, "imp_idx", HOFFSET(S, imp_idx), H5T_NATIVE_INT);
15 H5Tinsert(type, "gamma", HOFFSET(S, gamma), H5T_NATIVE_INT);
16 H5Tinsert(type, "tau", HOFFSET(S, tau), H5T_NATIVE_INT);
17 return type;
18}
19
20namespace triqs::modest {
21
22 // spin_kind_e
23 void h5_read(h5::group g, std::string const &name, spin_kind_e &spin_kind) {
24 int value = h5_read<int>(g, name); // Read the integer representation
25 spin_kind = static_cast<spin_kind_e>(value); // Convert to spin_kind_e
26 }
27
28 void h5_write(h5::group g, std::string const &name, spin_kind_e const &spin_kind) {
29 int value = static_cast<int>(spin_kind); // Convert to integer representation
30 h5_write(g, name, value); // Write the integer representation
31 }
32
33 // projector
34 void h5_read(h5::group g, std::string const &name, downfolding_projector &proj) {
35 auto subgroup = g.open_group(name);
36 h5_read(subgroup, "spin_kind", proj.spin_kind);
37 h5_read(subgroup, "P_k", proj.P_k);
38 h5_read(subgroup, "n_bands_per_k", proj.n_bands_per_k);
39 }
40
41 void h5_write(h5::group g, std::string const &name, downfolding_projector const &proj) {
42 auto subgroup = g.create_group(name);
43 h5_write(subgroup, "spin_kind", proj.spin_kind);
44 h5_write(subgroup, "P_k", proj.P_k);
45 h5_write(subgroup, "n_bands_per_k", proj.n_bands_per_k);
46 }
47
48 // band_dispersion
49 void h5_read(h5::group g, std::string const &name, band_dispersion &bd) {
50 auto subgroup = g.open_group(name);
51 h5_read(subgroup, "spin_kind", bd.spin_kind);
52 h5_read(subgroup, "H_k", bd.H_k);
53 h5_read(subgroup, "n_bands_per_k", bd.n_bands_per_k);
54 h5_read(subgroup, "k_weights", bd.k_weights);
55 }
56 void h5_write(h5::group g, std::string const &name, band_dispersion const &bd) {
57 auto subgroup = g.create_group(name);
58 h5_write(subgroup, "spin_kind", bd.spin_kind);
59 h5_write(subgroup, "H_k", bd.H_k);
60 h5_write(subgroup, "n_bands_per_k", bd.n_bands_per_k);
61 h5_write(subgroup, "k_weights", bd.k_weights);
62 }
63
64 // atomic_shell
65 void h5_read(h5::group g, std::string const &name, atomic_orbs &shell) {
66 auto subgroup = g.open_group(name);
67 h5_read(subgroup, "dim", shell.dim);
68 h5_read(subgroup, "l", shell.l);
69 h5_read(subgroup, "cls_idx", shell.cls_idx);
70 h5_read(subgroup, "dft_idx", shell.dft_idx);
71 }
72 void h5_write(h5::group g, std::string const &name, atomic_orbs const &shell) {
73 auto subgroup = g.create_group(name);
74 h5_write(subgroup, "dim", shell.dim);
75 h5_write(subgroup, "l", shell.l);
76 h5_write(subgroup, "cls_idx", shell.cls_idx);
77 h5_write(subgroup, "dft_idx", shell.dft_idx);
78 }
79
80 // local_space
81 void h5_read(h5::group g, std::string const &name, local_space &ls) {
82 auto subgroup = g.open_group(name);
83 h5_read(subgroup, "spin_kind", ls._spin_kind);
84 h5_read(subgroup, "atomic_shells", ls._atomic_shells);
85 h5_read(subgroup, "block_decomposition", ls._irreps_decomp_per_atom);
86 }
87
88 void h5_write(h5::group g, std::string const &name, local_space const &ls) {
89 auto subgroup = g.create_group(name);
90 h5_write(subgroup, "spin_kind", ls._spin_kind);
91 h5_write(subgroup, "atomic_shells", ls._atomic_shells);
92 h5_write(subgroup, "block_decomposition", ls._irreps_decomp_per_atom);
93 }
94
95 // embedding
96 void h5_read(h5::group g, std::string const &name, embedding &embed) {
97 auto subgroup = g.open_group(name);
98 h5_read(subgroup, "sigma_embed_decomp", embed.sigma_embed_decomp);
99 h5_read(subgroup, "imp_decomps", embed.imp_decomps);
100 //h5_read(subgroup, "psi", embed.psi);
101 h5_read(subgroup, "sigma_names", embed._sigma_names);
102 }
103
104 void h5_write(h5::group g, std::string const &name, embedding const &embed) {
105 auto subgroup = g.create_group(name);
106 h5_write(subgroup, "sigma_embed_decomp", embed.sigma_embed_decomp);
107 h5_write(subgroup, "imp_decomps", embed.imp_decomps);
108 //h5_write(subgroup, "psi", embed.psi);
109 h5_write(subgroup, "sigma_names", embed._sigma_names);
110 }
111
112 // one_body_elements_on_grid
113 void h5_read(h5::group g, std::string const &name, one_body_elements_on_grid &obe) {
114 auto subgroup = g.open_group(name);
115 h5_read(subgroup, "H", obe.H);
116 h5_read(subgroup, "C_space", obe.C_space);
117 h5_read(subgroup, "P", obe.P);
118 //h5_read(subgroup, "ibz_symm_ops", obe.ibz_symm_ops);
119 }
120 void h5_write(h5::group g, std::string const &name, one_body_elements_on_grid const &obe) {
121 auto subgroup = g.create_group(name);
122 h5_write(subgroup, "H", obe.H);
123 h5_write(subgroup, "C_space", obe.C_space);
124 h5_write(subgroup, "P", obe.P);
125 //h5_write(subgroup, "ibz_symm_ops", obe.ibz_symm_ops);
126 }
127} // namespace triqs::modest
The embedding class.
Definition embedding.hpp:29
Describe the atomic orbitals within downfolded space.
void h5_write(h5::group g, std::string const &name, initial_data const &data)
spin_kind_e
Kind of σ index.
void h5_read(h5::group g, std::string const &name, initial_data &data)
Info on an atomic shell.
The one-body dispersion as a function of momentum.
nda::array< long, 2 > n_bands_per_k
n_bands_per_k [k_idx, σ'] = # of nu
nda::array< double, 1 > k_weights
k_weights[k_idx]
nda::array< dcomplex, 4 > H_k
H_k [k_idx, σ', nu, nu'].
spin_kind_e spin_kind
Spin kind of the one-body data.
The projector that downfolds the one-body dispersion (ν) onto local orbitals (m).
nda::array< dcomplex, 4 > P_k
Pk[alpha][k_idx, σ', m_alpha, nu].
nda::array< long, 2 > n_bands_per_k
n_bands_per_k [k_idx, σ'] = # of nu
A one-body elements struct where all of the underlying data exists on a fixed momentum grid.