32 myParam{std::make_unique<PWParameterSet>(
comm)},
41 bool success = getH5(cur,
"href");
43 processChildren(cur, [&](
const std::string& cname,
const xmlNodePtr element) {
44 if (cname ==
"basisset")
48 myParam->Ecut = std::stod(a);
50 else if (cname ==
"coefficients")
55 success = getH5(element,
"hdata");
60 throw std::runtime_error(
"h5 cannot be open for creating PW basis!");
70 std::string spo_object_name;
72 aAttrib.
add(spin_group,
"spindataset");
73 aAttrib.
add(spo_object_name,
"name");
74 aAttrib.
add(spo_object_name,
"id");
76 return createPW(cur, spo_object_name, spin_group);
93 hfile.
read(idata,
"electrons/number_of_kpoints");
95 hfile.
read(idata,
"electrons/number_of_spins");
96 hfile.
read(idata,
"electrons/kpoint_0/spin_0/number_of_states");
99 app_log() <<
"Number of bands = " << nbands << std::endl;
106 if (nbands < nup || nbands < ndown)
108 app_error() <<
"Not enough bands in h5 file" << std::endl;
111 std::string tname =
myParam->getTwistAngleName();
113 hfile.
read(TwistAngle_DP,
"/electrons/kpoint_0/reduced_k");
125 app_log() <<
" num_twist = " << nkpts << std::endl;
127 app_log() <<
" num_bands = " << nbands << std::endl;
128 app_log() <<
" input maximum_ecut = " << ecut << std::endl;
129 app_log() <<
" current maximum_ecut = " << real_ecut << std::endl;
130 app_log() <<
" num_planewaves = " << nh5gvecs << std::endl;
137 std::vector<int> occBand(nb);
138 for (
int i = 0; i < nb; i++)
142 bool transform2grid =
false;
146 std::string cname((
const char*)(cur->name));
147 if (cname ==
"transform")
150 transform2grid =
true;
152 else if (cname ==
"occupation")
154 std::string occMode(
"ground");
157 aAttrib.
add(occMode,
"mode");
158 aAttrib.
add(bandoffset,
"offset");
160 if (occMode ==
"excited")
162 std::vector<int> occ;
163 std::vector<int> deleted, added;
165 for (
int i = 0; i < occ.size(); i++)
168 deleted.push_back(-occ[i]);
170 added.push_back(occ[i]);
172 if (deleted.size() != added.size())
174 app_error() <<
" Numbers of deleted and added bands are not identical." << std::endl;
177 for (
int i = 0; i < deleted.size(); i++)
179 occBand[deleted[i] - bandoffset] = added[i] - bandoffset;
181 app_log() <<
" mode=\"excited\" Occupied states: " << std::endl;
182 copy(occBand.begin(), occBand.end(), std::ostream_iterator<int>(
app_log(),
" "));
188 std::string tname =
"kpoint_0";
192 auto psi = std::make_unique<SPOSetType>(objname);
197 for (
int i = 0; i < nb; i++)
205 using TempVecType = std::vector<std::complex<RealType>>;
206 using TempVecType_DP = std::vector<std::complex<double>>;
207 TempVecType_DP coefs_DP(
myBasisSet->inputmap.size());
211 std::string bname(
myParam->getBandName(occBand[ib], spinIndex));
212 app_log() <<
" Reading " << tname <<
"/" << bname << std::endl;
215 TempVecType coefs(coefs_DP.begin(), coefs_DP.end());
216 psi->addVector(coefs, ib);
225 using ComplexTempVecType = std::vector<std::complex<RealType>>;
226 using ComplexTempVecType_DP = std::vector<std::complex<double>>;
227 ComplexTempVecType_DP complex_coefs_DP(
myBasisSet->inputmap.size());
231 std::string bname(
myParam->getBandName(occBand[ib], spinIndex));
232 app_log() <<
" Reading " << tname <<
"/" << bname << std::endl;
235 ComplexTempVecType complex_coefs(complex_coefs_DP.begin(), complex_coefs_DP.end());
236 psi->addVector(complex_coefs, ib);
243 #if defined(QMC_COMPLEX) 246 app_warning() <<
" Going to transform on grid " << std::endl;
247 transform2GridData(nG, spinIndex, *psi);
253 #if defined(QMC_COMPLEX) 256 std::ostringstream splineTag;
257 splineTag <<
"eigenstates_" << nG[0] <<
"_" << nG[1] <<
"_" << nG[2];
258 herr_t status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
259 std::string splineTagStr = splineTag.str();
260 app_log() <<
" splineTag " << splineTagStr << std::endl;
270 std::string tname =
myParam->getTwistName();
280 #if defined(VERYTINYMEMORY) 282 StorageType inData(nG[0], nG[1], nG[2]);
284 while (ib < myParam->numBands)
286 std::string bname(
myParam->getBandName(ib));
290 bname =
myParam->getSpinName(spinIndex);
293 for (
int ig = 0; ig < nG[0]; ig++)
296 for (
int jg = 0; jg < nG[1]; jg++)
299 for (
int kg = 0;
kg < nG[2];
kg++)
305 app_log() <<
" Add spline data " << ib <<
" h5path=" << tname <<
"/eigvector" << std::endl;
314 UPtrVector<StorageType> inData;
316 for (
int ib = 0; ib < nb; ib++)
317 inData.push_back(std::make_unique<StorageType>(nG[0], nG[1], nG[2]));
322 for (
int ig = 0; ig < nG[0]; ig++)
325 for (
int jg = 0; jg < nG[1]; jg++)
328 for (
int kg = 0;
kg < nG[2];
kg++)
334 for (
int ib = 0; ib < nb; ib++)
335 (*inData[ib])(ig, jg,
kg) = phase * phi[ib];
339 for (
int ib = 0; ib < nb; ib++)
341 std::string bname(
myParam->getBandName(ib));
345 bname =
myParam->getSpinName(spinIndex);
348 app_log() <<
" Add spline data " << ib <<
" h5path=" << tname <<
"/eigvector" << std::endl;
366 bool success =
hfile.
open(a, H5F_ACC_RDONLY | H5P_DEFAULT);
369 app_error() <<
" Cannot open " << a <<
" file." << std::endl;
std::ostream & app_warning()
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
QTBase::RealType RealType
ValueType evaluate(int ib, const PosType &pos)
size_t getTotalNum() const
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
bool put(xmlNodePtr cur)
assign attributes to the set
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
std::ostream & app_error()
int first(int igroup) const
return the first index of a group i
bool getH5(xmlNodePtr cur, const char *aname)
Communicate * Controller
Global Communicator for a process.
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
hdf_archive hfile
hdf5 handler to clean up
QMCTraits::PosType PosType
Wrapping information on parallelism.
const auto & getSimulationCell() const
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
Specialized paritlce class for atomistic simulations.
base class for the real SPOSet builder
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
PWOrbitalSetBuilder(const ParticleSet &p, Communicate *comm, xmlNodePtr cur)
constructor
QTBase::ValueType ValueType
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
create an sposet from xml and save the resulting SPOSet
class to handle a set of attributes of an xmlNode
OrbitalSetTraits< ValueType >::ValueVector ValueVector
~PWOrbitalSetBuilder() override
std::unique_ptr< PWParameterSet > myParam
parameter set
int last(int igroup) const
return the last index of a group i
xmlNodePtr rootNode
xml node for determinantset
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
void push(const std::string &gname, bool createit=true)
push a group to the group stack
void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
QMCTraits::RealType RealType
std::unique_ptr< SPOSet > createPW(xmlNodePtr cur, const std::string &objname, int spinIndex)
void processChildren(const xmlNodePtr cur, const F &functor)
process through all the children of an XML element F is a lambda or functor void F/[](const std::stri...
bool is_group(const std::string &aname)
check if aname is a group
const auto & getLattice() const
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Declaration of a builder class for PWOrbitalSet.
A D-dimensional Array class based on PETE.
const ParticleSet & targetPtcl
target particle set
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
bool createPWBasis()
The read routine - get data from XML and H5.
TinyVector< IndexType, 3 > GIndex_t
std::unique_ptr< PWBasis > myBasisSet
PosType TwistAngle
input twist angle