QMCPACK
PWOrbitalSet.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: Jeongnim Kim, jeongnim.kim@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 // Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #include "Message/Communicate.h"
17 #include "PWOrbitalSet.h"
19 
20 namespace qmcplusplus
21 {
23 {
24  if (OwnBasisSet && myBasisSet)
25  delete myBasisSet;
26  if (!IsCloned && C != nullptr)
27  delete C;
28 }
29 
30 std::unique_ptr<SPOSet> PWOrbitalSet::makeClone() const
31 {
32  auto myclone = std::make_unique<PWOrbitalSet>(*this);
33  myclone->myBasisSet = new PWBasis(*myBasisSet);
34  myclone->IsCloned = true;
35  return myclone;
36 }
37 
39 
40 void PWOrbitalSet::resize(PWBasisPtr bset, int nbands, bool cleanup)
41 {
42  myBasisSet = bset;
43  OrbitalSetSize = nbands;
44  OwnBasisSet = cleanup;
48  app_log() << " PWOrbitalSet::resize OrbitalSetSize =" << OrbitalSetSize << " BasisSetSize = " << BasisSetSize
49  << std::endl;
50 }
51 
52 void PWOrbitalSet::addVector(const std::vector<ComplexType>& coefs, int jorb)
53 {
54  int ng = myBasisSet->inputmap.size();
55  if (ng != coefs.size())
56  {
57  app_error() << " Input G map does not match the basis size of wave functions " << std::endl;
59  }
60  //drop G points for the given TwistAngle
61  const std::vector<int>& inputmap(myBasisSet->inputmap);
62  for (int ig = 0; ig < ng; ig++)
63  {
64  if (inputmap[ig] > -1)
65  (*C)[jorb][inputmap[ig]] = coefs[ig];
66  }
67 }
68 
69 void PWOrbitalSet::addVector(const std::vector<RealType>& coefs, int jorb)
70 {
71  int ng = myBasisSet->inputmap.size();
72  if (ng != coefs.size())
73  {
74  app_error() << " Input G map does not match the basis size of wave functions " << std::endl;
76  }
77  //drop G points for the given TwistAngle
78  const std::vector<int>& inputmap(myBasisSet->inputmap);
79  for (int ig = 0; ig < ng; ig++)
80  {
81  if (inputmap[ig] > -1)
82  (*C)[jorb][inputmap[ig]] = coefs[ig];
83  }
84 }
85 
87 {
88  //Evaluate every orbital for particle iat.
89  //Evaluate the basis-set at these coordinates:
90  //myBasisSet->evaluate(P,iat);
91  myBasisSet->evaluate(P.activeR(iat));
93 }
94 
95 void PWOrbitalSet::evaluateVGL(const ParticleSet& P, int iat, ValueVector& psi, GradVector& dpsi, ValueVector& d2psi)
96 {
97  //Evaluate the orbitals and derivatives for particle iat only.
98  myBasisSet->evaluateAll(P, iat);
100  const ValueType* restrict tptr = Temp.data();
101  for (int j = 0; j < OrbitalSetSize; j++, tptr += PW_MAXINDEX)
102  {
103  psi[j] = tptr[PW_VALUE];
104  d2psi[j] = tptr[PW_LAP];
105  dpsi[j] = GradType(tptr[PW_GRADX], tptr[PW_GRADY], tptr[PW_GRADZ]);
106  }
107 }
108 
110  int first,
111  int last,
112  ValueMatrix& logdet,
113  GradMatrix& dlogdet,
114  ValueMatrix& d2logdet)
115 {
116  for (int iat = first, i = 0; iat < last; iat++, i++)
117  {
118  myBasisSet->evaluateAll(P, iat);
120  const ValueType* restrict tptr = Temp.data();
121  for (int j = 0; j < OrbitalSetSize; j++, tptr += PW_MAXINDEX)
122  {
123  logdet(i, j) = tptr[PW_VALUE];
124  d2logdet(i, j) = tptr[PW_LAP];
125  dlogdet(i, j) = GradType(tptr[PW_GRADX], tptr[PW_GRADY], tptr[PW_GRADZ]);
126  }
127  }
128 }
129 } // namespace qmcplusplus
void evaluateAll(const ParticleSet &P, int iat)
Definition: PWBasis.h:291
void resize(PWBasisPtr bset, int nbands, bool cleanup=false)
resize the orbital base
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::GradType GradType
Definition: Configuration.h:62
void evaluate(const PosType &pos)
Definition: PWBasis.h:284
IndexType BasisSetSize
number of basis
Definition: PWOrbitalSet.h:101
Matrix< ValueType > Temp
temporary array to perform gemm operation
Definition: PWOrbitalSet.h:112
void addVector(const std::vector< ComplexType > &coefs, int jorb)
Builder class takes care of the assertion.
Definition of member functions of Plane-wave basis set.
std::unique_ptr< SPOSet > makeClone() const override
make a clone of itself every derived class must implement this to have threading working correctly...
std::ostream & app_log()
Definition: OutputManager.h:65
void evaluate_notranspose(const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, ValueMatrix &d2logdet) override
evaluate the values, gradients and laplacians of this single-particle orbital for [first...
std::ostream & app_error()
Definition: OutputManager.h:67
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Definition: SPOSet.h:50
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi) override
evaluate the values, gradients and laplacians of this single-particle orbital set ...
ValueMatrix * C
pointer to matrix containing the coefficients
Definition: PWOrbitalSet.h:106
PWBasisPtr myBasisSet
My basis set.
Definition: PWOrbitalSet.h:99
Vector< ComplexType > Zv
Definition: PWBasis.h:89
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Definition: SPOSet.h:52
~PWOrbitalSet() override
delete BasisSet only it owns this
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
Matrix< ComplexType > Z
Definition: PWBasis.h:87
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
IndexType OrbitalSetSize
number of Single-particle orbitals
Definition: SPOSet.h:566
const PosType & activeR(int iat) const
return the active position if the particle is active or the return current position if not ...
Definition: ParticleSet.h:265
void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
void abort() const
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111
OrbitalSetTraits< ValueType >::GradVector GradVector
Definition: SPOSet.h:51
bool IsCloned
if true, do not clean up
Definition: PWOrbitalSet.h:108
LatticeGaussianProduct::ValueType ValueType
Plane-wave basis set.
Definition: PWBasis.h:40
void setOrbitalSetSize(int norbs) override
set the OrbitalSetSize
std::vector< int > inputmap
Definition: PWBasis.h:108