QMCPACK
PWBasis Class Reference

Plane-wave basis set. More...

+ Inheritance diagram for PWBasis:
+ Collaboration diagram for PWBasis:

Public Types

enum  {
  PW_VALUE, PW_LAP, PW_GRADX, PW_GRADY,
  PW_GRADZ, PW_MAXINDEX
}
 
using ParticleLayout = ParticleSet::ParticleLayout
 
using GIndex_t = TinyVector< IndexType, 3 >
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 PWBasis ()
 default constructor More...
 
 PWBasis (const PosType &twistangle)
 constructor More...
 
 ~PWBasis ()
 
void setTwistAngle (const PosType &tang)
 set the twist angle More...
 
void reset ()
 reset More...
 
int readbasis (hdf_archive &h5basisgroup, RealType ecutoff, const ParticleLayout &lat, const std::string &pwname="planewaves", const std::string &pwmultname="multipliers", bool resizeContainer=true)
 Read basisset from hdf5 file. More...
 
void trimforecut ()
 Remove basis elements if kinetic energy > ecut. More...
 
void evaluate (const PosType &pos)
 
void evaluateAll (const ParticleSet &P, int iat)
 

Public Attributes

Matrix< ComplexTypeZ
 
Vector< ComplexTypeZv
 
Vector< RealTypephi
 
std::vector< int > inputmap
 
int NumPlaneWaves
 total number of basis functions More...
 
ParticleLayout Lattice
 local copy of Lattice More...
 

Private Attributes

int maxmaxg
 max of maxg[i] More...
 
GIndex_t maxg
 
RealType ecut
 
PosType twist
 twist angle in reduced More...
 
PosType twist_cart
 twist angle in cartesian More...
 
std::vector< GIndex_tgvecs
 gvecs in reduced coordiates More...
 
std::vector< GIndex_tgvecs_shifted
 Reduced coordinates with offset gvecs_shifted[][idim]=gvecs[][idim]+maxg[idim]. More...
 
std::vector< RealTypeminusModKplusG2
 
std::vector< PosTypekplusgvecs_cart
 
Matrix< ComplexTypeC
 
std::vector< int > negative
 

Detailed Description

Plane-wave basis set.

Rewrite of PlaneWaveBasis to utilize blas II or III Support more general input tags

Definition at line 40 of file PWBasis.h.

Member Typedef Documentation

◆ GIndex_t

Definition at line 44 of file PWBasis.h.

◆ ParticleLayout

Definition at line 43 of file PWBasis.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
PW_VALUE 
PW_LAP 
PW_GRADX 
PW_GRADY 
PW_GRADZ 
PW_MAXINDEX 

Definition at line 77 of file PWBasis.h.

Constructor & Destructor Documentation

◆ PWBasis() [1/2]

PWBasis ( )
inline

default constructor

Definition at line 117 of file PWBasis.h.

117 : maxmaxg(0), NumPlaneWaves(0) {}
int maxmaxg
max of maxg[i]
Definition: PWBasis.h:48
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111

◆ PWBasis() [2/2]

PWBasis ( const PosType twistangle)
inline

constructor

Definition at line 120 of file PWBasis.h.

120 : maxmaxg(0), twist(twistangle), NumPlaneWaves(0) {}
int maxmaxg
max of maxg[i]
Definition: PWBasis.h:48
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111
PosType twist
twist angle in reduced
Definition: PWBasis.h:54

◆ ~PWBasis()

~PWBasis ( )
inline

Definition at line 122 of file PWBasis.h.

122 {}

Member Function Documentation

◆ evaluate()

void evaluate ( const PosType pos)
inline

Definition at line 284 of file PWBasis.h.

References Vector< T, Alloc >::data(), qmcplusplus::dot(), eval_e2iphi(), PWBasis::kplusgvecs_cart, PWBasis::NumPlaneWaves, PWBasis::phi, and PWBasis::Zv.

Referenced by PWOrbitalSet::evaluate(), PWRealOrbitalSet::evaluate(), PWBasis::evaluateAll(), PWOrbitalSet::evaluateValue(), and PWRealOrbitalSet::evaluateValue().

285  {
286  //Evaluate the planewaves for particle iat.
287  for (int ig = 0; ig < NumPlaneWaves; ig++)
288  phi[ig] = dot(kplusgvecs_cart[ig], pos);
290  }
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< PosType > kplusgvecs_cart
Definition: PWBasis.h:64
Vector< ComplexType > Zv
Definition: PWBasis.h:89
Vector< RealType > phi
Definition: PWBasis.h:106
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61

◆ evaluateAll()

void evaluateAll ( const ParticleSet P,
int  iat 
)
inline

Definition at line 291 of file PWBasis.h.

References ParticleSet::activeR(), Matrix< T, Alloc >::data(), PWBasis::evaluate(), PWBasis::kplusgvecs_cart, PWBasis::minusModKplusG2, PWBasis::NumPlaneWaves, PWBasis::Z, and PWBasis::Zv.

Referenced by PWOrbitalSet::evaluate_notranspose(), PWRealOrbitalSet::evaluate_notranspose(), PWOrbitalSet::evaluateVGL(), and PWRealOrbitalSet::evaluateVGL().

292  {
293  const PosType& r(P.activeR(iat));
294  evaluate(r);
295  ComplexType* restrict zptr = Z.data();
296  for (int ig = 0; ig < NumPlaneWaves; ig++, zptr += 5)
297  {
298  //PW is initialized as exp(i*twist.r) so that the final basis evaluations
299  //are for (twist+G).r
300  ComplexType& pw = Zv[ig];
301  zptr[0] = pw;
302  zptr[1] = minusModKplusG2[ig] * pw;
303  zptr[2] = kplusgvecs_cart[ig][0] * ComplexType(-pw.imag(), pw.real());
304  zptr[3] = kplusgvecs_cart[ig][1] * ComplexType(-pw.imag(), pw.real());
305  zptr[4] = kplusgvecs_cart[ig][2] * ComplexType(-pw.imag(), pw.real());
306  }
307  }
void evaluate(const PosType &pos)
Definition: PWBasis.h:284
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
std::vector< PosType > kplusgvecs_cart
Definition: PWBasis.h:64
std::vector< RealType > minusModKplusG2
Definition: PWBasis.h:63
Vector< ComplexType > Zv
Definition: PWBasis.h:89
QMCTraits::PosType PosType
Matrix< ComplexType > Z
Definition: PWBasis.h:87
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111

◆ readbasis()

int readbasis ( hdf_archive h5basisgroup,
RealType  ecutoff,
const ParticleLayout lat,
const std::string &  pwname = "planewaves",
const std::string &  pwmultname = "multipliers",
bool  resizeContainer = true 
)

Read basisset from hdf5 file.

Apply ecut.

Parameters
h5basisgrouph5 node where basis is located
ecutoffcutoff energy
latCrystalLattice
resizeContainerif true, resize internal storage.
Returns
the number of plane waves

make a local copy

Definition at line 23 of file PWBasis.cpp.

References qmcplusplus::app_log(), PWBasis::ecut, PWBasis::gvecs, CrystalLattice< T, D >::k_cart(), PWBasis::kplusgvecs_cart, PWBasis::NumPlaneWaves, hdf_archive::read(), and PWBasis::reset().

29 {
30  ///make a local copy
31  Lattice = lat;
32  ecut = ecutoff;
33  app_log() << " PWBasis::" << pwmultname << " is found " << std::endl;
34  h5basisgroup.read(gvecs, "/electrons/kpoint_0/gvectors");
35  NumPlaneWaves = std::max(gvecs.size(), kplusgvecs_cart.size());
36  if (NumPlaneWaves == 0)
37  throw std::runtime_error(" PWBasis::readbasis Basis is missing.");
38 
39  if (kplusgvecs_cart.empty())
40  {
42  for (int i = 0; i < NumPlaneWaves; i++)
44  }
45  //app_log() << " Gx Gy Gz " << std::endl;
46  //for(int i=0; i<kplusgvecs_cart.size(); i++)
47  //{
48  // app_log() << kplusgvecs_cart[i] << std::endl;
49  //}
50  //Now remove elements outside Ecut. At the same time, fill k+G and |k+G| lists.
51  //Also keep track of the original index ordering (using indexmap[]) so that
52  //orbital coefficients can be ordered and trimmed for ecut in the same way.
53  //support older parser
54  if (resizeContainer)
55  reset();
56  //std::copy(gvecs.begin(),gvecs.end(),std::ostream_iterator<GIndex_t>(std::cout,"\n"));
57  return NumPlaneWaves;
58 }
std::vector< GIndex_t > gvecs
gvecs in reduced coordiates
Definition: PWBasis.h:59
ParticleLayout Lattice
local copy of Lattice
Definition: PWBasis.h:114
void reset()
reset
Definition: PWBasis.cpp:70
std::vector< PosType > kplusgvecs_cart
Definition: PWBasis.h:64
std::ostream & app_log()
Definition: OutputManager.h:65
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111
SingleParticlePos k_cart(const SingleParticlePos &kin) const
conversion of a reciprocal-vector

◆ reset()

void reset ( )

reset

Definition at line 70 of file PWBasis.cpp.

References QMCTraits::DIM, PWBasis::NumPlaneWaves, PWBasis::phi, Matrix< T, Alloc >::resize(), Vector< T, Alloc >::resize(), PWBasis::trimforecut(), PWBasis::Z, and PWBasis::Zv.

Referenced by PWBasis::readbasis(), and PWBasis::setTwistAngle().

71 {
72  trimforecut();
73  //logC.resize(3,2*maxmaxg+1);
74  Z.resize(NumPlaneWaves, 2 + DIM);
77 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
Vector< ComplexType > Zv
Definition: PWBasis.h:89
void trimforecut()
Remove basis elements if kinetic energy > ecut.
Definition: PWBasis.cpp:83
Vector< RealType > phi
Definition: PWBasis.h:106
Matrix< ComplexType > Z
Definition: PWBasis.h:87
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111

◆ setTwistAngle()

void setTwistAngle ( const PosType tang)

set the twist angle

Definition at line 60 of file PWBasis.cpp.

References qmcplusplus::dot(), PWBasis::maxmaxg, PWBasis::reset(), and PWBasis::twist.

61 {
62  PosType dang = twist - tang;
63  bool sameTwist = dot(dang, dang) < std::numeric_limits<RealType>::epsilon();
64  if (maxmaxg && sameTwist)
65  return;
66  twist = tang;
67  reset();
68 }
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void reset()
reset
Definition: PWBasis.cpp:70
QMCTraits::PosType PosType
int maxmaxg
max of maxg[i]
Definition: PWBasis.h:48
PosType twist
twist angle in reduced
Definition: PWBasis.h:54

◆ trimforecut()

void trimforecut ( )

Remove basis elements if kinetic energy > ecut.

Keep and indexmap so we know how to match coefficients on read.

Definition at line 83 of file PWBasis.cpp.

References qmcplusplus::abs(), qmcplusplus::app_log(), PWBasis::C, qmcplusplus::dot(), PWBasis::gvecs, PWBasis::gvecs_shifted, PWBasis::inputmap, CrystalLattice< T, D >::k_cart(), PWBasis::kplusgvecs_cart, PWBasis::maxg, PWBasis::maxmaxg, PWBasis::minusModKplusG2, PWBasis::NumPlaneWaves, OHMMS_DIM, Matrix< T, Alloc >::resize(), PWBasis::twist, and PWBasis::twist_cart.

Referenced by PWBasis::reset().

84 {
85  //Convert the twist angle to Cartesian coordinates.
87  inputmap.resize(NumPlaneWaves);
88  app_log() << " PWBasis::TwistAngle (unit) =" << twist << std::endl;
89  app_log() << " PWBasis::TwistAngle (cart) =" << twist_cart << std::endl;
90  app_log() << " PWBasis::trimforecut NumPlaneWaves (before) =" << NumPlaneWaves << std::endl;
91  std::vector<GIndex_t> gvecCopy(gvecs);
92  std::vector<PosType> gcartCopy(kplusgvecs_cart);
93  gvecs.clear();
94  kplusgvecs_cart.clear();
96  // RealType kcutoff2 = 2.0*ecut; //std::sqrt(2.0*ecut);
97  int ngIn = NumPlaneWaves;
98  for (int ig = 0, newig = 0; ig < ngIn; ig++)
99  {
100  //PosType tempvec = Lattice.k_cart(gvecCopy[ig]+twist);
101  PosType tempvec = gcartCopy[ig] + twist_cart;
102  RealType mod2 = dot(tempvec, tempvec);
103 
104  // Keep all the g-vectors
105  // The cutoff energy is not stored in the HDF file now.
106  // Is truncating the gvectors to a spherical shell necessary?
107  if (true)
108  {
109  gvecs.push_back(gvecCopy[ig]);
110  kplusgvecs_cart.push_back(tempvec);
111  minusModKplusG2.push_back(-mod2);
112  //Remember which position in the HDF5 file this came from...for coefficients
113  inputmap[ig] = newig++;
114  }
115 #if 0
116  if(mod2<=kcutoff2)
117  {
118  gvecs.push_back(gvecCopy[ig]);
119  kplusgvecs_cart.push_back(tempvec);
120  minusModKplusG2.push_back(-mod2);
121  //Remember which position in the HDF5 file this came from...for coefficients
122  inputmap[ig] = newig++;
123  }
124  else
125  {
126  inputmap[ig] = -1; //Temporary value...need to know final NumPlaneWaves.
127  NumPlaneWaves--;
128  }
129 #endif
130  }
131 #if defined(PWBASIS_USE_RECURSIVE)
132  //Store the maximum number of translations, within ecut, of any reciprocal cell vector.
133  for (int ig = 0; ig < NumPlaneWaves; ig++)
134  for (int i = 0; i < OHMMS_DIM; i++)
135  if (std::abs(gvecs[ig][i]) > maxg[i])
136  maxg[i] = std::abs(gvecs[ig][i]);
138  for (int ig = 0; ig < NumPlaneWaves; ig++)
139  gvecs_shifted[ig] = gvecs[ig] + maxg;
140  maxmaxg = std::max(maxg[0], std::max(maxg[1], maxg[2]));
141  //changes the order???? ok
142  C.resize(3, 2 * maxmaxg + 2);
143 #else
144  maxmaxg = 1;
145 #endif
146  // //make a copy of input to gvecCopy
147  //// for(int ig=0, newig=0; ig<ngIn; ig++) {
148  // //Check size of this g-vector
149  // PosType tempvec = Lattice.k_cart(gvecCopy[ig]+twist);
150  // RealType mod2 = dot(tempvec,tempvec);
151  // if(mod2<=kcutoff2){ //Keep this element
152  // gvecs.push_back(gvecCopy[ig]);
153  // kplusgvecs_cart.push_back(tempvec);
154  // minusModKplusG2.push_back(-mod2);
155  // //Remember which position in the HDF5 file this came from...for coefficients
156  // inputmap[ig] = newig++;
157  ////#if !defined(QMC_COMPLEX)
158  //// //Build the negative vector. See comment at declaration (above) for details.
159  //// if(gvecCopy[ig][0] < 0)
160  //// negative.push_back(0);
161  //// else if(gvecCopy[ig][0] > 0)
162  //// negative.push_back(1);
163  //// else { //gx == 0, test gy
164  //// if(gvecCopy[ig][1] < 0)
165  //// negative.push_back(0);
166  //// else if(gvecCopy[ig][1] > 0)
167  //// negative.push_back(1);
168  //// else { //gx == gy == 0; test gz. If gz==0 also, take negative=1 (arbitrary)
169  //// if(gvecCopy[ig][2] < 0)
170  //// negative.push_back(0);
171  //// else
172  //// negative.push_back(1);
173  //// }
174  //// }
175  ////#endif
176  // } else {
177  // inputmap[ig] = -1; //Temporary value...need to know final NumPlaneWaves.
178  // NumPlaneWaves--;
179  // }
180  // }
181  //Finalize the basis. Fix temporary values of inputmap.
182  //for(int ig=0; ig<inputmap.size(); ig++)
183  // if(inputmap[ig] == -1)
184  // inputmap[ig] = NumPlaneWaves; //For dumping coefficients of PWs>ecut
185  app_log() << " NumPlaneWaves (after) =" << NumPlaneWaves << std::endl;
186 }
std::vector< GIndex_t > gvecs
gvecs in reduced coordiates
Definition: PWBasis.h:59
ParticleLayout Lattice
local copy of Lattice
Definition: PWBasis.h:114
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< int > inputmap
Definition: PWBasis.h:108
std::vector< PosType > kplusgvecs_cart
Definition: PWBasis.h:64
std::vector< RealType > minusModKplusG2
Definition: PWBasis.h:63
Matrix< ComplexType > C
Definition: PWBasis.h:66
QMCTraits::PosType PosType
int maxmaxg
max of maxg[i]
Definition: PWBasis.h:48
std::vector< GIndex_t > gvecs_shifted
Reduced coordinates with offset gvecs_shifted[][idim]=gvecs[][idim]+maxg[idim].
Definition: PWBasis.h:61
PosType twist_cart
twist angle in cartesian
Definition: PWBasis.h:56
#define OHMMS_DIM
Definition: config.h:64
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
std::ostream & app_log()
Definition: OutputManager.h:65
int NumPlaneWaves
total number of basis functions
Definition: PWBasis.h:111
SingleParticlePos k_cart(const SingleParticlePos &kin) const
conversion of a reciprocal-vector
PosType twist
twist angle in reduced
Definition: PWBasis.h:54
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType

Member Data Documentation

◆ C

Matrix<ComplexType> C
private

Definition at line 66 of file PWBasis.h.

Referenced by PWBasis::trimforecut().

◆ ecut

RealType ecut
private

Definition at line 52 of file PWBasis.h.

Referenced by PWBasis::readbasis().

◆ gvecs

std::vector<GIndex_t> gvecs
private

gvecs in reduced coordiates

Definition at line 59 of file PWBasis.h.

Referenced by PWBasis::readbasis(), and PWBasis::trimforecut().

◆ gvecs_shifted

std::vector<GIndex_t> gvecs_shifted
private

Reduced coordinates with offset gvecs_shifted[][idim]=gvecs[][idim]+maxg[idim].

Definition at line 61 of file PWBasis.h.

Referenced by PWBasis::trimforecut().

◆ inputmap

std::vector<int> inputmap

◆ kplusgvecs_cart

std::vector<PosType> kplusgvecs_cart
private

◆ Lattice

local copy of Lattice

Definition at line 114 of file PWBasis.h.

◆ maxg

GIndex_t maxg
private

Definition at line 50 of file PWBasis.h.

Referenced by PWBasis::trimforecut().

◆ maxmaxg

int maxmaxg
private

max of maxg[i]

Definition at line 48 of file PWBasis.h.

Referenced by PWBasis::setTwistAngle(), and PWBasis::trimforecut().

◆ minusModKplusG2

std::vector<RealType> minusModKplusG2
private

Definition at line 63 of file PWBasis.h.

Referenced by PWBasis::evaluateAll(), and PWBasis::trimforecut().

◆ negative

std::vector<int> negative
private

Definition at line 73 of file PWBasis.h.

◆ NumPlaneWaves

int NumPlaneWaves

◆ phi

Definition at line 106 of file PWBasis.h.

Referenced by PWBasis::evaluate(), and PWBasis::reset().

◆ twist

PosType twist
private

twist angle in reduced

Definition at line 54 of file PWBasis.h.

Referenced by PWBasis::setTwistAngle(), and PWBasis::trimforecut().

◆ twist_cart

PosType twist_cart
private

twist angle in cartesian

Definition at line 56 of file PWBasis.h.

Referenced by PWBasis::trimforecut().

◆ Z

◆ Zv


The documentation for this class was generated from the following files: