QMCPACK
LPQHIBasis.h
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 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #ifndef QMCPLUSPLUS_LPQHIBASIS_H
16 #define QMCPLUSPLUS_LPQHIBASIS_H
17 
18 #include "LongRange/LRBasis.h"
19 #include <complex>
20 
21 namespace qmcplusplus
22 {
23 /** @ingroup longrange
24  *\brief A derivative of LRBasis class to provide the functionality
25  * of the LPQHI basis. Based on code by Ken Esler from PIM.
26  */
27 
28 class LPQHIBasis : public LRBasis
29 {
30 private:
31  int NumKnots; //Number of knots for basis.
33  Matrix<mRealType> S; //Coefficients for LPQHI
34  Matrix<mRealType> S1; //First derivatives
35  Matrix<mRealType> S2; //Second derivatives
37  std::vector<mRealType> tvec; //Coefficients
38 
39  //Helper functions for computing FT of basis functions (used in c(n,k))
40  inline std::complex<mRealType> Eplus(int i, mRealType k, int n) const;
41  inline std::complex<mRealType> Eminus(int i, mRealType k, int n) const;
42  inline mRealType Dplus(int i, mRealType k, int n) const;
43  inline mRealType Dminus(int i, mRealType k, int n) const;
44 
45 public:
46  LPQHIBasis(const LPQHIBasis& b, const ParticleLayout& ref)
47  : LRBasis(ref),
48  NumKnots(b.NumKnots),
49  delta(b.delta),
50  deltainv(b.deltainv),
51  S(b.S),
52  S1(b.S1),
53  S2(b.S2),
54  tvec(b.tvec)
55  {
56  Mfactor[0] = 1.0;
57  Mfactor[1] = -1.0;
58  Mfactor[2] = 1.0;
59  BasisSize = b.BasisSize;
60  m_rc = b.m_rc;
61  }
62 
63  inline mRealType get_delta() const { return delta; }
64  //inline int NumBasisElem() const {return 3*NumKnots;}
65  void set_NumKnots(int n); // n >= 2 required
66  void set_rc(mRealType rc) override;
67 
68  inline mRealType h(int n, mRealType r) const override
69  {
70  int i = n / 3;
71  int alpha = n - 3 * i;
72  mRealType ra = delta * (i - 1);
73  mRealType rb = delta * i;
74  mRealType rc = delta * (i + 1);
75  rc = std::min(m_rc, rc);
76  const mRealType* restrict Sa(S[alpha]);
77  if (r < ra || r > rc)
78  return 0.0;
79  if (r <= rb)
80  {
81  mRealType x = (rb - r) * deltainv;
82  return Mfactor[alpha] * (Sa[0] + x * (Sa[1] + x * (Sa[2] + x * (Sa[3] + x * (Sa[4] + x * Sa[5])))));
83  }
84  else
85  {
86  mRealType x = (r - rb) * deltainv;
87  return Sa[0] + x * (Sa[1] + x * (Sa[2] + x * (Sa[3] + x * (Sa[4] + x * Sa[5]))));
88  }
89  }
90 
91  inline mRealType dh_dr(int n, mRealType r) const override
92  {
93  int i = n / 3;
94  int alpha = n - 3 * i;
95  mRealType ra = delta * (i - 1);
96  mRealType rb = delta * i;
97  mRealType rc = delta * (i + 1);
98  rc = std::min(m_rc, rc);
99  const mRealType* restrict Sa(S[alpha]);
100  if (r < ra || r > rc)
101  return 0.0;
102  if (r <= rb)
103  {
104  mRealType x = (rb - r) * deltainv;
105  return -deltainv * Mfactor[alpha] * (Sa[1] + x * (2 * Sa[2] + x * (3 * Sa[3] + x * (4 * Sa[4] + x * 5 * Sa[5]))));
106  }
107  else
108  {
109  mRealType x = (r - rb) * deltainv;
110  return deltainv * (Sa[1] + x * (2 * Sa[2] + x * (3 * Sa[3] + x * (4 * Sa[4] + x * 5 * Sa[5]))));
111  }
112  }
113  // inline TinyVector<mRealType,3> getTriplet(int n, mRealType r) const {
114  // using Return_t = TinyVector<mRealType,3>;
115  // int i=n/3;
116  // int alpha = n-3*i;
117  // mRealType ra = delta*(i-1);
118  // mRealType rb = delta*i;
119  // mRealType rc = delta*(i+1);
120  // rc = std::min(m_rc, rc);
121  // if(r<ra || r>rc) return Return_t;
122  // const mRealType* restrict Sa(S[alpha]);
123  // const mRealType* restrict S1a(S1[alpha]);
124  // const mRealType* restrict S2a(S2[alpha]);
125  // if (r <= rb) {
126  // mRealType x=(rb-r)*deltainv;
127  // return Return_t(
128  // Mfactor[alpha]*(Sa[0] +x*(Sa[1] +x*(Sa[2] +x*(Sa[3] +x*(Sa[4]+x*Sa[5]))))),
129  // Mfactor[alpha]*(S1a[0]+x*(S1a[1]+x*(S1a[2]+x*(S1a[3]+x*S1a[4])))),
130  // Mfactor[alpha]*(S2a[0]+x*(S2a[1]+x*(S2a[2]+x*S2a[3]))));
131  // } else {
132  // mRealType x=(r-rb)*deltainv;
133  // return Return_t(
134  // Sa[0] +x*(Sa[1] +x*(Sa[2] +x*(Sa[3] +x*(Sa[4]+x*Sa[5])))),
135  // S1a[0]+x*(S1a[1]+x*(S1a[2]+x*(S1a[3]+x*S1a[4]))),
136  // S2a[0]+x*(S2a[1]+x*(S2a[2]+x*S2a[3])));
137  // }
138  // }
139 
140  mRealType hintr2(int n) const override;
141  mRealType c(int n, mRealType k) const override;
142 
143  //Constructor...fill S matrix...call correct base-class constructor
144  LPQHIBasis(const ParticleLayout& ref) : LRBasis(ref), NumKnots(0), delta(0.0)
145  {
146  S.resize(3, 6);
147  S(0, 0) = 1.0;
148  S(0, 1) = 0.0;
149  S(0, 2) = 0.0;
150  S(0, 3) = -10.0;
151  S(0, 4) = 15.0;
152  S(0, 5) = -6.0;
153  S(1, 0) = 0.0;
154  S(1, 1) = 1.0;
155  S(1, 2) = 0.0;
156  S(1, 3) = -6.0;
157  S(1, 4) = 8.0;
158  S(1, 5) = -3.0;
159  S(2, 0) = 0.0;
160  S(2, 1) = 0.0;
161  S(2, 2) = 0.5;
162  S(2, 3) = -1.5;
163  S(2, 4) = 1.5;
164  S(2, 5) = -0.5;
165  S1.resize(3, 5);
166  for (int i = 0; i < 5; i++)
167  {
168  for (int j = 0; j < 3; j++)
169  {
170  S1(j, i) = static_cast<double>(i + 1.0) * S(j, i + 1);
171  }
172  }
173  Mfactor[0] = 1.0;
174  Mfactor[1] = -1.0;
175  Mfactor[2] = 1.0;
176  }
177 };
178 
179 } // namespace qmcplusplus
180 
181 #endif
a class that defines a supercell in D-dimensional Euclean space.
mRealType Dminus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:219
mRealType hintr2(int n) const override
Definition: LPQHIBasis.cpp:79
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
mRealType dh_dr(int n, mRealType r) const override
Definition: LPQHIBasis.h:91
EwaldHandler3D::mRealType mRealType
Matrix< mRealType > S
Definition: LPQHIBasis.h:33
Matrix< mRealType > S1
Definition: LPQHIBasis.h:34
mRealType Mfactor[3]
Definition: LPQHIBasis.h:36
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
T min(T a, T b)
mRealType get_delta() const
Definition: LPQHIBasis.h:63
mRealType h(int n, mRealType r) const override
Definition: LPQHIBasis.h:68
A derivative of LRBasis class to provide the functionality of the LPQHI basis.
Definition: LPQHIBasis.h:28
void set_rc(mRealType rc) override
Definition: LPQHIBasis.cpp:36
Base-class for long-range breakups.
Definition: LRBasis.h:33
LPQHIBasis(const LPQHIBasis &b, const ParticleLayout &ref)
Definition: LPQHIBasis.h:46
void set_NumKnots(int n)
Definition: LPQHIBasis.cpp:22
std::complex< mRealType > Eplus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:171
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40
std::vector< mRealType > tvec
Definition: LPQHIBasis.h:37
mRealType c(int n, mRealType k) const override
Definition: LPQHIBasis.cpp:139
Matrix< mRealType > S2
Definition: LPQHIBasis.h:35
DECLARE_COULOMB_TYPES int BasisSize
size of the basis elements
Definition: LRBasis.h:38
LPQHIBasis(const ParticleLayout &ref)
Definition: LPQHIBasis.h:144
std::complex< mRealType > Eminus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:191
mRealType Dplus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:211