mirror of
https://github.com/triqs/dft_tools
synced 2025-01-12 14:08:24 +01:00
deprecated gfs files removed
This commit is contained in:
parent
b2603dcf3a
commit
04cf39a361
@ -1,91 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#ifndef TRIQS_GF_RE_IM_FREQ_H
|
|
||||||
#define TRIQS_GF_RE_IM_FREQ_H
|
|
||||||
#include "./tools.hpp"
|
|
||||||
#include "./gf.hpp"
|
|
||||||
#include "./refreq.hpp"
|
|
||||||
#include "./imfreq.hpp"
|
|
||||||
#include "./meshes/product.hpp"
|
|
||||||
|
|
||||||
namespace triqs { namespace gfs {
|
|
||||||
|
|
||||||
struct re_im_freq {};
|
|
||||||
|
|
||||||
// the mesh
|
|
||||||
template<typename Opt> struct gf_mesh<re_im_freq,Opt> : mesh_product<gf_mesh<refreq,Opt>,gf_mesh<imfreq,Opt>> {
|
|
||||||
typedef gf_mesh<refreq,Opt> m1_t;
|
|
||||||
typedef gf_mesh<imfreq,Opt> m2_t;
|
|
||||||
typedef mesh_product<m1_t,m2_t> B;
|
|
||||||
gf_mesh () = default;
|
|
||||||
gf_mesh (double wmin, double wmax, int n_freq_re, double beta, statistic_enum S, int n_freq_im) :
|
|
||||||
B { gf_mesh<refreq,Opt>(wmin,wmax,n_freq_re,full_bins), gf_mesh<imfreq,Opt>(beta, S, n_freq_im)} {}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gfs_implementation {
|
|
||||||
|
|
||||||
// singularity
|
|
||||||
template<typename Opt> struct singularity<re_im_freq,scalar_valued,Opt> { typedef gf<refreq,scalar_valued> type;};
|
|
||||||
|
|
||||||
// h5 name
|
|
||||||
template<typename Opt> struct h5_name<re_im_freq,scalar_valued,Opt> { static std::string invoke(){ return "GfReImFreq";}};
|
|
||||||
|
|
||||||
/// --------------------------- data access ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct data_proxy<re_im_freq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt>
|
|
||||||
struct evaluator<re_im_freq,scalar_valued,Opt> {
|
|
||||||
static constexpr int arity = 2;
|
|
||||||
template<typename G>
|
|
||||||
std::complex<double> operator() (G const * g, double w, long n) const {
|
|
||||||
auto & data = g->data();
|
|
||||||
auto & mesh = g->mesh();
|
|
||||||
int nr; double wr; bool in;
|
|
||||||
std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()), w);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
|
||||||
auto gg = [g,data,mesh]( int nr, int n) {return data(mesh.index_to_linear(std::tuple<int,int>{nr,n}));};
|
|
||||||
return wr * gg(nr,n) + (1-wr) * gg(nr+1,n) ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------- Factories --------------------------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct factories<re_im_freq, scalar_valued,Opt> {
|
|
||||||
typedef gf<re_im_freq, scalar_valued,Opt> gf_t;
|
|
||||||
struct target_shape_t {};
|
|
||||||
// typedef typename gf_mesh<re_im_freq, Opt>::type mesh_t;
|
|
||||||
|
|
||||||
static gf_t make_gf(double wmin, double wmax, int nw, double beta, statistic_enum S, int nwn) {
|
|
||||||
auto m = gf_mesh<re_im_freq,Opt>(wmin, wmax, nw, beta, S, nwn);
|
|
||||||
typename gf_t::data_regular_t A(m.size());
|
|
||||||
A() =0;
|
|
||||||
return gf_t (m, std::move(A), gf<refreq,scalar_valued>({wmin, wmax, nw}), nothing() ) ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // gfs_implementation
|
|
||||||
|
|
||||||
}}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#ifndef TRIQS_GF_RE_IM_TIMES_H
|
|
||||||
#define TRIQS_GF_RE_IM_TIMES_H
|
|
||||||
#include "../tools.hpp"
|
|
||||||
#include "../gf.hpp"
|
|
||||||
#include "../retime.hpp"
|
|
||||||
#include "../imtime.hpp"
|
|
||||||
#include "../meshes/product.hpp"
|
|
||||||
#include "./tool.hpp"
|
|
||||||
|
|
||||||
namespace triqs { namespace gfs {
|
|
||||||
|
|
||||||
struct re_im_time {};
|
|
||||||
|
|
||||||
// the gf_mesh
|
|
||||||
template<typename Opt> struct gf_mesh<re_im_time,Opt> : mesh_product<gf_mesh<retime,Opt>,gf_mesh<imtime,Opt>> {
|
|
||||||
typedef gf_mesh<retime,Opt> m1_t;
|
|
||||||
typedef gf_mesh<imtime,Opt> m2_t;
|
|
||||||
typedef mesh_product<m1_t,m2_t> B;
|
|
||||||
gf_mesh () = default;
|
|
||||||
gf_mesh (double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) :
|
|
||||||
B {gf_mesh<retime,Opt>(tmin,tmax,nt), gf_mesh<imtime,Opt>(beta,S, ntau, mk)} {}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gfs_implementation {
|
|
||||||
|
|
||||||
// singularity
|
|
||||||
//template<typename Opt> struct singularity<re_im_time, scalar_valued, Opt> { typedef gf<retime,scalar_valued> type;};
|
|
||||||
|
|
||||||
// h5 name
|
|
||||||
template<typename Opt> struct h5_name<re_im_time,scalar_valued,Opt> { static std::string invoke(){ return "GfReImTime";}};
|
|
||||||
|
|
||||||
/// --------------------------- data access ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct data_proxy<re_im_time,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
|
||||||
template<typename Opt>
|
|
||||||
struct evaluator<re_im_time,scalar_valued,Opt> {
|
|
||||||
static constexpr int arity = 2;
|
|
||||||
template<typename G>
|
|
||||||
std::complex<double> operator() (G const * g, double t, double tau) const {
|
|
||||||
double beta = std::get<1>(g->mesh().components()).domain().beta;
|
|
||||||
int p = std::floor(tau/beta);
|
|
||||||
tau -= p*beta;
|
|
||||||
size_t nr,ni; double wr,wi; bool in;
|
|
||||||
std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()),t);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds, tmax=" << std::get<0>(g->mesh().components()).x_max() << ", tmin=" << std::get<0>(g->mesh().components()).x_min() << "here, t=" <<t;
|
|
||||||
std::tie(in, ni, wi) = windowing( std::get<1>(g->mesh().components()),tau);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds, taumax=" << std::get<1>(g->mesh().components()).x_max()<< ", taumin=" << std::get<1>(g->mesh().components()).x_min() << "here, tau=" <<tau;
|
|
||||||
auto gg = on_mesh(*g); //[g]( size_t nr, size_t ni) {return g->on_mesh(nr,ni);}; //data( g->mesh().index_to_linear(nr,ni));
|
|
||||||
auto res = (1-wr) * ( (1-wi) * gg(nr,ni) + wi * gg(nr,ni+1)) + wr * ( (1-wi) * gg(nr+1,ni) + wi * gg(nr+1,ni+1));
|
|
||||||
return ((std::get<1>(g->mesh().components()).domain().statistic == Fermion) && (p%2==1) ? -res : res);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------- Factories --------------------------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct factories<re_im_time, scalar_valued,Opt> {
|
|
||||||
typedef gf<re_im_time, scalar_valued,Opt> gf_t;
|
|
||||||
struct target_shape_t {};
|
|
||||||
|
|
||||||
template<typename MeshType>
|
|
||||||
static gf_t make_gf(MeshType && m) {
|
|
||||||
typename gf_t::data_regular_t A(m.size());
|
|
||||||
A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gf_t make_gf(double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) {
|
|
||||||
auto m = gf_mesh<re_im_time,Opt>(tmin,tmax, nt, beta, S, ntau, mk);
|
|
||||||
typename gf_t::data_regular_t A(m.size());
|
|
||||||
A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing());
|
|
||||||
//return gf_t (m, std::move(A), make_gf<retime,scalar_valued>(tmin, tmax, nt), nothing());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // gfs_implementation
|
|
||||||
|
|
||||||
// CHANGE THIS NAME !!!
|
|
||||||
template<typename RHS, bool V, bool C, typename Variable, typename Target, typename Opt >
|
|
||||||
void assign_from_expression (gf_impl<Variable,Target,Opt,V,C> const &, RHS) {}
|
|
||||||
|
|
||||||
//slices
|
|
||||||
inline gf_view<retime,scalar_valued> slice_mesh_imtime (gf_view<re_im_time,scalar_valued> g, size_t index) {
|
|
||||||
auto arr = reinterpret_linear_array(g.mesh(),g.data()); // view it as a 2d array
|
|
||||||
return { std::get<0>(g.mesh().components()), arr(arrays::range(), index), local::tail(1,1), nothing() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/* gf_view<imtime,scalar_valued> slice_mesh_retime ( gf_view<re_im_time,scalar_valued> g, size_t index) {
|
|
||||||
auto arr = reinterpret_linear_array(g.mesh(),g.data()); // view it as a 2d array
|
|
||||||
return { std::get<1>(g.mesh().components()), arr(index, arrays::range()), g.singularity().singularity(), nothing() };
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// gf_view<retime,scalar_valued> slice_meshes ( gf_view<re_im_time,scalar_valued> g, size_t index) {
|
|
||||||
// return { std::get<0>(g.mesh().components()), g.data()(arrays::range(), index), tail ( g.singularity(.......) ), g.symmetry()}
|
|
||||||
// }
|
|
||||||
|
|
||||||
}}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#ifndef TRIQS_GF_IMTIME_REFREQ_TIMES_H
|
|
||||||
#define TRIQS_GF_IMTIME_REFREQ_TIMES_H
|
|
||||||
#include "./tools.hpp"
|
|
||||||
#include "./gf.hpp"
|
|
||||||
#include "./imtime.hpp"
|
|
||||||
#include "./refreq.hpp"
|
|
||||||
#include "./meshes/product.hpp"
|
|
||||||
|
|
||||||
namespace triqs { namespace gfs {
|
|
||||||
|
|
||||||
struct refreq_imtime {};
|
|
||||||
|
|
||||||
// the mesh
|
|
||||||
template<typename Opt> struct gf_mesh<refreq_imtime,Opt> :mesh_product<gf_mesh<refreq,Opt>,gf_mesh<imtime,Opt>> {
|
|
||||||
typedef gf_mesh<refreq,Opt> m1_t;
|
|
||||||
typedef gf_mesh<imtime,Opt> m2_t;
|
|
||||||
typedef mesh_product<m1_t,m2_t> B;
|
|
||||||
gf_mesh () = default;
|
|
||||||
gf_mesh(B const & x) : B(x) {}
|
|
||||||
gf_mesh (double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins ) :
|
|
||||||
B {gf_mesh<refreq,Opt>(wmin,wmax,n_freq), gf_mesh<imtime,Opt>(beta,S,nt,mk)} {}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gfs_implementation {
|
|
||||||
// singularity
|
|
||||||
//template<typename Opt> struct singularity<refreq_imtime,scalar_valued,Opt> { typedef gf<retime,scalar_valued> type;};
|
|
||||||
|
|
||||||
// h5 name
|
|
||||||
template<typename Opt> struct h5_name<refreq_imtime,scalar_valued,Opt> { static std::string invoke(){ return "GfReFreqImTime";}};
|
|
||||||
|
|
||||||
/// --------------------------- data access ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct data_proxy<refreq_imtime,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt>
|
|
||||||
struct evaluator<refreq_imtime,scalar_valued,Opt> {
|
|
||||||
static constexpr int arity = 2;
|
|
||||||
template<typename G>
|
|
||||||
std::complex<double> operator() (G const * g, double omega, double tau) const {
|
|
||||||
double beta = std::get<1>(g->mesh().components()).domain().beta;
|
|
||||||
int p = std::floor(tau/beta);
|
|
||||||
tau -= p*beta;
|
|
||||||
size_t n1,n2; double w1,w2; bool in;
|
|
||||||
std::tie(in, n1, w1) = windowing( std::get<0>(g->mesh().components()),omega);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
|
||||||
std::tie(in, n2, w2) = windowing( std::get<1>(g->mesh().components()),tau);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
|
||||||
auto gg = on_mesh(*g); //[g]( size_t n1, size_t n2) {return g->on_mesh(n1,n2);};
|
|
||||||
auto res = w1 *( w2*gg(n1,n2) + (1-w2)*gg(n1,n2+1)) + (1-w1) * ( w2*gg(n1+1,n2) + (1-w2)*gg(n1+1,n2+1));
|
|
||||||
|
|
||||||
//std::cout << "eval reref imtim"<< n1 << " "<< n2 << " "<< w1 << " " << w2 << " "<< omega << " "<< tau<< std::endl;
|
|
||||||
|
|
||||||
return ((std::get<1>(g->mesh().components()).domain().statistic == Fermion) && (p%2==1) ? -res : res);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------- Factories --------------------------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct factories<refreq_imtime, scalar_valued,Opt> {
|
|
||||||
typedef gf<refreq_imtime, scalar_valued,Opt> gf_t;
|
|
||||||
struct target_shape_t {};
|
|
||||||
|
|
||||||
template<typename MeshType>
|
|
||||||
static gf_t make_gf(MeshType && m) {
|
|
||||||
typename gf_t::data_regular_t A(m.size());
|
|
||||||
A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gf_t make_gf(double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins) {
|
|
||||||
auto m = gf_mesh<refreq_imtime,Opt>(wmin, wmax, n_freq, beta,S, nt, mk);
|
|
||||||
typename gf_t::data_regular_t A(m.size());
|
|
||||||
A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing() ) ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // gfs_implementation
|
|
||||||
|
|
||||||
//slices
|
|
||||||
inline gf_view<refreq,scalar_valued> slice_mesh_imtime (gf_view<refreq_imtime,scalar_valued> g, size_t index) {
|
|
||||||
auto arr = reinterpret_linear_array(g.mesh(),g.data()); // view it as a 2d array
|
|
||||||
return { std::get<0>(g.mesh().components()), arr(arrays::range(),index), local::tail(1,1), nothing() };
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#pragma once
|
|
||||||
#include "../gf.hpp"
|
|
||||||
|
|
||||||
namespace triqs { namespace gfs {
|
|
||||||
|
|
||||||
// make_gf and make_gf_view forward any args to them
|
|
||||||
template <typename Variable, typename Target = matrix_valued, typename Opt = void, typename... U>
|
|
||||||
gf<Variable, Target, Opt> make_gf(gf_mesh<Variable, Opt> m, U &&... x) {
|
|
||||||
return gfs_implementation::factories<Variable, Target, Opt>::make_gf(std::move(m), std::forward<U>(x)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Variable, typename Target = matrix_valued, typename Opt = void, typename... U>
|
|
||||||
gf<Variable, Target, Opt> make_gf(U &&... x) {
|
|
||||||
return gfs_implementation::factories<Variable, Target, Opt>::make_gf(std::forward<U>(x)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Variable, typename Target = matrix_valued, typename Opt = void, typename... U>
|
|
||||||
gf_view<Variable, Target, Opt> make_gf_view(U &&... x) {
|
|
||||||
return gfs_implementation::factories<Variable, Target, Opt>::make_gf_view(std::forward<U>(x)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#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"
|
|
||||||
#include "./tool.hpp"
|
|
||||||
|
|
||||||
namespace triqs { namespace gfs {
|
|
||||||
|
|
||||||
struct two_real_times {};
|
|
||||||
|
|
||||||
// the mesh
|
|
||||||
template<typename Opt> struct gf_mesh<two_real_times,Opt> :mesh_product<gf_mesh<retime,Opt> ,gf_mesh<retime,Opt> > {
|
|
||||||
typedef mesh_product<gf_mesh<retime,Opt> ,gf_mesh<retime,Opt> > B;
|
|
||||||
gf_mesh() = default;
|
|
||||||
gf_mesh (double tmax, double n_time_slices) :
|
|
||||||
B(gf_mesh<retime,Opt> ( 0, tmax,n_time_slices, full_bins),
|
|
||||||
gf_mesh<retime,Opt> ( 0, tmax,n_time_slices, full_bins) ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gfs_implementation {
|
|
||||||
|
|
||||||
/// --------------------------- closest mesh point on the grid ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt>
|
|
||||||
struct get_closest_point <two_real_times,matrix_valued,Opt> {
|
|
||||||
typedef typename gf_mesh<two_real_times, Opt>::type mesh_t;
|
|
||||||
|
|
||||||
// // NOT FINISHED, NOT TESTED
|
|
||||||
// template<typename G, typename T>
|
|
||||||
// static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap<T,T> const & p) {
|
|
||||||
// return std::floor( double(p.value) / g->mesh().delta() + 0.5);
|
|
||||||
// }
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// h5 name
|
|
||||||
template<typename Opt> struct h5_name<two_real_times,matrix_valued,Opt> { static std::string invoke(){ return "GfTwoRealTime";}};
|
|
||||||
template<typename Opt> struct h5_name<two_real_times,scalar_valued,Opt> { static std::string invoke(){ return "GfTwoRealTime_s";}};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt, typename Target>
|
|
||||||
struct evaluator<two_real_times,Target,Opt> {
|
|
||||||
static constexpr int arity = 2;
|
|
||||||
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, double t1) const {
|
|
||||||
int n0,n1; double w0,w1; bool in;
|
|
||||||
std::tie(in, n0, w0) = windowing(std::get<0>(g->mesh().components()),t0);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
|
||||||
std::tie(in, n1, w1) = windowing(std::get<1>(g->mesh().components()),t1);
|
|
||||||
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
|
|
||||||
auto gg = on_mesh(*g);
|
|
||||||
return (1-w0) * ( (1-w1) * gg(n0, n1) + w1 * gg(n0, n1+1) ) + w0 * ( (1-w1) * gg(n0+1, n1) + w1 * gg(n0+1, n1+1));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// --------------------------- data access ---------------------------------
|
|
||||||
|
|
||||||
template<typename Opt> struct data_proxy<two_real_times,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {};
|
|
||||||
template<typename Opt> struct data_proxy<two_real_times,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
|
|
||||||
|
|
||||||
// ------------------------------- Factories --------------------------------------------------
|
|
||||||
|
|
||||||
//matrix_valued
|
|
||||||
template<typename Opt> struct factories<two_real_times, matrix_valued,Opt> {
|
|
||||||
typedef gf<two_real_times, matrix_valued,Opt> gf_t;
|
|
||||||
typedef gf_mesh<two_real_times, Opt> mesh_t;
|
|
||||||
typedef tqa::mini_vector<int,2> target_shape_t;
|
|
||||||
|
|
||||||
static gf_t make_gf(double tmax, double n_time_slices, tqa::mini_vector<int,2> shape) {
|
|
||||||
auto m = gf_mesh<two_real_times,Opt>(tmax, n_time_slices);
|
|
||||||
typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing() ) ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//scalar_valued
|
|
||||||
template<typename Opt> struct factories<two_real_times, scalar_valued,Opt> {
|
|
||||||
typedef gf<two_real_times, scalar_valued,Opt> gf_t;
|
|
||||||
typedef gf_mesh<two_real_times, Opt> mesh_t;
|
|
||||||
struct target_shape_t {};
|
|
||||||
|
|
||||||
static gf_t make_gf(double tmax, double n_time_slices) {
|
|
||||||
auto m = gf_mesh<two_real_times,Opt>(tmax, n_time_slices);
|
|
||||||
typename gf_t::data_regular_t A(m.size()); A() =0;
|
|
||||||
return gf_t (m, std::move(A), nothing(), nothing() ) ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // gfs_implementation
|
|
||||||
|
|
||||||
// ------------------------------- Additionnal free function for this gf --------------------------------------------------
|
|
||||||
|
|
||||||
// from g(t,t') and t, return g(t-t') for any t'>t
|
|
||||||
//
|
|
||||||
inline gf<retime> slice (gf_view<two_real_times> const & g, double t) {
|
|
||||||
auto const & m = std::get<0> (g.mesh().components()); //one-time mesh
|
|
||||||
int it = get_closest_mesh_pt_index(m, t); //index of t on this mesh
|
|
||||||
int nt = m.size() - it;
|
|
||||||
if (it+1 < nt) nt = it+1 ; //nt=length of the resulting GF's mesh
|
|
||||||
double dt = m.delta();
|
|
||||||
auto res = gf<retime>{{0, 2*(nt-1)*dt, nt}, g(t,t).shape()};
|
|
||||||
res() = 0;
|
|
||||||
auto _ = arrays::range();// everyone
|
|
||||||
for(int sh=0; sh<nt; sh++){
|
|
||||||
res.data()(sh,_,_) = g.data()(g.mesh().index_to_linear(std::make_tuple( it+sh, it-sh) ),_,_);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the 1 time mesh from the 2 times cartesian product (for cython interface mainly)
|
|
||||||
template<typename M>
|
|
||||||
auto get_1d_mesh_from_2times_mesh(M const & m) DECL_AND_RETURN(std::get<0>(m.components()));
|
|
||||||
|
|
||||||
}}
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user