Exemplo n.º 1
0
 void h5_read ( h5::group F, std::string const & subgroup_name, parameters & p){
  auto gr = F.open_group(subgroup_name);
  std::vector<std::string> ds_name = F.get_all_dataset_names(subgroup_name), grp_name = F.get_all_subgroup_names(subgroup_name);
  for (auto & x : grp_name) {
   //std::cerr  << " loading group : "<< x <<std::endl;
   auto x_grp = gr.open_group(x);
   auto triqs_data_scheme = x_grp.read_triqs_hdf5_data_scheme(); 
   if (triqs_data_scheme != "") { 
    auto type_hash = _object::h5_scheme_to_code[triqs_data_scheme];
    auto it = _object::code_to_h5_read_fnts.find(type_hash);
    if (it == _object::code_to_h5_read_fnts.end()) TRIQS_RUNTIME_ERROR << "TRIQS_HDF5_data_scheme : ["<< triqs_data_scheme << "] is unknown. Did you register your object ?";
    p[x] = it->second(gr,x);
   }
   else { 
    parameters p2;
    h5_read (gr,x,p2);
    p[x] = p2;
   }
  }
  for (auto & x : ds_name) {
   //std::cerr  << " loading : "<< x <<std::endl;
   try {
    _object obj;
    h5_read(gr,x,obj);
    p[x] = obj;
   }
   catch(H5::Exception const & e) { TRIQS_RUNTIME_ERROR<< "Cannot load "<< x<<"\n H5 error is : \n   "<< e.getCDetailMsg();}
  }
 }
Exemplo n.º 2
0
      /**
   @param fg Parent HDF5 group to read the space from
   @param name Name of the HDF5 subgroup to be read
   @param hs Reference to a target Hilbert subspace object
 */
      friend void h5_read(h5::group fg, std::string const &name, sub_hilbert_space &hs) {
        using h5::h5_read;
        auto gr = fg.open_group(name);
        h5_read(gr, "index", hs.index);
        h5_read(gr, "fock_states", hs.fock_states);
        hs.fock_to_index.clear();
        for (auto f : hs.fock_states) hs.fock_to_index.insert(std::make_pair(f, static_cast<int>(hs.fock_to_index.size())));
      }
Exemplo n.º 3
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh& m) {
  h5::group gr = fg.open_group(subgroup_name);
  auto bz = h5::h5_read<brillouin_zone>(gr, "domain");
  auto dims = h5::h5_read<int>(gr, "n_pts");
  m = gf_mesh(bz, dims);
  //auto dims = h5::h5_read<std::vector<int>>(gr, "dims");
  //m = gf_mesh(bz, {dims[0], dims[1], dims[2]}); // NOT CORRECT IN GENERAL
 }
Exemplo n.º 4
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, matsubara_domain &d) {
  h5::group gr = fg.open_group(subgroup_name);
  double beta;
  std::string statistic;
  h5_read(gr, "beta", beta);
  h5_read(gr, "statistic", statistic);
  d = matsubara_domain(beta, (statistic == "F" ? Fermion : Boson));
 }
Exemplo n.º 5
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, matsubara_freq_mesh &m) {
     h5::group gr = fg.open_group(subgroup_name);
     typename matsubara_freq_mesh::domain_t dom;
     int L;
     bool s = true;
     h5_read(gr, "domain", dom);
     h5_read(gr, "size", L);
     if (gr.has_key("start_at_0")) h5_read(gr, "start_at_0", s);
     m = matsubara_freq_mesh{std::move(dom), L, s};
 }
Exemplo n.º 6
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, linear_mesh &m) {
  h5::group gr = fg.open_group(subgroup_name);
  typename linear_mesh::domain_t dom;
  double a, b;
  long L;
  h5_read(gr, "domain", dom);
  h5_read(gr, "min", a);
  h5_read(gr, "max", b);
  h5_read(gr, "size", L);
  m = linear_mesh(std::move(dom), a, b, L);
 }
Exemplo n.º 7
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh &m) {
  h5::group gr = fg.open_group(subgroup_name);
  typename gf_mesh::domain_t dom;
  long L;
  int s = 1;
  h5_read(gr, "domain", dom);
  h5_read(gr, "size", L);
  // backward compatibility : older file do not have this flags, default is true. 
  if (gr.has_key("positive_freq_only")) h5_read(gr, "positive_freq_only", s);
  if (gr.has_key("start_at_0")) h5_read(gr, "start_at_0", s);
  m = gf_mesh{std::move(dom), L, (s==1)};
 }
Exemplo n.º 8
0
 /// HDF5 interface
 friend void h5_read (h5::group g, std::string const & name, mc_generic & mc){
  auto gr = g.open_group(name);
  h5_read(gr,"moves", mc.AllMoves);
  h5_read(gr,"measures", mc.AllMeasures);
  h5_read(gr,"length_monte_carlo_cycle", mc.Length_MC_Cycle);
  h5_read(gr,"number_cycle_requested", mc.NCycles);
  h5_read(gr,"number_warming_cycle_requested", mc.NWarmIterations);
  h5_read(gr,"number_cycle_done", mc.NC);
  h5_read(gr,"number_measure_done", mc.nmeasures);
  h5_read(gr,"sign", mc.sign);
  h5_read(gr,"sum_sign", mc.sum_sign);
 }
Exemplo n.º 9
0
 std::c14::enable_if_t<is_amv_value_or_view_class<ArrayType>::value && !has_scalar_or_string_value_type<ArrayType>::value>
 h5_read(h5::group gr, std::string name, ArrayType& a) {
  static_assert(!std::is_const<ArrayType>::value, "Cannot read in const object");
  auto gr2 = gr.open_group(name);
  // TODO checking scheme...
  // load the shape
  auto sha2 = a.shape();
  array<int, 1> sha;
  h5_read(gr2, "shape", sha);
  if (first_dim(sha) != sha2.size())
   TRIQS_RUNTIME_ERROR << " array<array<...>> load : rank mismatch. Expected " << sha2.size()<< " Got " << first_dim(sha);
  for (int u = 0; u < sha2.size(); ++u) sha2[u] = sha(u);
  if (a.shape() != sha2) a.resize(sha2);
#ifndef __cpp_generic_lambdas
  foreach(a, h5_impl::_load_lambda<ArrayType>{a, gr2});
#else
  foreach(a, [&](auto... is) { h5_read(gr2, h5_impl::_h5_name(is...), a(is...)); });
#endif
 }
Exemplo n.º 10
0
 friend void h5_read (h5::group g, std::string const & name, measure_set & ms) {
     auto gr = g.open_group(name);
     for (auto & p : ms.m_map) h5_read(gr,p.first, p.second);
 }
Exemplo n.º 11
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh &m) {
  h5::group gr = fg.open_group(subgroup_name);
  auto l = [gr](int N, auto &m) { h5_read(gr, "MeshComponent" + std::to_string(N), m); };
  triqs::tuple::for_each_enumerate(m.components(), l);
 }
 /// Read from HDF5
 void h5_read(h5::group fg, std::string subgroup_name, brillouin_zone& bz) {
  h5::group gr = fg.open_group(subgroup_name);
  bravais_lattice bl;
  h5_read(gr, "bravais_lattice", bl);
  bz = brillouin_zone{bl};
 }
 /// Read from HDF5
 void h5_read(h5::group fg, std::string subgroup_name, bravais_lattice& bl) {
  h5::group gr = fg.open_group(subgroup_name);
  matrix<double> u;
  h5_read(gr, "units", u);
  bl = bravais_lattice{u}; // NOT COMPLETE
 }
Exemplo n.º 14
0
      /**
   @param fg Parent HDF5 group to read the space from
   @param name Name of the HDF5 subgroup to be read
   @param hs Reference to a target Hilbert space object
 */
      friend void h5_read(h5::group fg, std::string const &name, hilbert_space &hs) {
        auto gr = fg.open_group(name);
        h5_read(gr, "dim", hs.dim);
      }
Exemplo n.º 15
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, discrete_mesh &m) {
  h5::group gr = fg.open_group(subgroup_name);
  typename discrete_mesh::domain_t dom;
  h5_read(gr, "domain", dom);
  m = discrete_mesh(std::move(dom));
 }
Exemplo n.º 16
0
 friend void h5_read(h5::group fg, std::string subgroup_name, tail_impl &t) {
  auto gr = fg.open_group(subgroup_name);
  h5_read(gr, "omin", t.omin);
  h5_read(gr, "mask", t._mask);
  h5_read(gr, "data", t._data);
 }
Exemplo n.º 17
0
 /// Read from HDF5
 friend void h5_read(h5::group fg, std::string subgroup_name, gf_mesh& m) {
  h5::group gr = fg.open_group(subgroup_name);
  auto dims = h5::h5_read<std::vector<int>>(gr, "dims");
  m = gf_mesh(dims[0], dims[1], dims[2]);
 }