3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 19:23:45 +01:00

Fixed computation of density for full matsub mesh

-> Previously, calculation was implicitly assuming a mesh with only positive matsubara frequencies.
-> Added corresponding test
-> Also added test of density calculation with or without correct tail.
This commit is contained in:
tayral 2014-01-23 11:34:53 +00:00 committed by Olivier Parcollet
parent 6e87bee850
commit 82a6d21939
6 changed files with 66 additions and 5 deletions

View File

@ -42,8 +42,13 @@ int main() {
TEST(Gt(.9));
TEST(Gt(-.1));//should be equal to line above
//fourier
triqs::gfs::local::tail t(1,1);
gw_n (tau_) << 1/(tau_-1.);
auto gt_with_full_tail = make_gf_from_inverse_fourier(make_gf_from_g_and_tail(gw_n, gw.singularity()));
auto gt_tail_with_one_term = make_gf_from_inverse_fourier(make_gf_from_g_and_tail(gw_n, t));
TEST(gt_with_full_tail(.5));
TEST(gt_tail_with_one_term(.5));
}
TRIQS_CATCH_AND_ABORT;
}

View File

@ -6,3 +6,15 @@
(Gt(-.1)) ---> -0.40657
(gt_with_full_tail(.5)) ---> ((0.5 *
[[-0.44347,0]
[0,-0.44347]]) + (0.5 *
[[-0.443038,0]
[0,-0.443038]]))
(gt_tail_with_one_term(.5)) ---> ((0.5 *
[[-0.44347,0]
[0,-0.44347]]) + (0.5 *
[[-0.443038,0]
[0,-0.443038]]))

View File

@ -0,0 +1,33 @@
//#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
#include <triqs/gfs.hpp>
#include <triqs/gfs/local/functions.hpp>
using namespace triqs::gfs;
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;
int main() {
try {
double beta =1;int n_im_freq=400;
auto G = gf<imfreq, scalar_valued> {{beta, Fermion, n_im_freq,false}};
auto G_pos_only = gf<imfreq, scalar_valued> {{beta, Fermion, n_im_freq,true}};
TEST(G.mesh().positive_only());
TEST(G_pos_only.mesh().positive_only());
//std::cout << G.singularity() << std::endl ;
triqs::clef::placeholder<0> om_;
G(om_) << 1/(om_ + 2.3);
G_pos_only(om_) << 1/(om_ + 2.3);
auto n = triqs::gfs::density(G);
auto n_pos_only = triqs::gfs::density(G_pos_only);
TEST(n);
TEST(n_pos_only);
// test hdf5
//H5::H5File file("gf_scalar.h5", H5F_ACC_TRUNC);
//h5_write(file, "g", G);
//h5_write(file, "gm", reinterpret_scalar_valued_gf_as_matrix_valued(G));
}
TRIQS_CATCH_AND_ABORT;
}

View File

@ -0,0 +1,10 @@
(G.mesh().positive_only()) ---> 0
(G_pos_only.mesh().positive_only()) ---> 1
0
1
(n) ---> 0.908877
(n_pos_only) ---> 0.908877

View File

@ -157,7 +157,8 @@
[(0,0),(0.151719,-0.207234)]]
----------------- 4 --------------------
(density(G3)) --->
(density(G3)) ---> 1
[[1.81775,0]
[0,1.81775]]

View File

@ -53,10 +53,10 @@ namespace triqs { namespace gfs {
//dens_part(n1,n2) = dens_part(n1,n2)*(fact/Beta) + (d + F(a1,b1,Beta) + F(a2,b2,Beta)+ F(a3,b3,Beta));
//if (!Green_Function_Are_Complex_in_time) dens_part = 0+real(dens_part);
}
for (size_t n1=0; n1<N1;n1++)
for (size_t n2=0; n2<N2;n2++) {
dens_part(n1,n2) = dens_part(n1,n2) + real(dens_part(n2,n1)) - I * imag(dens_part(n2,n1)) + dens_tail(n1,n2);
dens_part(n1,n2) = dens_part(n1,n2) + (G.mesh().positive_only()? ( real(dens_part(n2,n1)) - I * imag(dens_part(n2,n1)) ) : 0) + dens_tail(n1,n2);
// ?? STRANGE ??
dens_part(n2,n1) = real(dens_part(n1,n2)) - I * imag(dens_part(n1,n2));
}