src/QMCWaveFunctions/lcao/LCAOrbitalBuilder.cpp
/** read data from a hdf5 file
   * @param norb number of orbitals to be initialized
   * @param coeff_ptr xmlnode for coefficients
   */
read data from a hdf5 file
@param norb number of orbitals to be initialized
@param coeff_ptr xmlnode for coefficients
read data from a hdf5 file @param norb number of orbitals to be initialized @param coeff_ptr xmlnode for coefficients
bool LCAOrbitalBuilder::putPBCFromH5(LCAOrbitalSet& spo, xmlNodePtr coeff_ptr)
{
#if defined(HAVE_LIBHDF5)
  ReportEngine PRE("LCAOrbitalBuilder", "LCAOrbitalBuilder::putPBCFromH5");
  int norbs      = spo.getOrbitalSetSize();
  int neigs      = spo.getBasisSetSize();
  int setVal     = -1;
  bool IsComplex = false;
  PosType SuperTwist(0.0);
  PosType SuperTwistH5(0.0);
  OhmmsAttributeSet aAttrib;
  aAttrib.add(setVal, "spindataset");
  aAttrib.add(neigs, "size");
  aAttrib.add(neigs, "orbitals");
  aAttrib.put(coeff_ptr);
  spo.setIdentity(false);
  hdf_archive hin(myComm);
  xmlNodePtr curtemp = coeff_ptr->parent->parent->parent;
  aAttrib.add(SuperTwist, "twist");
  aAttrib.put(curtemp);
  if (myComm->rank() == 0)
  {
    if (!hin.open(h5_path, H5F_ACC_RDONLY))
      APP_ABORT("LCAOrbitalBuilder::putFromH5 missing or incorrect path to H5 file.");
    hin.push("parameters");
    hin.read(IsComplex, "IsComplex");
    hin.pop();
    std::string setname("/Super_Twist/Coord");
    hin.read(SuperTwistH5, setname);
    if (std::abs(SuperTwistH5[0] - SuperTwist[0]) >= 1e-6 || std::abs(SuperTwistH5[1] - SuperTwist[1]) >= 1e-6 ||
        std::abs(SuperTwistH5[2] - SuperTwist[2]) >= 1e-6)
    {
      app_log() << "Super Twist in XML : " << SuperTwist[0] << "    In H5:" << SuperTwistH5[0] << std::endl;
      app_log() << "                     " << SuperTwist[1] << "          " << SuperTwistH5[1] << std::endl;
      app_log() << "                     " << SuperTwist[2] << "          " << SuperTwistH5[2] << std::endl;
      app_log() << "Diff in Coord     x :" << std::abs(SuperTwistH5[0] - SuperTwist[0]) << std::endl;
      app_log() << "                  y :" << std::abs(SuperTwistH5[1] - SuperTwist[1]) << std::endl;
      app_log() << "                  z :" << std::abs(SuperTwistH5[2] - SuperTwist[2]) << std::endl;
      APP_ABORT("Requested Super Twist in XML and Super Twist in HDF5 do not Match!!! Aborting.");
    }
    Matrix<ValueType> Ctemp(neigs, spo.getBasisSetSize());
    LoadFullCoefsFromH5(hin, setVal, SuperTwist, Ctemp);
    int n = 0, i = 0;
    while (i < norbs)
    {
      if (Occ[n] > 0.0)
      {
        std::copy(Ctemp[n], Ctemp[n + 1], (*spo.C)[i]);
        i++;
      }
      n++;
    }
    hin.close();
  }
#ifdef HAVE_MPI
  myComm->comm.broadcast_n(spo.C->data(), spo.C->size());
#endif
#else
  APP_ABORT("LCAOrbitalBuilder::putFromH5 HDF5 is disabled.")
#endif
  return true;
}
bool LCAOrbitalBuilder :: putPBCFromH5 ( LCAOrbitalSet & spo , xmlNodePtr coeff_ptr ) { #if defined ( HAVE_LIBHDF5 ) ReportEngine PRE ( " " , " " ) ; int norbs = spo . getOrbitalSetSize ( ) ; int neigs = spo . getBasisSetSize ( ) ; int setVal = -1 ; bool IsComplex = false ; PosType SuperTwist ( 0.0 ) ; PosType SuperTwistH5 ( 0.0 ) ; OhmmsAttributeSet aAttrib ; aAttrib . add ( setVal , " " ) ; aAttrib . add ( neigs , " " ) ; aAttrib . add ( neigs , " " ) ; aAttrib . put ( coeff_ptr ) ; spo . setIdentity ( false ) ; hdf_archive hin ( myComm ) ; xmlNodePtr curtemp = coeff_ptr -> parent -> parent -> parent ; aAttrib . add ( SuperTwist , " " ) ; aAttrib . put ( curtemp ) ; if ( myComm -> rank ( ) == 0 ) { if ( ! hin . open ( h5_path , H5F_ACC_RDONLY ) ) APP_ABORT ( " " ) ; hin . push ( " " ) ; hin . read ( IsComplex , " " ) ; hin . pop ( ) ; std :: string setname ( " " ) ; hin . read ( SuperTwistH5 , setname ) ; if ( std :: abs ( SuperTwistH5 [ 0 ] - SuperTwist [ 0 ] ) >= 1e-6 || std :: abs ( SuperTwistH5 [ 1 ] - SuperTwist [ 1 ] ) >= 1e-6 || std :: abs ( SuperTwistH5 [ 2 ] - SuperTwist [ 2 ] ) >= 1e-6 ) { app_log ( ) << " " << SuperTwist [ 0 ] << " " << SuperTwistH5 [ 0 ] << std :: endl ; app_log ( ) << " " << SuperTwist [ 1 ] << " " << SuperTwistH5 [ 1 ] << std :: endl ; app_log ( ) << " " << SuperTwist [ 2 ] << " " << SuperTwistH5 [ 2 ] << std :: endl ; app_log ( ) << " " << std :: abs ( SuperTwistH5 [ 0 ] - SuperTwist [ 0 ] ) << std :: endl ; app_log ( ) << " " << std :: abs ( SuperTwistH5 [ 1 ] - SuperTwist [ 1 ] ) << std :: endl ; app_log ( ) << " " << std :: abs ( SuperTwistH5 [ 2 ] - SuperTwist [ 2 ] ) << std :: endl ; APP_ABORT ( " " ) ; } Matrix < ValueType > Ctemp ( neigs , spo . getBasisSetSize ( ) ) ; LoadFullCoefsFromH5 ( hin , setVal , SuperTwist , Ctemp ) ; int n = 0 , i = 0 ; while ( i < norbs ) { if ( Occ [ n ] > 0.0 ) { std :: copy ( Ctemp [ n ] , Ctemp [ n + 1 ] , ( * spo . C ) [ i ] ) ; i ++ ; } n ++ ; } hin . close ( ) ; } #ifdef HAVE_MPI myComm -> comm . broadcast_n ( spo . C -> data ( ) , spo . C -> size ( ) ) ; #endif #else APP_ABORT ( " " ) #endif return true ; }
read data from a hdf5 file
 @param norb number of orbitals to be initialized
 @param coeff_ptr xmlnode for coefficients
read data from a hdf5 file @param norb number of orbitals to be initialized @param coeff_ptr xmlnode for coefficients