TRIQS/triqs_modest 3.3.0
Modular Electronic Structure Toolkit
Loading...
Searching...
No Matches
chargedensity.hpp
Go to the documentation of this file.
1#pragma once
2#include "utils/defs.hpp"
3#include "utils/gf_supp.hpp"
4#include <triqs/mesh.hpp>
5#include "downfolding.hpp"
6#include "gloc_fixed_grid.hpp"
7
8namespace triqs::modest {
9
22 template <typename Mesh>
23 nda::array<dcomplex, 4> charge_density_correction(one_body_elements_on_grid const &obe, double mu,
24 block2_gf<Mesh, matrix_valued> const &Sigma_dynamic,
25 nda::array<nda::matrix<dcomplex>, 2> const &Sigma_static) {
26
27 auto n_sigma = obe.C_space.n_sigma(); // number of spin channesl
28 auto n_k = obe.H.n_k(); // number of k-points
29
30 // maximum number of bands
31 auto n_nu_k = range(n_k) | stdv::transform([&obe](auto k_idx) { return obe.H.N_nu(0, k_idx); }) | tl::to<std::vector>();
32 auto n_nu = *std::max_element(begin(n_nu_k), end(n_nu_k));
33
34 // setup data structure for return
35 auto N_nu_nup_k = nda::zeros<dcomplex>(n_k, n_sigma, n_nu, n_nu);
36
37 // calculator for lattice Green's function at given k and σ
38 auto glatt_at_k = detail::lattice_gf_at_k(obe, mu, Sigma_dynamic, Sigma_static);
39
40 // loop over k and σ
41 // TODO: parallelize over k and gather
42 for (auto k_idx : range(n_k)) {
43 for (auto const &sigma : range(n_sigma)) {
44 auto r_window = nda::range(0, obe.H.N_nu(sigma, k_idx));
45 N_nu_nup_k(k_idx, sigma, r_window, r_window) = density(glatt_at_k(k_idx, sigma));
46 }
47 }
48
49 return N_nu_nup_k;
50 }
51
52 template nda::array<dcomplex, 4> charge_density_correction(one_body_elements_on_grid const &obe, double mu,
53 block2_gf<imfreq, matrix_valued> const &Sigma_dynamic,
54 nda::array<nda::matrix<dcomplex>, 2> const &Sigma_static);
55
56} // namespace triqs::modest
long n_sigma() const
Dimension of the index.
double density(one_body_elements_on_grid const &obe, double mu, block2_gf< Mesh, matrix_valued > const &Sigma_dynamic, nda::array< nda::matrix< dcomplex >, 2 > const &Sigma_static)
Compute the density of the lattice Green's function with a self-energy using Woodbury.
Definition density.hpp:93
nda::array< dcomplex, 4 > charge_density_correction(one_body_elements_on_grid const &obe, double mu, block2_gf< Mesh, matrix_valued > const &Sigma_dynamic, nda::array< nda::matrix< dcomplex >, 2 > const &Sigma_static)
Compute the charge density correction from DMFT.
long n_k() const
Number of k-points in the grid.
long N_nu(long sigma, long k_idx) const
Number of bands for a given k-point and spin .
A one-body elements struct where all of the underlying data exists on a fixed momentum grid.
band_dispersion H
Band dispersion.