TRIQS/triqs_modest 3.3.0
Brillouin zone summation
Loading...
Searching...
No Matches
local_space.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 "./local_space.hpp"
7
8namespace triqs::modest {
9
10 local_space::local_space(spin_kind_e spin_kind, std::vector<atomic_orbs> atomic_shells, nda::array<std::vector<long>, 2> irreps_decomp_per_atom,
11 nda::array<nda::matrix<dcomplex>, 2> rotation_from_dft_to_local_basis,
12 nda::array<nda::matrix<dcomplex>, 1> rotation_from_spherical_to_dft_basis)
13 : _spin_kind{spin_kind},
14 _atomic_shells{std::move(atomic_shells)},
15 _irreps_decomp_per_atom{std::move(irreps_decomp_per_atom)},
16 _rotation_from_dft_to_local_basis{std::move(rotation_from_dft_to_local_basis)},
17 _rotation_from_spherical_to_dft_basis{std::move(rotation_from_spherical_to_dft_basis)} {
18
19 // Compute the dimension of the correlated space
20 _dim_C = stdr::fold_left(_atomic_shells | stdv::transform([](auto const &s) { return s.dim; }), 0, std::plus<>());
21
22 // Pre-compute the atom names
23 _atom_names = range(_atomic_shells.size()) | stdv::transform([](auto i) { return std::to_string(i); }) | tl::to<std::vector>();
24 };
25
26 [[nodiscard]] long local_space::first_shell_of_its_equiv_cls(long idx) const {
27 auto cls_idx = _atomic_shells[idx].cls_idx;
28 for (auto const &[iatom, sh] : enumerate(_atomic_shells)) {
29 if (cls_idx == sh.cls_idx) return iatom;
30 }
31 throw std::runtime_error("Can not find the atom in first_shell_of_its_equiv_cls");
32 };
33
34 nda::array<nda::matrix<dcomplex>, 2> local_space::atomic_view(nda::array<nda::matrix<dcomplex>, 2> const &matrix_C) {
35 // FIXME : ASSERT check the dimension of G_C m x m , one a block, n_sigma ...
36 auto matrix_out = nda::array<nda::matrix<dcomplex>, 2>{n_atoms(), n_sigma()};
37 for (auto sigma : range(n_sigma()))
38 for (auto const &[atom, r_atom] : enumerated_sub_slices(atomic_decomposition())) {
39 matrix_out(atom, sigma) = nda::matrix<dcomplex>{matrix_C(0, sigma)(r_atom, r_atom)};
40 }
41 return matrix_out;
42 }
43
45 auto res = nda::zeros<long>(1, n_sigma());
46 res(0, r_all) = dim();
47 return {.names = {{"0"s}, sigma_names()}, .dims = std::move(res)};
48 }
49} // namespace triqs::modest
block2_gf< Mesh > atomic_view(block2_gf< Mesh > const &G_C)
Views a block2gf according to the atomic decomposition.
long n_sigma() const
Dimension of the σ index.
local_space(spin_kind_e spin_kind, std::vector< atomic_orbs > atomic_shells, nda::array< std::vector< long >, 2 > irreps_decomp_per_atom, nda::array< nda::matrix< dcomplex >, 2 > rotation_from_dft_to_local_basis, nda::array< nda::matrix< dcomplex >, 1 > rotation_from_spherical_to_dft_basis)
auto atomic_decomposition() const
Generates [dimension of the atomic shell].
long dim() const
Dimension of the correlated space.
long n_atoms() const
The number of atoms.
std::vector< std::string > sigma_names() const
names of spin indices for naming blocks in block_gf
C2PY_IGNORE gf_struct2_t Gc_block_shape() const
Shape of the Green function in the correlated space, without block decomposition.
long first_shell_of_its_equiv_cls(long idx) const
Given the index idx of an atomic shell, return the index of the first atomic shell of its equivalence...
spin_kind_e
Kind of σ index.
static constexpr auto r_all
Definition defs.hpp:40
generator< std::pair< long, nda::range > > enumerated_sub_slices(auto sub_div)