mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 13:53:40 +01:00
gf: clean h5name
- _s automatically done for scalar_valued. - add simple reinterpretation of gf scalar to matrix view to easy h5 saving to plot in python
This commit is contained in:
parent
c5c016aa79
commit
f6fa63c9b3
@ -64,6 +64,8 @@ namespace triqs { namespace gfs {
|
|||||||
// This trait contains functions to read/write in hdf5 files. Can be specialized for some descriptor (Cf block)
|
// This trait contains functions to read/write in hdf5 files. Can be specialized for some descriptor (Cf block)
|
||||||
template <typename Variable, typename Target, typename Opt> struct h5_name; // value is a const char *
|
template <typename Variable, typename Target, typename Opt> struct h5_name; // value is a const char *
|
||||||
|
|
||||||
|
template<typename Variable, typename Opt> struct h5_name<Variable,scalar_valued,Opt> { static std::string invoke(){ return h5_name<Variable,matrix_valued,Opt>::invoke() + "_s";}};
|
||||||
|
|
||||||
template <typename Variable, typename Target, typename Opt> struct h5_ops {
|
template <typename Variable, typename Target, typename Opt> struct h5_ops {
|
||||||
template<typename DataType, typename GF> static void write(h5::group g, std::string const & s, DataType const & data, GF const &) { h5_write(g,"data",data); }
|
template<typename DataType, typename GF> static void write(h5::group g, std::string const & s, DataType const & data, GF const &) { h5_write(g,"data",data); }
|
||||||
template<typename DataType, typename GF> static void read (h5::group g, std::string const & s, DataType & data, GF const &) { h5_read(g,"data",data);}
|
template<typename DataType, typename GF> static void read (h5::group g, std::string const & s, DataType & data, GF const &) { h5_read(g,"data",data);}
|
||||||
@ -248,7 +250,7 @@ namespace triqs { namespace gfs {
|
|||||||
|
|
||||||
//----------------------------- HDF5 -----------------------------
|
//----------------------------- HDF5 -----------------------------
|
||||||
|
|
||||||
friend std::string get_triqs_hdf5_data_scheme(gf_impl const & g) { return gfs_implementation::h5_name<Variable,Target,Opt>::invoke();}
|
friend std::string get_triqs_hdf5_data_scheme(gf_impl const & g) { return "Gf" + gfs_implementation::h5_name<Variable,Target,Opt>::invoke();}
|
||||||
|
|
||||||
/// Write into HDF5
|
/// Write into HDF5
|
||||||
friend void h5_write (h5::group fg, std::string subgroup_name, gf_impl const & g) {
|
friend void h5_write (h5::group fg, std::string subgroup_name, gf_impl const & g) {
|
||||||
@ -407,7 +409,15 @@ namespace triqs { namespace gfs {
|
|||||||
static_assert(std::is_same<Target,matrix_valued>::value, "slice_target only for matrix_valued GF's");
|
static_assert(std::is_same<Target,matrix_valued>::value, "slice_target only for matrix_valued GF's");
|
||||||
using arrays::range;
|
using arrays::range;
|
||||||
auto sg=slice_target (g.singularity(),range(args,args+1)...);
|
auto sg=slice_target (g.singularity(),range(args,args+1)...);
|
||||||
return gf_view<Variable,scalar_valued,Opt>(g.mesh(), g.data()(range(), args... ), sg , g.symmetry());
|
return gf_view<Variable,scalar_valued,Opt>(g.mesh(), g.data()(range(), args... ), sg, g.symmetry());
|
||||||
|
}
|
||||||
|
|
||||||
|
// a scalar_valued gf can be viewed as a 1x1 matrix
|
||||||
|
template<typename Variable, typename Opt, bool V, typename... Args>
|
||||||
|
gf_view<Variable,matrix_valued,Opt> reinterpret_scalar_valued_gf_as_matrix_valued (gf_impl<Variable,scalar_valued,Opt,V> const & g) {
|
||||||
|
typedef arrays::array_view<typename gfs_implementation::data_proxy<Variable,matrix_valued,Opt>::storage_t::value_type,3> a_t;
|
||||||
|
auto a = a_t {typename a_t::indexmap_type (arrays::mini_vector<size_t,3>(g.data().shape()[0],1,1)), g.data().storage()};
|
||||||
|
return gf_view<Variable,matrix_valued,Opt>(g.mesh(), a, g.singularity(), g.symmetry());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,8 +47,7 @@ namespace triqs { namespace gfs {
|
|||||||
template<typename Opt> struct singularity<imfreq,scalar_valued,Opt> { typedef local::tail type;};
|
template<typename Opt> struct singularity<imfreq,scalar_valued,Opt> { typedef local::tail type;};
|
||||||
|
|
||||||
//h5 name
|
//h5 name
|
||||||
template<typename Opt> struct h5_name<imfreq,matrix_valued,Opt> { static std::string invoke(){ return "GfImFreq";}};
|
template<typename Opt> struct h5_name<imfreq,matrix_valued,Opt> { static std::string invoke(){ return "ImFreq";}};
|
||||||
template<typename Opt> struct h5_name<imfreq,scalar_valued,Opt> { static std::string invoke(){ return "GfImFreq_s";}};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
/// --------------------------- evaluator ---------------------------------
|
||||||
template<typename Opt, typename Target>
|
template<typename Opt, typename Target>
|
||||||
|
@ -46,8 +46,7 @@ namespace triqs { namespace gfs {
|
|||||||
template<typename Opt> struct singularity<imtime,scalar_valued,Opt> { typedef local::tail type;};
|
template<typename Opt> struct singularity<imtime,scalar_valued,Opt> { typedef local::tail type;};
|
||||||
|
|
||||||
// h5 name
|
// h5 name
|
||||||
template<typename Opt> struct h5_name<imtime,matrix_valued,Opt> { static std::string invoke(){ return "GfImTime";}};
|
template<typename Opt> struct h5_name<imtime,matrix_valued,Opt> { static std::string invoke(){ return "ImTime";}};
|
||||||
template<typename Opt> struct h5_name<imtime,scalar_valued,Opt> { static std::string invoke(){ return "GfImTime_s";}};
|
|
||||||
|
|
||||||
/// --------------------------- data access ---------------------------------
|
/// --------------------------- data access ---------------------------------
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace triqs { namespace gfs {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// h5 name
|
// h5 name
|
||||||
template<typename Opt> struct h5_name<legendre,matrix_valued,Opt> { static std::string invoke(){ return "GfLegendre";}};
|
template<typename Opt> struct h5_name<legendre,matrix_valued,Opt> { static std::string invoke(){ return "Legendre";}};
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
/// --------------------------- evaluator ---------------------------------
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ namespace triqs { namespace gfs {
|
|||||||
void assign_from_expression (gf_impl<Variable,Target,Opt,V> const &, RHS) {}
|
void assign_from_expression (gf_impl<Variable,Target,Opt,V> const &, RHS) {}
|
||||||
|
|
||||||
//slices
|
//slices
|
||||||
gf_view<retime,scalar_valued> slice_mesh_imtime (gf_view<re_im_time,scalar_valued> g, size_t index) {
|
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
|
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() };
|
return { std::get<0>(g.mesh().components()), arr(arrays::range(), index), local::tail(1,1), nothing() };
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ namespace triqs { namespace gfs {
|
|||||||
template<typename Opt> struct singularity<refreq,scalar_valued,Opt> { typedef local::tail type;};
|
template<typename Opt> struct singularity<refreq,scalar_valued,Opt> { typedef local::tail type;};
|
||||||
|
|
||||||
// h5 name
|
// h5 name
|
||||||
template<typename Opt> struct h5_name<refreq,matrix_valued,Opt> { static std::string invoke(){ return "GfReFreq";}};
|
template<typename Opt> struct h5_name<refreq,matrix_valued,Opt> { static std::string invoke(){ return "ReFreq";}};
|
||||||
template<typename Opt> struct h5_name<refreq,scalar_valued,Opt> { static std::string invoke(){ return "GfReFreq_s";}};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
/// --------------------------- evaluator ---------------------------------
|
||||||
template<typename Opt, typename Target>
|
template<typename Opt, typename Target>
|
||||||
|
@ -96,7 +96,7 @@ namespace triqs { namespace gfs {
|
|||||||
} // gfs_implementation
|
} // gfs_implementation
|
||||||
|
|
||||||
//slices
|
//slices
|
||||||
gf_view<refreq,scalar_valued> slice_mesh_imtime (gf_view<refreq_imtime,scalar_valued> g, size_t index) {
|
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
|
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() };
|
return { std::get<0>(g.mesh().components()), arr(arrays::range(),index), local::tail(1,1), nothing() };
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,7 @@ namespace triqs { namespace gfs {
|
|||||||
template<typename Opt> struct singularity<retime,scalar_valued,Opt> { typedef local::tail type;};
|
template<typename Opt> struct singularity<retime,scalar_valued,Opt> { typedef local::tail type;};
|
||||||
|
|
||||||
// h5 name
|
// h5 name
|
||||||
template<typename Opt> struct h5_name<retime,matrix_valued,Opt> { static std::string invoke(){ return "GfReTime";}};
|
template<typename Opt> struct h5_name<retime,matrix_valued,Opt> { static std::string invoke(){ return "ReTime";}};
|
||||||
template<typename Opt> struct h5_name<retime,scalar_valued,Opt> { static std::string invoke(){ return "GfReTime_s";}};
|
|
||||||
|
|
||||||
/// --------------------------- evaluator ---------------------------------
|
/// --------------------------- evaluator ---------------------------------
|
||||||
template<typename Opt, typename Target>
|
template<typename Opt, typename Target>
|
||||||
|
Loading…
Reference in New Issue
Block a user