QMCPACK
LPQHIBasis Class Reference

A derivative of LRBasis class to provide the functionality of the LPQHI basis. More...

+ Inheritance diagram for LPQHIBasis:
+ Collaboration diagram for LPQHIBasis:

Public Member Functions

 LPQHIBasis (const LPQHIBasis &b, const ParticleLayout &ref)
 
mRealType get_delta () const
 
void set_NumKnots (int n)
 
void set_rc (mRealType rc) override
 
mRealType h (int n, mRealType r) const override
 
mRealType dh_dr (int n, mRealType r) const override
 
mRealType hintr2 (int n) const override
 
mRealType c (int n, mRealType k) const override
 
 LPQHIBasis (const ParticleLayout &ref)
 
- Public Member Functions inherited from LRBasis
 LRBasis (const ParticleLayout &ref)
 
virtual ~LRBasis ()=default
 
int NumBasisElem () const
 
virtual mRealType dc_dk (int m, mRealType k) const
 
mRealType df (int m, mRealType r) const
 
mRealType f (mRealType r, const std::vector< mRealType > &coefs) const
 $f(r,{tn})$ returns the value of $ t_n*h_{ n}(r)$ r is radial position (scalar) std::vector<RealType> coefs are the {tn} optimized breakup coefficients. More...
 
mRealType df_dr (mRealType r, const std::vector< mRealType > &coefs) const
 
mRealType fk (mRealType k, const std::vector< mRealType > coefs) const
 
mRealType dfk_dk (mRealType k, const std::vector< mRealType > coefs) const
 
mRealType get_rc () const
 
mRealType get_CellVolume () const
 
void set_Lattice (const ParticleLayout &ref)
 
const ParticleLayoutget_Lattice () const
 

Private Member Functions

std::complex< mRealTypeEplus (int i, mRealType k, int n) const
 
std::complex< mRealTypeEminus (int i, mRealType k, int n) const
 
mRealType Dplus (int i, mRealType k, int n) const
 
mRealType Dminus (int i, mRealType k, int n) const
 

Private Attributes

int NumKnots
 
mRealType delta
 
mRealType deltainv
 
Matrix< mRealTypeS
 
Matrix< mRealTypeS1
 
Matrix< mRealTypeS2
 
mRealType Mfactor [3]
 
std::vector< mRealTypetvec
 

Additional Inherited Members

- Public Types inherited from LRBasis
using ParticleLayout = ParticleSet::ParticleLayout
 Typedef for the lattice-type. We don't need the full particle-set. More...
 
- Public Attributes inherited from LRBasis
DECLARE_COULOMB_TYPES int BasisSize
 size of the basis elements More...
 
mRealType m_rc
 Real-space cutoff for short-range part. More...
 
ParticleLayout Lattice
 

Detailed Description

A derivative of LRBasis class to provide the functionality of the LPQHI basis.

Based on code by Ken Esler from PIM.

Definition at line 28 of file LPQHIBasis.h.

Constructor & Destructor Documentation

◆ LPQHIBasis() [1/2]

LPQHIBasis ( const LPQHIBasis b,
const ParticleLayout ref 
)
inline

Definition at line 46 of file LPQHIBasis.h.

References LRBasis::BasisSize, LRBasis::m_rc, and LPQHIBasis::Mfactor.

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  }
LRBasis(const ParticleLayout &ref)
Definition: LRBasis.h:50
Matrix< mRealType > S
Definition: LPQHIBasis.h:33
Matrix< mRealType > S1
Definition: LPQHIBasis.h:34
mRealType Mfactor[3]
Definition: LPQHIBasis.h:36
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40
std::vector< mRealType > tvec
Definition: LPQHIBasis.h:37
Matrix< mRealType > S2
Definition: LPQHIBasis.h:35
DECLARE_COULOMB_TYPES int BasisSize
size of the basis elements
Definition: LRBasis.h:38

◆ LPQHIBasis() [2/2]

LPQHIBasis ( const ParticleLayout ref)
inline

Definition at line 144 of file LPQHIBasis.h.

References LPQHIBasis::Mfactor, Matrix< T, Alloc >::resize(), LPQHIBasis::S, and LPQHIBasis::S1.

144  : 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  }
LRBasis(const ParticleLayout &ref)
Definition: LRBasis.h:50
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

Member Function Documentation

◆ c()

LPQHIBasis::mRealType c ( int  n,
mRealType  k 
) const
overridevirtual

Implements LRBasis.

Definition at line 139 of file LPQHIBasis.cpp.

References LPQHIBasis::Dminus(), LPQHIBasis::Dplus(), qmcplusplus::Units::distance::m, qmcplusplus::n, LPQHIBasis::NumKnots, LPQHIBasis::S, and sign().

140 {
141  int i = m / 3;
142  int alpha = m - 3 * i;
143  mRealType sum = 0.0;
144  if (i == 0)
145  {
146  for (int n = 0; n <= 5; n++)
147  {
148  sum += S(alpha, n) * (Dplus(i, k, n));
149  }
150  }
151  else if (i == (NumKnots - 1))
152  {
153  for (int n = 0; n <= 5; n++)
154  {
155  mRealType sign = ((alpha + n) & 1) ? -1.0 : 1.0;
156  sum += S(alpha, n) * (Dminus(i, k, n) * sign);
157  }
158  }
159  else
160  {
161  for (int n = 0; n <= 5; n++)
162  {
163  mRealType sign = ((alpha + n) & 1) ? -1.0 : 1.0;
164  sum += S(alpha, n) * (Dplus(i, k, n) + Dminus(i, k, n) * sign);
165  }
166  }
167  return (sum);
168 }
mRealType Dminus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:219
EwaldHandler3D::mRealType mRealType
Matrix< mRealType > S
Definition: LPQHIBasis.h:33
double sign(double x)
Definition: Standard.h:73
mRealType Dplus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:211

◆ dh_dr()

mRealType dh_dr ( int  n,
mRealType  r 
) const
inlineoverridevirtual

Reimplemented from LRBasis.

Definition at line 91 of file LPQHIBasis.h.

References LPQHIBasis::delta, LPQHIBasis::deltainv, LRBasis::m_rc, LPQHIBasis::Mfactor, omptarget::min(), qmcplusplus::n, and LPQHIBasis::S.

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  }
EwaldHandler3D::mRealType mRealType
Matrix< mRealType > S
Definition: LPQHIBasis.h:33
mRealType Mfactor[3]
Definition: LPQHIBasis.h:36
T min(T a, T b)
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40

◆ Dminus()

LPQHIBasis::mRealType Dminus ( int  i,
mRealType  k,
int  n 
) const
inlineprivate

Definition at line 219 of file LPQHIBasis.cpp.

References LPQHIBasis::delta, LPQHIBasis::Eminus(), qmcplusplus::n, and CrystalLattice< T, D >::Volume.

Referenced by LPQHIBasis::c().

220 {
221  std::complex<mRealType> Z1 = Eminus(i, k, n + 1);
222  std::complex<mRealType> Z2 = Eminus(i, k, n);
223  return -4.0 * M_PI / (k * Lattice.Volume) * (delta * Z1.imag() + i * delta * Z2.imag());
224 }
ParticleLayout Lattice
Definition: LRBasis.h:46
Scalar_t Volume
Physical properties of a supercell.
std::complex< mRealType > Eminus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:191

◆ Dplus()

LPQHIBasis::mRealType Dplus ( int  i,
mRealType  k,
int  n 
) const
inlineprivate

Definition at line 211 of file LPQHIBasis.cpp.

References LPQHIBasis::delta, LPQHIBasis::Eplus(), qmcplusplus::n, and CrystalLattice< T, D >::Volume.

Referenced by LPQHIBasis::c().

212 {
213  std::complex<mRealType> Z1 = Eplus(i, k, n + 1);
214  std::complex<mRealType> Z2 = Eplus(i, k, n);
215  return 4.0 * M_PI / (k * Lattice.Volume) * (delta * Z1.imag() + i * delta * Z2.imag());
216 }
ParticleLayout Lattice
Definition: LRBasis.h:46
Scalar_t Volume
Physical properties of a supercell.
std::complex< mRealType > Eplus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:171

◆ Eminus()

std::complex< LPQHIBasis::mRealType > Eminus ( int  i,
mRealType  k,
int  n 
) const
inlineprivate

Definition at line 191 of file LPQHIBasis.cpp.

References qmcplusplus::cos(), LPQHIBasis::delta, qmcplusplus::n, sign(), and qmcplusplus::sin().

Referenced by LPQHIBasis::Dminus().

192 {
193  std::complex<mRealType> eye(0.0, 1.0);
194  if (n == 0)
195  {
196  std::complex<mRealType> e1(cos(k * delta) - 1.0, -sin(k * delta));
197  std::complex<mRealType> e2(cos(k * delta * i), sin(k * delta * i));
198  return (-(eye / k) * e1 * e2);
199  }
200  else
201  {
202  std::complex<mRealType> t1, t2;
203  mRealType sign = (n & 1) ? -1.0 : 1.0;
204  t1 = sign * std::complex<mRealType>(cos(k * delta * (i - 1)), sin(k * delta * (i - 1)));
205  t2 = -(mRealType)n / delta * Eminus(i, k, n - 1);
206  return (-(eye / k) * (t1 + t2));
207  }
208 }
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
EwaldHandler3D::mRealType mRealType
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
double sign(double x)
Definition: Standard.h:73
std::complex< mRealType > Eminus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:191

◆ Eplus()

std::complex< LPQHIBasis::mRealType > Eplus ( int  i,
mRealType  k,
int  n 
) const
inlineprivate

Definition at line 171 of file LPQHIBasis.cpp.

References qmcplusplus::cos(), LPQHIBasis::delta, qmcplusplus::n, and qmcplusplus::sin().

Referenced by LPQHIBasis::Dplus().

172 {
173  std::complex<mRealType> eye(0.0, 1.0);
174  if (n == 0)
175  {
176  std::complex<mRealType> e1(cos(k * delta) - 1.0, sin(k * delta));
177  std::complex<mRealType> e2(cos(k * delta * i), sin(k * delta * i));
178  return (-(eye / k) * e1 * e2);
179  }
180  else
181  {
182  std::complex<mRealType> t1, t2;
183  t1 = std::complex<mRealType>(cos(k * delta * (i + 1)), sin(k * delta * (i + 1)));
184  t2 = -(mRealType)n / delta * Eplus(i, k, n - 1);
185  ;
186  return (-(eye / k) * (t1 + t2));
187  }
188 }
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
EwaldHandler3D::mRealType mRealType
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
std::complex< mRealType > Eplus(int i, mRealType k, int n) const
Definition: LPQHIBasis.cpp:171

◆ get_delta()

mRealType get_delta ( ) const
inline

Definition at line 63 of file LPQHIBasis.h.

References LPQHIBasis::delta.

63 { return delta; }

◆ h()

mRealType h ( int  n,
mRealType  r 
) const
inlineoverridevirtual

Implements LRBasis.

Definition at line 68 of file LPQHIBasis.h.

References LPQHIBasis::delta, LPQHIBasis::deltainv, LRBasis::m_rc, LPQHIBasis::Mfactor, omptarget::min(), qmcplusplus::n, and LPQHIBasis::S.

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  }
EwaldHandler3D::mRealType mRealType
Matrix< mRealType > S
Definition: LPQHIBasis.h:33
mRealType Mfactor[3]
Definition: LPQHIBasis.h:36
T min(T a, T b)
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40

◆ hintr2()

LPQHIBasis::mRealType hintr2 ( int  n) const
overridevirtual

Implements LRBasis.

Definition at line 79 of file LPQHIBasis.cpp.

References LPQHIBasis::delta, qmcplusplus::n, LPQHIBasis::NumKnots, and LPQHIBasis::S.

80 {
81  int j = n / 3;
82  int alpha = n - 3 * j;
83  mRealType deltap3 = delta * delta * delta;
84  mRealType min1toalpha = 1.0;
85  bool alphaeven = true;
86  //Constants above correct for alpha==0
87  if (alpha == 1)
88  {
89  min1toalpha = -1.0;
90  alphaeven = false;
91  }
92  mRealType sum = 0.0;
93  if (j == 0)
94  {
95  for (int i = 0; i <= 5; i++)
96  sum += S(alpha, i) / (i + 3);
97  sum *= deltap3;
98  }
99  else if (j == (NumKnots - 1))
100  {
101  mRealType prod1 = 1.0 / 3.0;
102  mRealType prod2 = -j;
103  mRealType prod3 = j * j;
104  for (int i = 0; i <= 5; i++)
105  {
106  sum += S(alpha, i) * (prod1 + prod2 + prod3);
107  prod1 *= (i + 3.0) / (i + 4.0);
108  prod2 *= (i + 2.0) / (i + 3.0);
109  prod3 *= (i + 1.0) / (i + 2.0);
110  }
111  sum *= deltap3 * min1toalpha;
112  }
113  else
114  // expression for 0<j<M
115  {
116  if (alphaeven)
117  {
118  mRealType prod1 = 1.0 / 3.0;
119  mRealType prod2 = j * j;
120  for (int i = 0; i <= 5; i++)
121  {
122  sum += S(alpha, i) * (prod1 + prod2);
123  prod1 *= (i + 3.0) / (i + 4.0); //Prepare for next cycle.
124  prod2 *= (i + 1.0) / (i + 2.0); //Prepare for next cycle.
125  }
126  sum *= 2. * deltap3;
127  }
128  else
129  {
130  for (int i = 0; i <= 5; i++)
131  sum += S(alpha, i) / (i + 2.0);
132  sum *= deltap3 * 4. * j;
133  }
134  }
135  return (sum);
136 }
EwaldHandler3D::mRealType mRealType
Matrix< mRealType > S
Definition: LPQHIBasis.h:33

◆ set_NumKnots()

void set_NumKnots ( int  n)

Definition at line 22 of file LPQHIBasis.cpp.

References LRBasis::BasisSize, LPQHIBasis::delta, LPQHIBasis::deltainv, LRBasis::m_rc, qmcplusplus::n, and LPQHIBasis::NumKnots.

23 {
24  assert(n > 1);
25  NumKnots = n;
26  if (m_rc != 0.0)
27  {
28  delta = m_rc / (NumKnots - 1);
29  deltainv = 1.0 / delta;
30  }
31  //set the BasisSize to 3*NumKnots
32  BasisSize = 3 * NumKnots;
33 }
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40
DECLARE_COULOMB_TYPES int BasisSize
size of the basis elements
Definition: LRBasis.h:38

◆ set_rc()

void set_rc ( mRealType  rc)
overridevirtual

Implements LRBasis.

Definition at line 36 of file LPQHIBasis.cpp.

References LPQHIBasis::delta, LPQHIBasis::deltainv, LRBasis::m_rc, and LPQHIBasis::NumKnots.

37 {
38  m_rc = rc;
39  if (NumKnots != 0)
40  {
41  delta = m_rc / (NumKnots - 1);
42  deltainv = 1.0 / delta;
43  }
44 }
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40

Member Data Documentation

◆ delta

◆ deltainv

mRealType deltainv
private

◆ Mfactor

mRealType Mfactor[3]
private

Definition at line 36 of file LPQHIBasis.h.

Referenced by LPQHIBasis::dh_dr(), LPQHIBasis::h(), and LPQHIBasis::LPQHIBasis().

◆ NumKnots

int NumKnots
private

◆ S

◆ S1

Matrix<mRealType> S1
private

Definition at line 34 of file LPQHIBasis.h.

Referenced by LPQHIBasis::LPQHIBasis().

◆ S2

Matrix<mRealType> S2
private

Definition at line 35 of file LPQHIBasis.h.

◆ tvec

std::vector<mRealType> tvec
private

Definition at line 37 of file LPQHIBasis.h.


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