22 #if defined(QMC_COMPLEX) 42 auto bspline = std::make_unique<SA>(my_name);
43 app_log() <<
" ClassName = " <<
bspline->getClassName() << std::endl;
44 bool foundspline = createSplineDataSpaceLookforDumpFile(bandgroup, *
bspline);
49 const auto splinefile = getSplineDumpFileName(bandgroup);
50 h5f.
open(splinefile, H5F_ACC_RDONLY);
51 foundspline =
bspline->read_splines(h5f);
53 app_log() <<
" Successfully restored 3D B-spline coefficients from " << splinefile <<
". The reading time is " 54 << now.
elapsed() <<
" sec." << std::endl;
62 initialize_spline_pio_gather(spin, bandgroup, *
bspline);
63 app_log() <<
" SplineSetReader initialize_spline_pio " << now.
elapsed() <<
" sec" << std::endl;
65 if (saveSplineCoefs && myComm->rank() == 0)
68 const std::string splinefile(getSplineDumpFileName(bandgroup));
71 std::string classname =
bspline->getClassName();
72 h5f.
write(classname,
"class_name");
73 int sizeD =
sizeof(
typename SA::DataType);
74 h5f.
write(sizeD,
"sizeof");
77 app_log() <<
" Stored spline coefficients in " << splinefile <<
" for potential reuse. The writing time is " 78 << now.
elapsed() <<
" sec." << std::endl;
85 app_log() <<
" Time to bcast the table = " << now.
elapsed() << std::endl;
95 app_log() <<
" Using complex einspline table" << std::endl;
97 app_log() <<
" Using real einspline table" << std::endl;
100 check_twists(
bspline, bandgroup);
104 typename SA::BCType xyz_bc[3];
105 bool havePsig = set_grid(
bspline.HalfG, xyz_grid, xyz_bc);
107 myComm->barrier_and_abort(
"SplineSetReader needs psi_g. Set precision=\"double\".");
108 bspline.create_spline(xyz_grid, xyz_bc);
112 if (myComm->rank() == 0)
116 foundspline = h5f.
open(getSplineDumpFileName(bandgroup), H5F_ACC_RDONLY);
119 std::string aname(
"none");
120 foundspline = h5f.
readEntry(aname,
"class_name");
121 foundspline = (aname.find(
bspline.getKeyword()) != std::string::npos);
126 foundspline = h5f.
readEntry(sizeD,
"sizeof");
127 foundspline = (sizeD ==
sizeof(
typename SA::DataType));
131 myComm->bcast(foundspline);
135 template<
typename SA>
138 Vector<std::complex<double>>& cG)
const 142 std::ostringstream msg;
143 msg <<
"SplineSetReader Failed to read band(s) from h5 file. " <<
"Attempted dataset " <<
s <<
" with " << cG.size()
144 <<
" complex numbers." << std::endl;
145 throw std::runtime_error(msg.str());
150 std::ostringstream msg;
151 msg <<
"SplineSetReader The orbital dataset " <<
s <<
" has a wrong norm " << total_norm
152 <<
", computed from plane wave coefficients!" << std::endl
153 <<
"This may indicate a problem with the HDF5 library versions used " 154 <<
"during wavefunction conversion or read." << std::endl;
155 throw std::runtime_error(msg.str());
159 template<
typename SA>
166 const int Nprocs = myComm->size();
167 const int Nbandgroups =
std::min(Nbands, Nprocs);
169 std::vector<int> band_groups(Nbandgroups + 1, 0);
171 int iorb_first = band_groups[band_group_comm.
getGroupID()];
172 int iorb_last = band_groups[band_group_comm.
getGroupID() + 1];
174 app_log() <<
"Start transforming plane waves to 3D B-Splines." << std::endl;
178 const std::vector<BandInfo>& cur_bands = bandgroup.
myBands;
181 h5f.open(mybuilder->H5FileName, H5F_ACC_RDONLY);
182 for (
int iorb = iorb_first; iorb < iorb_last; iorb++)
184 const auto& cur_band = cur_bands[
bspline.BandIndexMap[iorb]];
185 const int ti = cur_band.TwistIndex;
186 readOneOrbitalCoefs(psi_g_path(ti, spin, cur_band.BandIndex), h5f, cG);
187 oneband.fft_spline(cG, mybuilder->Gvecs[0], mybuilder->primcell_kpoints[ti], rotate);
188 bspline.set_spline(&oneband.get_spline_r(), &oneband.get_spline_i(), cur_band.TwistIndex, iorb, 0);
195 app_log() <<
" Time to gather the table = " << now.
elapsed() << std::endl;
200 #if defined(QMC_COMPLEX) 203 #if !defined(QMC_MIXED_PRECISION) 211 #if !defined(QMC_MIXED_PRECISION) double bspline(double x, const std::vector< double > &t, const std::vector< double > &c, int k)
void write(T &data, const std::string &aname)
write the data to the group aname and check status runtime error is issued on I/O error ...
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
helper functions for EinsplineSetBuilder
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
void close()
close all the open groups and file
void FairDivideLow(int ntot, int npart, IV &adist)
partition ntot elements among npart
T compute_norm(const Vector< std::complex< T >> &cG)
Compute the norm of an orbital.
int getNumDistinctOrbitals() const
return the size of this band
Wrapping information on parallelism.
Each SplineC2X needs a reader derived from BsplineReader.
int getGroupID() const
return the group id
General SplineSetReader to handle any unitcell.
A collection of functions for dividing fairly.
class to handle complex splines to real orbitals with splines of arbitrary precision ...
SplineSetReader(EinsplineSetBuilder *e)
bool isGroupLeader()
return true if the current MPI rank is the group lead
class to handle complex splines to real orbitals with splines of arbitrary precision splines storage ...
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
The most general reader class for the following classes using the full single grid for the supercell...
class to handle complex splines to complex orbitals with splines of arbitrary precision splines stora...
Communicate * getGroupLeaderComm()
#define PW_COEFF_NORM_TOLERANCE
bool readEntry(T &data, const std::string &aname)
read the data from the group aname and return status use read() for inbuilt error checking ...
class to handle complex splines to complex orbitals with splines of arbitrary precision ...
std::vector< BandInfo > myBands
Bands that belong to this group.