35 #include <string_view> 55 bool matrixNotSet =
true;
56 for (
int i = 0; i < 3; i++)
57 for (
int j = 0; j < 3; j++)
58 matrixNotSet = matrixNotSet && (
TileMatrix(i, j) == 0);
61 for (
int i = 0; i < 3; i++)
62 for (
int j = 0; j < 3; j++)
66 std::array<char, 1000> buff;
68 std::snprintf(buff.data(), buff.size(),
" TileMatrix = \n [ %2d %2d %2d\n %2d %2d %2d\n %2d %2d %2d ]\n",
69 TileMatrix(0, 0),
TileMatrix(0, 1),
TileMatrix(0, 2),
TileMatrix(1, 0),
TileMatrix(1, 1),
72 throw std::runtime_error(
"Error converting TileMatrix to a string");
73 app_log() << std::string_view(buff.data(), length);
77 "EinsplineSetBuilder::createSPOSet You must specify the number of orbitals in the input file.");
79 app_log() <<
" Reading " << numOrbs <<
" orbitals from HDF5 file.\n";
88 throw std::runtime_error(
"EinsplineSetBuilder::set_metadata Error reading orbital info from HDF5 file.");
89 app_log() <<
"TIMER EinsplineSetBuilder::ReadOrbitalInfo " << orb_info_timer.
elapsed() << std::endl;
94 app_log() <<
"TIMER EinsplineSetBuilder::BroadcastOrbitalInfo " << orb_info_timer.
elapsed() << std::endl;
112 bool skipChecks =
false;
116 std::string sourceName;
117 std::string spo_prec(
"double");
118 std::string truncate(
"no");
119 std::string hybrid_rep(
"no");
120 std::string skip_checks(
"no");
121 std::string use_einspline_set_extended(
124 std::string GPUsharing =
"no";
133 a.
add(sortBands,
"sort");
135 a.
add(twist_num_inp,
"twistnum");
136 a.
add(twist_inp,
"twist");
137 a.
add(sourceName,
"source");
139 a.
add(hybrid_rep,
"hybridrep");
141 a.
add(GPUsharing,
"gpusharing");
142 a.
add(spo_prec,
"precision");
143 a.
add(truncate,
"truncate");
145 a.
add(skip_checks,
"skip_checks");
148 a.
add(numOrbs,
"size");
149 a.
add(numOrbs,
"norbs");
150 a.
add(spinSet,
"spindataset");
151 a.
add(spinSet,
"group");
158 if (skip_checks ==
"yes")
170 const std::vector<int> last_occ(
Occ);
176 oAttrib.
add(spinSet,
"spindataset");
180 xmlNodePtr spo_cur = cur;
184 std::string cname((
const char*)(cur->name));
185 if (cname ==
"occupation")
187 std::string occ_mode(
"ground");
191 oAttrib.
add(occ_mode,
"mode");
192 oAttrib.
add(spinSet,
"spindataset");
196 if (occ_mode ==
"excited")
198 else if (occ_mode !=
"ground")
200 "currently supported in EinsplineSetBuilder.");
210 #if defined(MIXED_PRECISION) 211 app_log() <<
"\t MIXED_PRECISION=1 Overwriting the einspline storage to single precision.\n";
216 if ((iter !=
SPOSetMap.end()) && (!NewOcc))
217 app_warning() <<
"!!!!!!! Identical SPOSets are detected by EinsplineSetBuilder! " 218 "Implicit sharing one SPOSet for spin-up and spin-down electrons has been removed. " 219 "Each determinant creates its own SPOSet with dedicated memory for spline coefficients. " 220 "To avoid increasing the memory footprint of spline coefficients, " 221 "create a single SPOset outside the determinantset using 'sposet_collection' " 222 "and reference it by name on the determinant line." 226 FullBands[spinSet] = std::make_unique<std::vector<BandInfo>>();
230 if (
SPOSetMap.size() == 0 && spinSet != 0)
235 set_metadata(numOrbs, twist_num_inp, twist_inp, skipChecks);
242 OccupyBands(spinSet, sortBands, numOrbs, skipChecks);
246 bool use_single = (spo_prec ==
"single" || spo_prec ==
"float");
249 if (truncate ==
"yes")
251 "The 'truncate' feature of spline SPO has been removed. Please use hybrid orbital representation.");
253 #if !defined(QMC_COMPLEX) 274 app_log() <<
"Time spent in creating B-spline SPOs " << mytimer.
elapsed() <<
" sec" << std::endl;
275 OrbitalSet->finalizeConstruction();
288 a.
add(spinSet,
"spindataset");
289 a.
add(spinSet,
"group");
296 auto bspline_zd =
MixedSplineReader->create_spline_set(spinSet, cur, input_info);
void set(const Tensor< TT, D > &lat)
set the lattice vector from the command-line options
a class that defines a supercell in D-dimensional Euclean space.
std::unique_ptr< SPOSet > createSPOSet(xmlNodePtr cur, SPOSetInputInfo &input_info) override
initialize with the existing SPOSet
const PSetMap & ParticleSets
reference to the particleset pool
Tensor< double, OHMMS_DIM > GGt
Tensor< int, OHMMS_DIM > TileMatrix
std::ostream & app_warning()
helper functions for EinsplineSetBuilder
class to read state range information from sposet input
int rank() const
return the rank
std::map< H5OrbSet, SPOSet *, H5OrbSet > SPOSetMap
bool put(xmlNodePtr cur)
assign attributes to the set
std::string myName
name of the object
Builder class for einspline-based SPOSet objects.
ParticleSet * SourcePtcl
ionic system
Tensor_t G
Reciprocal unit vectors. G(j,i) i=vector and j=x,y,z.
void AnalyzeTwists2(const int twist_num_inp, const TinyVector< double, OHMMS_DIM > &twist_inp)
analyze twists of orbitals in h5 and determinine twist_num_
std::vector< std::unique_ptr< std::vector< BandInfo > > > FullBands
Helper vector for sorting bands.
static constexpr double TWIST_NO_INPUT
twist_inp[i] <= -9999 to indicate no given input after parsing XML
void bcastSortBands(int splin, int N, bool root)
broadcast SortBands
base class to read data and manage spline tables
void BroadcastOrbitalInfo()
Communicate * myComm
pointer to Communicate
std::unique_ptr< BsplineReader > createBsplineReal(EinsplineSetBuilder *e, bool use_single, bool hybrid_rep, const std::string &useGPU)
create a reader which handles real splines, R2R case spline storage and computation precision is doub...
class to handle a set of attributes of an xmlNode
bool ReadOrbitalInfo(bool skipChecks=false)
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
std::unique_ptr< BsplineReader > createBsplineComplex(EinsplineSetBuilder *e, bool hybrid_rep, const std::string &useGPU)
create a reader which handles complex (double size real) splines, C2R or C2C case spline storage and ...
BsplineSet is a SPOSet derived class and serves as a base class for B-spline SPO C2C/C2R/R2R implemen...
AntiSymTensor< T, D > transpose(const AntiSymTensor< T, D > &rhs)
void OccupyBands(int spin, int sortBands, int numOrbs, bool skipChecks=false)
std::unique_ptr< BsplineReader > MixedSplineReader
reader to use BsplineReader
construct a name for spline SPO set
static constexpr int TWISTNUM_NO_INPUT
twistnum_inp == -9999 to indicate no given input after parsing XML
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
void set_metadata(int numOrbs, int twist_num_inp, const TinyVector< double, OHMMS_DIM > &twist_inp, bool skipChecks=false)
a specific but clean code path in createSPOSetFromXML, for PBC, double, ESHDF
xmlNodePtr XMLRoot
root XML node with href, sort, tilematrix, twistnum, source, precision,truncate,version ...
std::filesystem::path H5FileName
Tensor< double, OHMMS_DIM > SuperLattice
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void barrier_and_abort(const std::string &msg) const
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
initialize the Antisymmetric wave function for electrons
bool get(std::ostream &os) const override
dummy. For satisfying OhmmsElementBase.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
bool use_real_splines_
if false, splines are conceptually complex valued
const std::vector< std::string > candidate_values