43 #if !defined(REMOVE_TRACEMANAGER) 94 app_summary() <<
" Hamiltonian and observables" << std::endl;
95 app_summary() <<
" ---------------------------" << std::endl;
99 std::string htype(
"generic"), source(
"i"), defaultKE(
"yes");
101 hAttrib.
add(htype,
"type");
102 hAttrib.
add(source,
"source");
103 hAttrib.
add(defaultKE,
"default");
111 if (defaultKE !=
"no")
112 targetH->addOperator(std::make_unique<BareKineticEnergy>(
targetPtcl, *targetPsi),
"Kinetic");
117 processChildren(cur, [&](
const std::string& cname,
const xmlNodePtr element) {
122 processChildren(cur, [&](
const std::string& cname,
const xmlNodePtr element) {
123 std::string notype =
"0";
124 std::string noname =
"any";
125 std::string potType(notype);
126 std::string potName(noname);
127 std::string potUnit(
"hartree");
128 std::string estType(
"coulomb");
132 attrib.
add(sourceInp,
"source");
133 attrib.add(sourceInp,
"sources");
134 attrib.add(targetInp,
"target");
135 attrib.add(potType,
"type");
136 attrib.add(potName,
"name");
137 attrib.add(potUnit,
"units");
138 attrib.add(estType,
"potential");
143 int nham =
targetH->total_size();
144 if (cname ==
"pairpot")
146 if (potType ==
"coulomb")
148 else if (potType ==
"skpot")
150 std::unique_ptr<SkPot> hs = std::make_unique<SkPot>(
targetPtcl);
152 targetH->addOperator(std::move(hs),
"SkPot",
true);
155 else if (potType ==
"MPC" || potType ==
"mpc")
159 else if (cname ==
"constant")
162 if (potType ==
"coulomb")
165 else if (cname ==
"extpot")
167 if (potType ==
"harmonic_ext" || potType ==
"HarmonicExt")
169 std::unique_ptr<HarmonicExternalPotential> hs = std::make_unique<HarmonicExternalPotential>(
targetPtcl);
171 targetH->addOperator(std::move(hs),
"HarmonicExt",
true);
173 if (potType ==
"grid")
175 std::unique_ptr<GridExternalPotential> hs = std::make_unique<GridExternalPotential>(
targetPtcl);
177 targetH->addOperator(std::move(hs),
"Grid",
true);
180 else if (cname ==
"estimator")
182 if (potType ==
"flux")
183 targetH->addOperator(std::make_unique<ConservedEnergy>(), potName,
false);
184 else if (potType ==
"specieskinetic")
186 std::unique_ptr<SpeciesKineticEnergy> apot = std::make_unique<SpeciesKineticEnergy>(
targetPtcl);
188 targetH->addOperator(std::move(apot), potName,
false);
190 else if (potType ==
"latticedeviation")
196 APP_ABORT(
"Unknown target \"" + targetInp +
"\" for LatticeDeviation.");
200 auto spit(
ptclPool.find(sourceInp));
203 APP_ABORT(
"Unknown source \"" + sourceInp +
"\" for LatticeDeviation.");
208 std::string target_group, source_group;
209 local_attrib.
add(target_group,
"tgroup");
210 local_attrib.
add(source_group,
"sgroup");
211 local_attrib.
put(element);
213 std::unique_ptr<LatticeDeviationEstimator> apot =
214 std::make_unique<LatticeDeviationEstimator>(*pit->second, *spit->second, target_group, source_group);
216 targetH->addOperator(std::move(apot), potName,
false);
218 else if (potType ==
"Force")
220 else if (potType ==
"gofr")
222 std::unique_ptr<PairCorrEstimator> apot = std::make_unique<PairCorrEstimator>(
targetPtcl, sourceInp);
224 targetH->addOperator(std::move(apot), potName,
false);
226 else if (potType ==
"density")
228 std::unique_ptr<DensityEstimator> apot = std::make_unique<DensityEstimator>(
targetPtcl);
230 targetH->addOperator(std::move(apot), potName,
false);
232 else if (potType ==
"spindensity")
234 app_log() <<
" Adding SpinDensity" << std::endl;
235 std::unique_ptr<SpinDensity> apot = std::make_unique<SpinDensity>(
targetPtcl);
237 targetH->addOperator(std::move(apot), potName,
false);
239 else if (potType ==
"structurefactor")
241 app_log() <<
" Adding StaticStructureFactor" << std::endl;
242 std::unique_ptr<StaticStructureFactor> apot = std::make_unique<StaticStructureFactor>(
targetPtcl);
244 targetH->addOperator(std::move(apot), potName,
false);
246 else if (potType ==
"selfhealingoverlap" || potType ==
"SelfHealingOverlap")
248 app_log() <<
" Adding SelfHealingOverlap" << std::endl;
249 std::unique_ptr<SelfHealingOverlapLegacy> apot = std::make_unique<SelfHealingOverlapLegacy>(*targetPsi);
251 targetH->addOperator(std::move(apot), potName,
false);
253 else if (potType ==
"orbitalimages")
255 app_log() <<
" Adding OrbitalImages" << std::endl;
256 std::unique_ptr<OrbitalImages> apot =
259 targetH->addOperator(std::move(apot), potName,
false);
261 #if !defined(REMOVE_TRACEMANAGER) 262 else if (potType ==
"energydensity" || potType ==
"EnergyDensity")
264 app_log() <<
" Adding EnergyDensityEstimator" << std::endl;
265 std::unique_ptr<EnergyDensityEstimator> apot = std::make_unique<EnergyDensityEstimator>(
ptclPool, defaultKE);
267 targetH->addOperator(std::move(apot), potName,
false);
269 else if (potType ==
"dm1b")
271 app_log() <<
" Adding DensityMatrices1B" << std::endl;
272 std::string source =
"";
274 attrib.
add(source,
"source");
281 Pc = pit->second.
get();
284 APP_ABORT(
"Unknown source \"" + source +
"\" for DensityMatrices1B");
286 std::unique_ptr<DensityMatrices1B> apot = std::make_unique<DensityMatrices1B>(
targetPtcl, *targetPsi, Pc);
288 targetH->addOperator(std::move(apot), potName,
false);
291 else if (potType ==
"sk")
295 std::unique_ptr<SkEstimator> apot = std::make_unique<SkEstimator>(
targetPtcl);
297 targetH->addOperator(std::move(apot), potName,
false);
298 app_log() <<
"Adding S(k) estimator" << std::endl;
302 else if (potType ==
"chiesa")
304 std::string PsiName =
"psi0";
305 std::string SourceName =
"e";
307 hAttrib.
add(PsiName,
"psi");
308 hAttrib.
add(SourceName,
"source");
309 hAttrib.
put(element);
310 auto pit(
ptclPool.find(SourceName));
313 APP_ABORT(
"Unknown source \"" + SourceName +
"\" for Chiesa correction.");
316 auto psi_it(
psiPool.find(PsiName));
319 APP_ABORT(
"Unknown psi \"" + PsiName +
"\" for Chiesa correction.");
322 std::unique_ptr<ChiesaCorrection> chiesa = std::make_unique<ChiesaCorrection>(source, psi);
323 targetH->addOperator(std::move(chiesa),
"KEcorr",
false);
325 else if (potType ==
"skall")
327 std::string SourceName =
"";
329 attrib.
add(SourceName,
"source");
332 auto pit(
ptclPool.find(SourceName));
335 APP_ABORT(
"Unknown source \"" + SourceName +
"\" for SkAll.");
340 std::unique_ptr<SkAllEstimator> apot = std::make_unique<SkAllEstimator>(*pit->second,
targetPtcl);
342 targetH->addOperator(std::move(apot), potName,
false);
343 app_log() <<
"Adding S(k) ALL estimator" << std::endl;
348 else if (potType ==
"Pressure")
350 if (estType ==
"coulomb")
352 std::unique_ptr<Pressure> BP = std::make_unique<Pressure>(
targetPtcl);
354 targetH->addOperator(std::move(BP),
"Pressure",
false);
356 attrib.add(nlen,
"truncateSum");
362 else if (potType ==
"momentum")
364 app_log() <<
" Adding Momentum Estimator" << std::endl;
365 std::string PsiName =
"psi0";
367 hAttrib.
add(PsiName,
"wavefunction");
368 hAttrib.
put(element);
369 auto psi_it(
psiPool.find(PsiName));
372 APP_ABORT(
"Unknown psi \"" + PsiName +
"\" for momentum.");
374 std::unique_ptr<MomentumEstimator> ME = std::make_unique<MomentumEstimator>(
targetPtcl, *psi_it->second);
377 targetH->addOperator(std::move(ME),
"MomentumEstimator",
false);
381 if (nham < targetH->total_size())
383 if (potName == noname)
386 app_log() <<
"Provide name for hamiltonian element for type " << potType << std::endl;
389 targetH->addOperatorType(potName, potType);
396 bool dmc_correction =
false;
397 processChildren(cur, [&](
const std::string& cname,
const xmlNodePtr element) {
398 std::string potType(
"0");
400 attrib.
add(potType,
"type");
402 if (cname ==
"estimator" && potType ==
"ForwardWalking")
404 app_log() <<
" Adding Forward Walking Operator" << std::endl;
405 std::unique_ptr<ForwardWalking> FW = std::make_unique<ForwardWalking>();
407 targetH->addOperator(std::move(FW),
"ForwardWalking",
false);
408 dmc_correction =
true;
422 std::map<std::string, std::string>::iterator it(
RenamedProperty.find(aname));
425 aname = (*it).second;
431 bool success =
build(cur);
const std::string & getName() const
return the name
Base class for any object which needs to know about a MPI communicator.
helper functions for EinsplineSetBuilder
int rank() const
return the rank
std::ostream & app_summary()
bool put(xmlNodePtr cur)
assign attributes to the set
std::string myName
name of the object
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
int PBCType
type of the lattice. 0=non-periodic, 1=periodic
Collection of Local Energy Operators.
bool build(xmlNodePtr cur)
process xmlNode to populate targetPsi
HamiltonianFactory(const std::string &hName, ParticleSet &qp, const PSetMap &pset, const PsiPoolType &oset, Communicate *c)
constructor
const PsiPoolType & psiPool
reference to the TrialWaveFunction Pool
std::map< std::string, std::string > RenamedProperty
list of the old to new name
Wrapping information on parallelism.
Specialized paritlce class for atomistic simulations.
Communicate * myComm
pointer to Communicate
class to handle a set of attributes of an xmlNode
bool put(xmlNodePtr cur)
read from xmlNode
void addPseudoPotential(xmlNodePtr cur)
void addCoulombPotential(xmlNodePtr cur)
std::string ClassName
class Name
Declaration of a HamiltonianFactory.
const SPOMap & getSPOMap() const
spomap_ reference accessor
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Declarations of ForwardWalking.
std::map< std::string, const std::unique_ptr< TrialWaveFunction > > PsiPoolType
std::unique_ptr< QMCHamiltonian > targetH
many-body wavefunction object
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 renameProperty(const std::string &a, const std::string &b)
add a property whose name will be renamed by b
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...
const PSetMap & ptclPool
reference to the PSetMap
Class to represent a many-body trial wave function.
std::string psiName
name of the TrialWaveFunction
ParticleSet & targetPtcl
target ParticleSet
const auto & getLattice() const
void addMPCPotential(xmlNodePtr cur, bool physical=false)
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
void addForceHam(xmlNodePtr cur)
Declaration of QMCHamiltonian.