QMCPACK
LatticeGaussianProductBuilder.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
17 #include "OhmmsData/AttributeSet.h"
18 
19 namespace qmcplusplus
20 {
22  : WaveFunctionComponentBuilder(comm, p), ptclPool(psets)
23 {}
24 
25 std::unique_ptr<WaveFunctionComponent> LatticeGaussianProductBuilder::buildComponent(xmlNodePtr cur)
26 {
28  // initialize widths to zero; if no user input, then abort
30  OhmmsAttributeSet oAttrib;
31  oAttrib.add(sourceOpt, "source");
32  oAttrib.add(nameOpt, "name");
33  oAttrib.add(widthOpt, "width");
34  oAttrib.put(cur);
35  if (nameOpt == "")
36  {
37  app_warning() << " LatticeGaussianProductBuilder::put does not have name " << std::endl;
38  }
39 
40  auto pa_it(ptclPool.find(sourceOpt));
41  if (pa_it == ptclPool.end())
42  {
43  app_error() << "Could not find source ParticleSet " << sourceOpt << " for ion wave function.\n";
44  }
45  auto& sourcePtcl = *pa_it->second;
46  auto orb = std::make_unique<LatticeGaussianProduct>(sourcePtcl, targetPtcl);
47  orb->ParticleAlpha.resize(targetPtcl.getTotalNum());
48  orb->ParticleCenter.resize(targetPtcl.getTotalNum());
49  int num_nonzero = 0;
50  for (int iat = 0; iat < p.getTotalNum(); iat++)
51  {
52  RealType w = widthOpt[iat];
53  if (w > 0.0)
54  {
55  orb->ParticleCenter[iat] = num_nonzero++;
56  orb->ParticleAlpha[iat] = 0.5 / (w * w);
57  }
58  else
59  {
60  orb->ParticleCenter[iat] = -1;
61  orb->ParticleAlpha[iat] = 0.0;
62  }
63  }
64  if (num_nonzero != sourcePtcl.getTotalNum())
65  {
66  app_error() << " The number of nonzero widths should be the same as the number of\n"
67  << " centers for the ionwf.\n";
68  abort();
69  }
70  assert(num_nonzero == sourcePtcl.getTotalNum());
71  return orb;
72 }
73 
74 } // namespace qmcplusplus
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::ostream & app_warning()
Definition: OutputManager.h:69
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
An abstract class for wave function builders.
size_t getTotalNum() const
Definition: ParticleSet.h:493
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::ostream & app_error()
Definition: OutputManager.h:67
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
ParticleSet & targetPtcl
reference to the particle set on which targetPsi is defined
Wrapping information on parallelism.
Definition: Communicate.h:68
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
const PSetMap & ptclPool
particleset pool to get ParticleSet other than the target
LatticeGaussianProductBuilder(Communicate *comm, ParticleSet &p, const PSetMap &psets)
Simple gaussian functions used for orbitals for ions.
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42