/******************************************************************************* * * TRIQS: a Toolbox for Research in Interacting Quantum Systems * * Copyright (C) 2012 by M. Ferrero, O. Parcollet * * TRIQS is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * TRIQS. If not, see . * ******************************************************************************/ #ifndef TRIQS_GF_TWO_TIMES_H #define TRIQS_GF_TWO_TIMES_H #include "./tools.hpp" #include "./gf.hpp" #include "./retime.hpp" #include "./meshes/product.hpp" namespace triqs { namespace gf { struct two_real_times {}; namespace gf_implementation { // the mesh template struct mesh { typedef typename mesh::type m1_t; typedef mesh_product type; static type make (double tmax, double n_time_slices) { #ifndef TRIQS_WORKAROUND_INTEL_COMPILER_BUGS m1_t m1({},0, tmax,n_time_slices, triqs::gf::full_bins); return {m1,m1}; #else m1_t m1(typename m1_t::domain_t(),0, tmax,n_time_slices, triqs::gf::full_bins); type m(m1,m1); return m; #endif } }; // h5 name template struct h5_name { static std::string invoke(){ return "GfTwoRealTime";}}; /// --------------------------- closest mesh point on the grid --------------------------------- template struct get_closest_point { typedef typename mesh::type mesh_t; // NOT FINISHED, NOT TESTED template static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap const & p) { double x = (g->mesh().kind()==half_bins ? double(p.value) : double(p.value)+ 0.5*g->mesh().delta()); size_t n = std::floor(x/g->mesh().delta()); return n; } }; /// --------------------------- evaluator --------------------------------- template struct evaluator { static constexpr int arity = 2; template arrays::matrix_view > operator() (G const * g, double t0, double t1) const { auto & m0 = std::get<0>(g->mesh().components()); double s= m0.x_max()/m0.size(); return g->data()(g->mesh().index_to_linear( typename G::mesh_t::index_t(t0*s, t1*s)), arrays::range(), arrays::range());//mesh.index_to_linear(mesh.point_to_index (t1,t2))); } }; /// --------------------------- data access --------------------------------- template struct data_proxy : data_proxy_array,3> {}; // ------------------------------- Factories -------------------------------------------------- template struct factories { typedef gf gf_t; typedef typename mesh::type mesh_t; static gf_t make_gf(double tmax, double n_time_slices, tqa::mini_vector shape) { auto m = mesh::make(tmax, n_time_slices); typename gf_t::data_non_view_t A(shape.front_append(m.size())); A() =0; return gf_t (m, std::move(A), nothing(), nothing() ) ; } }; // ------------------------------- Path -------------------------------------------------- /* struct path { typedef typename mesh_t::index_t mesh_pt_t; typedef triqs::arrays::mini_vector delta_t; delta_t pt, delta; size_t L; path( mesh_t const & m, pt_t const & start_pt, delta_t const & d_) : pt(start_pt), delta(d_), L(std::get<1>(m.components()).size()){} void advance() { pt += delta;} bool out_of_mesh () const { return (! ( (pt[1]>=0) && ( pt[0] >= pt[1]) && (pt[0]<= L)));} typedef mesh_pt_generator iterator; iterator begin() const { return {this, false};} iterator end() const { return {this, true};} }; path make_path ( mesh_t const & m, typename mesh_t::index_t starting_point, delta) { return path(m, starting_point,delta); } // for (auto & p : make_path(G.mesh(), make_tuple(i,j), make_tuple(di,dj) )) G(p) +=0; */ } // gf_implementation // ------------------------------- Additionnal free function for this gf -------------------------------------------------- // from g(t,t') and t, return g(t-t') for any t'>t gf slice (gf_view const & g, double t) { auto const & m = std::get<0> (g.mesh().components()); long it = get_closest_mesh_pt_index(m, t); long nt = m.size() - it; if (it < nt) nt = it ; double dt = m.delta(); auto res = make_gf(0, nt*dt, nt, g(t,t).shape()); res() = 0; auto _ = arrays::range();// everyone for(long sh=0; sh auto get_1d_mesh_from_2times_mesh(M const & m) DECL_AND_RETURN(std::get<0>(m.components())); }} #endif