3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 19:23:45 +01:00
dft_tools/test/triqs/gfs/test_gf_triqs.cpp
tayral 3aa380ba9d 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
2014-05-08 12:09:58 +01:00

69 lines
1.5 KiB
C++

#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
#include <triqs/gfs.hpp>
using namespace triqs::gfs;
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){
std::ofstream mfile(s);
if(mfile.is_open()){
for(int i=0;i<gt.mesh().size();i++){
mfile << gt.mesh().index_to_point(i) << "\t" << gt.data()(i,0,0) << std::endl;
}
mfile.close();
}
else{
throw std::runtime_error("Could not print to file");
}
}
void test_0(){
int Ntau = 10001;
double beta =1;
/* ---------- construct a Green's function ---------*/
auto G = gf<imfreq> {{beta, Fermion, 100}, {1,1}};
triqs::clef::placeholder<0> om_;
G(om_) << 1./(om_ - 2.1);
/* ---------- Fourier transform ---------------------*/
auto Gt = gf<imtime> {{beta, Fermion, Ntau, full_bins}, {1,1}};
Gt() = inverse_fourier(G);
TEST(Gt(0.0));
TEST(Gt.data());
TEST(Gt.mesh().index_to_point(0));
TEST(Gt.mesh().index_to_point(1));
}
void test_1(){
double beta=10;
/* ----- Fourier ----- */
auto Gt = gf<imtime> {{beta, Fermion, 100,full_bins}, {1,1}};
auto Gw = gf<imfreq> {{beta, Fermion, 100}, {1,1}};
Gw.singularity()(1) = 1;
Gt() = inverse_fourier(Gw);
}
int main() {
test_0();
test_1();
}