12 constexpr auto upfold_self_energy_at_freq(one_body_elements_on_grid
const &obe, downfolding_projector
const &Proj,
auto const &Sigma_w,
13 long w_idx,
long k_idx,
long sigma_idx) {
14 auto N_nu = obe.H.N_nu(sigma_idx, k_idx);
15 auto out = nda::zeros<dcomplex>(N_nu, N_nu);
17 auto P = Proj.P(sigma_idx, k_idx)(R,
r_all);
18 out(
r_all,
r_all) += dagger(P) * nda::matrix<dcomplex>{Sigma_w(alpha, sigma_idx).data()(w_idx,
r_all,
r_all)} * P;
24 constexpr auto lattice_gf_at_k(
auto const &mesh, one_body_elements_on_grid
const &obe, downfolding_projector
const &Proj,
double mu,
25 auto const &Sigma_w,
dcomplex broadening) {
26 return [&, mu, broadening](
auto &k_idx,
auto &sigma) {
27 if constexpr (Trace) {
29 for (
auto &&[n, w] : enumerate(mesh)) {
30 auto PSP = upfold_self_energy_at_freq(obe, Proj, Sigma_w, n, k_idx, sigma);
31 out.data()(n) = trace(inverse(w + broadening + mu - obe.H.H(sigma, k_idx) - PSP));
35 auto N_nu = obe.H.N_nu(sigma, k_idx);
36 auto out = gf{mesh, {N_nu, N_nu}};
37 for (
auto &&[n, w] : enumerate(mesh)) {
38 auto PSP = upfold_self_energy_at_freq(obe, Proj, Sigma_w, n, k_idx, sigma);
39 out.data()(n,
r_all,
r_all) = inverse(w + broadening + mu - obe.H.H(sigma, k_idx) - PSP);
46 constexpr auto local_gf_at_k(
auto const &mesh, one_body_elements_on_grid
const &obe, downfolding_projector
const &Proj,
double mu,
47 auto const &Sigma_w,
dcomplex broadening) {
48 return [&, mu, broadening](
auto &k_idx,
auto &sigma) {
49 auto n_M = obe.C_space.dim();
50 auto out = gf{mesh, {n_M, n_M}};
51 auto P = obe.P.P(sigma, k_idx);
52 for (
auto &&[n, w] : enumerate(mesh)) {
53 auto PSP = upfold_self_energy_at_freq(obe, Proj, Sigma_w, n, k_idx, sigma);
54 out.data()(n,
r_all,
r_all) = P * inverse(w + broadening + mu - obe.H.H(sigma, k_idx) - PSP) * dagger(P);
63 block2_gf<mesh::refreq, matrix_valued>
const &Sigma_w,
double broadening) {
65 auto const &mesh = Sigma_w(0, 0).mesh();
68 auto n_k = obe_theta.
H.
n_k();
70 auto gloc_at_k = detail::local_gf_at_k(mesh, obe_theta, Proj, mu, Sigma_w,
dcomplex(0, broadening));
74 for (
auto const &k_idx : range(n_k)) {
75 for (
auto const &sigma : range(n_sigma)) {
80 gloc_result = mpi::all_reduce(gloc_result);
85 auto n_w = mesh.size();
87 auto total = nda::array<double, 2>(n_sigma, n_w);
88 auto per_theta = nda::array<double, 4>(n_sigma, n_w, n_M, n_M);
90 for (
auto const &sigma : nda::range(n_sigma)) {
91 auto g = gloc_result(0, sigma).data();
92 auto gC = conj(gloc_result(0, sigma)).data();
93 for (
auto [n, w] : enumerate(mesh)) {
96 total(sigma, n) = (-1.0 / M_PI) * imag(trace(g(n,
r_all,
r_all)));
101 return {.total = total, .per_theta = per_theta};
105 block2_gf<mesh::refreq, matrix_valued>
const &Sigma_w,
double broadening) {
106 auto const &mesh = Sigma_w(0, 0).mesh();
108 auto n_w = mesh.size();
109 auto n_k = obe.
H.
n_k();
112 auto data = nda::array<double, 3>(n_sigma, n_k, n_w);
113 auto proj_data = nda::array<double, 5>(n_sigma, n_k, n_w, n_M, n_M);
115 auto trglatt_at_k = detail::lattice_gf_at_k<true>(mesh, obe, obe.
P, mu, Sigma_w, broadening);
116 auto glatt_at_k = detail::lattice_gf_at_k<false>(mesh, obe, obe.
P, mu, Sigma_w, broadening);
118 for (
auto k_idx : range(n_k)) {
119 for (
auto sigma : range(n_sigma)) {
120 data(sigma, k_idx,
r_all) = (-1.0 / M_PI) * imag(trglatt_at_k(k_idx, sigma).data());
121 auto P = obe.
P.
P(sigma, k_idx);
123 for (
auto n : range(n_w)) {
124 auto PGP = P * nda::matrix<dcomplex>{glatt_at_k(k_idx, sigma).data()(n,
r_all,
r_all)} * dagger(P);
125 proj_data(sigma, k_idx, n,
r_all,
r_all) = (-1.0 / M_PI) * imag(PGP);
129 return {.data = data, .proj_data = proj_data};
long n_sigma() const
Dimension of the index.
auto atomic_decomposition() const
Transformed view containing the dimension of each atomic shell.
long dim() const
Dimension of the correlated space.
C2PY_IGNORE gf_struct2_t Gc_block_shape() const
Shape of the Green function in the correlated space, without block decomposition.
spectral_function_w projected_spectral_function(one_body_elements_on_grid const &obe_theta, downfolding_projector const &Proj, double mu, block2_gf< mesh::refreq, matrix_valued > const &Sigma_w, double broadening)
Compute the atom- and orbital-resolved spectral function (interacting density of states).
spectral_function_kw spectral_function_on_high_symmetry_path(one_body_elements_on_grid const &obe, double mu, block2_gf< mesh::refreq, matrix_valued > const &Sigma_w, double broadening)
Compute momentum-resolved spectral function along high-symmetry path.
block2_gf< Mesh, matrix_valued > make_block2_gf(Mesh const &mesh, gf_struct2_t const &gf_s)
gf_struct_t get_struct(block_gf< Mesh > const &g)
static constexpr auto r_all
generator< std::pair< long, nda::range > > enumerated_sub_slices(auto sub_div)
std::complex< double > dcomplex
nda::array< double, 1 > k_weights
Weight in the BZ for each k-point.
long n_k() const
Number of k-points in the grid.
The projector that downfolds the energy bands onto a set of localized atomic-like orbitals.
nda::matrix_const_view< dcomplex > P(long sigma, long k_idx) const
Get for a given and .
A one-body elements struct where all of the underlying data exists on a fixed momentum grid.
local_space C_space
Local space.
band_dispersion H
Band dispersion.
downfolding_projector P
Downfolding projector .
C2PY_IGNORE std::optional< ibz_symmetry_ops > ibz_symm_ops
IBZ symmetrizer after a k-sum.
Returns Tr (A) [σ,k,ω] for all k points in obe grid and all omega in Sigma mesh.
Store data of spectral functions.