2013-10-16 23:55:26 +02:00
|
|
|
#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
|
|
|
|
#include <triqs/gfs.hpp>
|
|
|
|
using namespace triqs::gfs;
|
|
|
|
using namespace triqs::arrays;
|
2013-07-19 13:28:30 +02:00
|
|
|
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
|
2013-10-16 23:55:26 +02:00
|
|
|
#include <triqs/gfs/local/fourier_matsubara.hpp>
|
2013-07-19 13:28:30 +02:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
double precision=10e-9;
|
|
|
|
H5::H5File file("test_fourier_matsubara.h5",H5F_ACC_TRUNC);
|
|
|
|
triqs::clef::placeholder<0> om_;
|
|
|
|
double beta =1;
|
|
|
|
int N=10000;
|
|
|
|
double E=1;
|
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
auto Gw1 = gf<imfreq> {{beta, Fermion, N}, {1,1}};
|
2013-07-19 13:28:30 +02:00
|
|
|
Gw1(om_) << 1/(om_-E);
|
|
|
|
h5_write(file, "Gw1", Gw1); // the original lorentzian
|
|
|
|
|
2013-10-16 23:55:26 +02:00
|
|
|
auto Gt1 = gf<imtime> {{beta, Fermion, N}, {1,1}};
|
2013-11-30 22:28:51 +01:00
|
|
|
Gt1() = inverse_fourier(Gw1);
|
2013-07-19 13:28:30 +02:00
|
|
|
h5_write(file, "Gt1", Gt1); // the lorentzian TF : lorentzian_inverse
|
|
|
|
|
|
|
|
///verification that TF(TF^-1)=Id
|
2013-10-16 23:55:26 +02:00
|
|
|
auto Gw1b = gf<imfreq> {{beta, Fermion, N}, {1,1}};
|
2013-11-30 22:28:51 +01:00
|
|
|
Gw1b() = fourier(Gt1);
|
2013-07-19 13:28:30 +02:00
|
|
|
for(auto const& w:Gw1.mesh()){
|
2013-07-28 13:47:42 +02:00
|
|
|
if ( std::abs(Gw1b[w](0,0)-Gw1[w](0,0)) > precision) TRIQS_RUNTIME_ERROR<<" fourier_matsubara error : w="<<std::complex<double>(w)<<" ,Gw1b="<<std::abs(Gw1b[w](0,0))<<"\n";
|
2013-07-19 13:28:30 +02:00
|
|
|
}
|
|
|
|
h5_write(file,"Gw1b",Gw1b); // must be 0
|
|
|
|
|
|
|
|
///verification that the TF is OK
|
|
|
|
for(auto const & t:Gt1.mesh()){
|
2013-07-28 13:47:42 +02:00
|
|
|
Gt1[t]-= exp(-E*t) * ( (t>0?-1:0)+1/(1+exp(E*beta)) );
|
|
|
|
if ( std::abs(Gt1[t](0,0)) > precision) TRIQS_RUNTIME_ERROR<<" fourier_matsubara error : t="<<t<<" ,G1="<<std::abs(Gt1[t](0,0))<<"\n";
|
2013-07-19 13:28:30 +02:00
|
|
|
}
|
|
|
|
h5_write(file,"Gt1b",Gt1); // must be 0
|
|
|
|
|
2013-10-23 15:51:51 +02:00
|
|
|
///to verify that fourier computes
|
2013-10-16 23:55:26 +02:00
|
|
|
auto Gw2 = gf<imfreq> {{beta, Fermion}, {1,1}};
|
2013-10-23 15:51:51 +02:00
|
|
|
Gw2() = fourier(Gt1);
|
2013-07-19 13:28:30 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|