3#include "./bz_integrators.hpp"
5#include "../utility/root_finder.hpp"
9#include <itertools/omp_chunk.hpp>
17namespace triqs::experimental::lattice {
41 auto expr_kw = nda::linalg::inv((ph::w + mu) * I - nda::clef::make_expr(H_k)(ph::kx, ph::ky, ph::kz));
60 template <
typename Mesh>
64 auto I = nda::eye<dcomplex>(n_orbitals);
66 throw std::runtime_error(
"Number of orbitals in Hk " +
std::to_string(H_k.
n_orbitals()) +
" not matched to shape of self energy "
71 nda::linalg::inv((ph::w + mu) * I - nda::clef::make_expr(H_k)(ph::kx, ph::ky, ph::kz) - nda::clef::make_expr(std::move(Sigma))[ph::w]);
89 template <
typename Mesh>
94 for (
auto block : range(Sigma.
size())) { Gloc_result[block] =
gloc(H_k, mu, Sigma[block], opt); }
114 template <
typename Mesh>
116 bz_int_options const &opt, std::string method =
"dichotomy",
double precision = 1.e-5,
bool verbosity =
false) {
119 std::function<double(
double)> f = [&H_k, &Sigma, &opt](
double mu) {
121 for (
auto block : range(Sigma.
size())) {
122 auto Gloc =
gloc(H_k, mu, Sigma[block], opt);
127 return std::get<0>(
utility::root_finder(method, f, 0.0, target_density, precision, 0.5, 1000,
"Chemical Potential",
"Total Density", verbosity));
146 template <
typename Mesh>
148 bz_int_options const &opt, std::string method =
"dichotomy",
double precision = 1.e-5,
bool verbosity =
false) {
150 std::function<double(
double)> f = [&H_k, &Sigma, &opt](
double mu) {
151 auto Gloc =
gloc(H_k, mu, Sigma, opt);
154 return std::get<0>(
utility::root_finder(method, f, 0.0, target_density, precision, 0.5, 1000,
"Chemical Potential",
"Total Density", verbosity));
Tight-binding Hamiltonian on a 3D lattice.
long n_orbitals() const
Get the number of orbitals, i.e. the dimension of the Hamiltonian matrices.
The owning block Green's function container.
int size() const
Get the total number of blocks.
gf_struct_t gf_struct() const
Get the block structure.
The owning Green's function container.
mesh_t const & mesh() const
Get the mesh of the Green's function.
std::array< long, Target::rank > target_shape() const
Get the shape of the target.
Umbrella header for the Green's function library.
double find_chemical_potential(double const target_density, tb_hk const &H_k, gfs::block_gf< Mesh, gfs::matrix_valued > const &Sigma, bz_int_options const &opt, std::string method="dichotomy", double precision=1.e-5, bool verbosity=false)
Find the chemical potential that yields a target density for a block self-energy.
gfs::gf< Mesh, gfs::matrix_valued > gloc(Mesh const &w_mesh, tb_hk const &H_k, double mu, bz_int_options const &opt)
Compute the non-interacting local Green's function from a tight-binding Hamiltonian on a given mesh.
gf< Mesh, matrix_valued > integrate_bz(auto const &f_kw, Mesh const &w_mesh, bz_int_options const &opt, mpi::communicator comm={})
Integrate an expression over the Brillouin zone for all frequencies, combining PTR and adaptive integ...
std::pair< double, double > root_finder(std::string method, std::function< double(double)> f, double x_init, double y_value, double precision, double delta_x, long max_loops=1000, std::string x_name="", std::string y_name="", bool verbosity=false)
Find the value that solves using the requested root-finding method.
nda::matrix< dcomplex > density(gf_const_view< mesh::imfreq > g, array_const_view< dcomplex, 3 > known_moments)
Compute the density from a Green's function.
G::regular_type::real_t real(G const &g)
Take the real part of a Green's function (no check), returning a new Green's function with a real tar...
string to_string(string const &str)
Identity overload for std::string.
CLEF placeholders for the momentum and frequency arguments of integrable expressions.
Options controlling the combined PTR and adaptive Brillouin-zone integration.
Provides the target types that fix the value stored at each mesh point of a Green's function.