mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 05:43:40 +01:00
Fixed abs bug in bravais_lattice + added method
When constructing the last unit vector in 2D, the sanity check was wrong because of usage of abs instead of std::abs. Added method energy_on_bz_path_2 that returns the energy *matrix* at each k point on a given path instead of the eigenvalues of this matrix. The name of the function should be changed (to energy_matrix_on_bz_path?) Renaming energies_on_bz_path_2 to energy_matrix_on_bz_path
This commit is contained in:
parent
7752db89c2
commit
3aa380ba9d
@ -27,6 +27,7 @@ cdef extern from "triqs/lattice/tight_binding.hpp" namespace "triqs::gf" :
|
||||
pair [array[double,ONE],array[double,TWO]] dos_c "dos" (tight_binding & TB, size_t nkpts, size_t neps)
|
||||
pair [array[double,ONE],array[double,ONE]] dos_patch_c "dos_patch" (tight_binding & TB, array_view[double,TWO] & triangles, size_t neps, size_t ndiv)
|
||||
array_view[double,TWO] energies_on_bz_path_c "energies_on_bz_path" (tight_binding & TB, tqa_vector[double] & K1, tqa_vector[double] & K2, size_t n_pts)
|
||||
array_view[complex,THREE] energy_matrix_on_bz_path_c "energy_matrix_on_bz_path" (tight_binding & TB, tqa_vector[double] & K1, tqa_vector[double] & K2, size_t n_pts)
|
||||
array_view[double,TWO] energies_on_bz_grid_c "energies_on_bz_grid" (tight_binding & TB, size_t n_pts)
|
||||
|
||||
cdef class BravaisLattice :
|
||||
@ -104,6 +105,10 @@ def energies_on_bz_path ( TightBinding TB, K1, K2, n_pts) :
|
||||
""" """
|
||||
return energies_on_bz_path_c (deref(TB._c), tqa_vector[double](K1), tqa_vector[double] (K2), n_pts).to_python()
|
||||
|
||||
def energy_matrix_on_bz_path ( TightBinding TB, K1, K2, n_pts) :
|
||||
""" """
|
||||
return energy_matrix_on_bz_path_c (deref(TB._c), tqa_vector[double](K1), tqa_vector[double] (K2), n_pts).to_python()
|
||||
|
||||
def energies_on_bz_grid ( TightBinding TB, n_pts) :
|
||||
""" """
|
||||
return energies_on_bz_grid_c (deref(TB._c), n_pts).to_python()
|
||||
|
@ -20,14 +20,14 @@
|
||||
#
|
||||
################################################################################
|
||||
|
||||
__all__ = ['BravaisLattice', 'TightBinding', 'dos', 'dos_patch', 'energies_on_bz_grid', 'energies_on_bz_path',
|
||||
__all__ = ['BravaisLattice', 'TightBinding', 'dos', 'dos_patch', 'energies_on_bz_grid', 'energies_on_bz_path', 'energy_matrix_on_bz_path',
|
||||
'hopping_stack', 'TBLattice']
|
||||
|
||||
from lattice_tools import BravaisLattice as BravaisLattice
|
||||
from lattice_tools import TightBinding as TightBinding
|
||||
from lattice_tools import dos_patch as dos_patch_c
|
||||
from lattice_tools import dos as dos_c
|
||||
from lattice_tools import energies_on_bz_grid, energies_on_bz_path, hopping_stack
|
||||
from lattice_tools import energies_on_bz_grid, energies_on_bz_path, hopping_stack, energy_matrix_on_bz_path
|
||||
from pytriqs.dos import DOS
|
||||
import numpy
|
||||
|
||||
|
@ -5,6 +5,7 @@ using namespace triqs::arrays;
|
||||
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
|
||||
#include <triqs/gfs/local/fourier_matsubara.hpp>
|
||||
#include<fstream>
|
||||
#include <stdexcept>
|
||||
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
|
||||
|
||||
void print_to_file(std::string const s, gf<imtime> const & gt){
|
||||
|
@ -64,6 +64,7 @@ namespace lattice {
|
||||
uy(2) = 1;
|
||||
uy = cross_product(units_(0, _), units_(1, _));
|
||||
delta = sqrt(dot(uy, uy));
|
||||
using std::abs;
|
||||
if (abs(delta) < almost_zero) TRIQS_RUNTIME_ERROR << "Bravais Lattice : the 2 vectors of unit are not independent : " << units__;
|
||||
units_(2, _) = uy / delta;
|
||||
break;
|
||||
|
@ -64,6 +64,19 @@ namespace lattice {
|
||||
return eval;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
array<dcomplex, 3> energy_matrix_on_bz_path(tight_binding const& TB, k_t const& K1, k_t const& K2, int n_pts) {
|
||||
auto TK = fourier(TB);
|
||||
int norb = TB.lattice().n_orbitals();
|
||||
int ndim = TB.lattice().dim();
|
||||
array<dcomplex, 3> eval(norb,norb,n_pts);
|
||||
k_t dk = (K2 - K1) / double(n_pts), k = K1;
|
||||
for (int i = 0; i < n_pts; ++i, k += dk) {
|
||||
eval(range(),range(),i) = TK(k(range(0, ndim)))();
|
||||
}
|
||||
return eval;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
array<double, 2> energies_on_bz_grid(tight_binding const& TB, int n_pts) {
|
||||
|
||||
|
@ -93,6 +93,7 @@ namespace lattice {
|
||||
std::pair<array<double, 1>, array<double, 1>> dos_patch(tight_binding const& TB, const array<double, 2>& triangles, int neps,
|
||||
int ndiv);
|
||||
array<double, 2> energies_on_bz_path(tight_binding const& TB, k_t const& K1, k_t const& K2, int n_pts);
|
||||
array<dcomplex, 3> energy_matrix_on_bz_path(tight_binding const& TB, k_t const& K1, k_t const& K2, int n_pts);
|
||||
array<double, 2> energies_on_bz_grid(tight_binding const& TB, int n_pts);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user