mirror of
https://github.com/triqs/dft_tools
synced 2025-01-12 05:58:18 +01:00
gf: test of retime and refreq improved, the scalar_valued evaluator now works.
This commit is contained in:
parent
43078dc597
commit
8b4404c1a9
@ -7,6 +7,7 @@ namespace tql= triqs::clef;
|
||||
namespace tqa= triqs::arrays;
|
||||
using tqa::range;
|
||||
using triqs::arrays::make_shape;
|
||||
using triqs::gf::scalar_valued;
|
||||
using triqs::gf::Fermion;
|
||||
using triqs::gf::refreq;
|
||||
using triqs::gf::retime;
|
||||
@ -17,21 +18,30 @@ using triqs::gf::make_gf;
|
||||
int main() {
|
||||
|
||||
double beta =1;
|
||||
auto G = make_gf<refreq> (-10, 10, 1000, make_shape(2,2));
|
||||
auto Gt = make_gf<retime> (0, 10, 1000, make_shape(2,2));
|
||||
auto Gt2 = make_gf<retime> (0, 10, 1000, make_shape(2,2));
|
||||
double tmax=10;
|
||||
int N=1000;
|
||||
auto Gw = make_gf<refreq> (-10, 10, N, make_shape(2,2));
|
||||
auto Gt = make_gf<retime> (0, tmax, N, make_shape(2,2));
|
||||
auto Gw2 = make_gf<refreq,scalar_valued> (-10, 10, N);
|
||||
auto Gt2 = make_gf<retime,scalar_valued> (0, tmax, N);
|
||||
|
||||
int i =0;
|
||||
for (auto & t : Gt.mesh()) Gt(t) = 1.0*t*t;
|
||||
for (auto & t : Gt.mesh()) Gt(t) = 1.0*t;
|
||||
for (auto & w : Gw.mesh()) Gw(w) = 1.0*w;
|
||||
|
||||
triqs::clef::placeholder<0> t_;
|
||||
Gt2( t_) << 2* t_; // * t_;
|
||||
|
||||
std::cout << Gt(3.255) << std::endl;
|
||||
//std::cout << Gt(3.2) << std::endl;
|
||||
triqs::clef::placeholder<1> w_;
|
||||
Gt2( t_) << 1.0*t_;
|
||||
Gw2( w_) << 1.0*w_;
|
||||
|
||||
std::cout << Gt(3.255)(0,0) << std::endl;
|
||||
std::cout << Gt2(3.255) << std::endl;
|
||||
std::cout << Gw(3.255)(0,0) << std::endl;
|
||||
std::cout << Gw2(3.255) << std::endl;
|
||||
|
||||
// test hdf5
|
||||
H5::H5File file("ess_gfre.h5", H5F_ACC_TRUNC );
|
||||
h5_write(file, "gt", Gt);
|
||||
h5_write(file, "gt2", Gt2);
|
||||
h5_write(file, "gt", Gt);
|
||||
h5_write(file, "gw", Gw);
|
||||
|
||||
}
|
||||
|
@ -52,20 +52,19 @@ namespace triqs { namespace gf {
|
||||
template<typename Opt, typename Target>
|
||||
struct evaluator<refreq,Target,Opt> {
|
||||
static constexpr int arity = 1;
|
||||
typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix_view<std::complex<double>>, std::complex<double>>::type rtype;
|
||||
typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double> >, std::complex<double>>::type rtype;
|
||||
template<typename G>
|
||||
rtype operator() (G const * g,double w0) const {
|
||||
auto & data = g->data();
|
||||
auto & mesh = g->mesh();
|
||||
size_t index; double w; bool in;
|
||||
std::tie(in, index, w) = windowing(mesh,w0);
|
||||
size_t n; double w; bool in;
|
||||
std::tie(in, n, w) = windowing(g->mesh(),w0);
|
||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
||||
return w*data(mesh.index_to_linear(index), arrays::ellipsis()) + (1-w)*data(mesh.index_to_linear(index+1), arrays::ellipsis());
|
||||
auto gg = on_mesh(*g);
|
||||
return (1-w) * gg(n) + w * gg(n+1);
|
||||
}
|
||||
template<typename G>
|
||||
local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();}
|
||||
};
|
||||
|
||||
|
||||
/// --------------------------- data access ---------------------------------
|
||||
template<typename Opt> struct data_proxy<refreq,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {};
|
||||
template<typename Opt> struct data_proxy<refreq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
|
||||
|
@ -58,14 +58,11 @@ namespace triqs { namespace gf {
|
||||
typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double>>, std::complex<double>>::type rtype;
|
||||
template<typename G>
|
||||
rtype operator() (G const * g,double t0) const {
|
||||
auto & data = g->data();
|
||||
auto & mesh = g->mesh();
|
||||
size_t index; double w; bool in;
|
||||
std::tie(in, index, w) = windowing(mesh,t0);
|
||||
size_t n; double w; bool in;
|
||||
std::tie(in, n, w) = windowing(g->mesh(),t0);
|
||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
||||
return
|
||||
(1-w) * data(mesh.index_to_linear(index ), arrays::ellipsis() )
|
||||
+ w * data(mesh.index_to_linear(index+1), arrays::ellipsis() );
|
||||
auto gg = on_mesh(*g);
|
||||
return (1-w) * gg(n) + w * gg(n+1);
|
||||
}
|
||||
template<typename G>
|
||||
local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();}
|
||||
|
Loading…
Reference in New Issue
Block a user