QMCPACK
LRBasis.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 // Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_LRBASIS_H
17 #define QMCPLUSPLUS_LRBASIS_H
18 
19 #include "Particle/ParticleSet.h"
20 #include "Pools/PooledData.h"
21 #include "coulomb_types.h"
22 
23 namespace qmcplusplus
24 {
25 /** @ingroup longrange
26  *\brief Base-class for long-range breakups.
27  *
28  * Contains 3 important functions: c(n,k), h(n,r), hintr2(r)
29  * which evaluate the n'th basis function at k or r.
30  * \f[ hintr2_n = \int dr h_n(r) r^2, \f]
31  */
32 
33 struct LRBasis
34 {
36 
37  ///size of the basis elements
38  int BasisSize;
39  ///Real-space cutoff for short-range part
41 
42  ///Typedef for the lattice-type. We don't need the full particle-set.
44 
45  //A copy of the lattice, so that we have the cell-vectors + volume.
47 
48 public:
49  //Constructor: copy lattice and init rc
50  LRBasis(const ParticleLayout& ref) : m_rc(0.0), Lattice(ref)
51  { /*Do nothing*/
52  }
53 
54  virtual ~LRBasis() = default;
55 
56  inline int NumBasisElem() const { return BasisSize; }
57 
58  //Real-space basis function + integral: override these
59  virtual mRealType h(int n, mRealType r) const = 0;
60  virtual mRealType hintr2(int n) const = 0;
61  virtual mRealType dh_dr(int n, mRealType r) const { return 0.0; };
62  //k-space basis function: override this
63  virtual mRealType c(int m, mRealType k) const = 0;
64  //k-space basis function k space derivative.
65  virtual mRealType dc_dk(int m, mRealType k) const { return 0.0; };
66 
67  //
68  // df(m,r) is included for legacy reasons. Please use dh_dr
69  //
70 
71  inline mRealType df(int m, mRealType r) const { return dh_dr(m, r); };
72 
73  ///$f(r,{tn})$ returns the value of $\sum_n t_n*h_{\alpha n}(r)$
74  /// r is radial position (scalar)
75  /// std::vector<RealType> coefs are the {tn} optimized breakup coefficients.
76 
77  /*
78  *
79  * name: f: function interpolated by optimized-breakup.
80  * @param r The radial coordinate.
81  * @param coefs A vector of optimized breakup coefficents.
82  * @return The value of $f(r) = \sum_n t_n h_{n \alpha}(r)$
83  *
84  */
85 
86  inline mRealType f(mRealType r, const std::vector<mRealType>& coefs) const
87  {
88  mRealType f = 0.0;
89  //RealType df = myFunc.df(r, rinv);
90  for (int n = 0; n < coefs.size(); n++)
91  f += coefs[n] * h(n, r);
92  return f;
93  }
94 
95  /*
96  *
97  * name: df_dr
98  * @param r The radial coordinate.
99  * @param coefs A vector of optimized breakup coefficents.
100  * @return $\frac{df}{dr}$.
101  *
102  */
103 
104  inline mRealType df_dr(mRealType r, const std::vector<mRealType>& coefs) const
105  {
106  mRealType df = 0.0;
107  //RealType df = myFunc.df(r, rinv);
108  for (int n = 0; n < coefs.size(); n++)
109  df += coefs[n] * dh_dr(n, r);
110  return df;
111  }
112 
113  /*
114  *
115  * name: fk
116  * @param k |k|
117  * @param coefs Optimized breakup coefficients
118  * @return The fourier transform of $f(r)$
119  *
120  */
121 
122 
123  inline mRealType fk(mRealType k, const std::vector<mRealType> coefs) const
124  {
125  mRealType fk = 0.0;
126  for (int n = 0; n < coefs.size(); n++)
127  fk += coefs[n] * c(n, k);
128  return fk;
129  }
130 
131  /*
132  *
133  * name: dfk_dk
134  * @param k |k|
135  * @param coefs Optimized breakup coefficients
136  * @return $\frac{df_k}{dk}$
137  *
138  */
139 
140  inline mRealType dfk_dk(mRealType k, const std::vector<mRealType> coefs) const
141  {
142  mRealType dfk = 0.0;
143  for (int n = 0; n < coefs.size(); n++)
144  dfk += coefs[n] * dc_dk(n, k);
145  return dfk;
146  }
147 
148  //May need extra functionality when resetting rc. Override this.
149  virtual void set_rc(mRealType rc) = 0;
150  inline mRealType get_rc() const { return m_rc; }
151  inline mRealType get_CellVolume() const { return Lattice.Volume; }
152  inline void set_Lattice(const ParticleLayout& ref) { Lattice = ref; }
153  inline const ParticleLayout& get_Lattice() const { return Lattice; }
154 };
155 
156 } // namespace qmcplusplus
157 
158 #endif
virtual ~LRBasis()=default
a class that defines a supercell in D-dimensional Euclean space.
virtual mRealType dc_dk(int m, mRealType k) const
Definition: LRBasis.h:65
LRBasis(const ParticleLayout &ref)
Definition: LRBasis.h:50
virtual mRealType hintr2(int n) const =0
mRealType get_rc() const
Definition: LRBasis.h:150
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
EwaldHandler3D::mRealType mRealType
ParticleLayout Lattice
Definition: LRBasis.h:46
mRealType df_dr(mRealType r, const std::vector< mRealType > &coefs) const
Definition: LRBasis.h:104
mRealType fk(mRealType k, const std::vector< mRealType > coefs) const
Definition: LRBasis.h:123
virtual mRealType dh_dr(int n, mRealType r) const
Definition: LRBasis.h:61
Scalar_t Volume
Physical properties of a supercell.
int NumBasisElem() const
Definition: LRBasis.h:56
Base-class for long-range breakups.
Definition: LRBasis.h:33
#define DECLARE_COULOMB_TYPES
Definition: coulomb_types.h:18
void set_Lattice(const ParticleLayout &ref)
Definition: LRBasis.h:152
virtual mRealType h(int n, mRealType r) const =0
mRealType m_rc
Real-space cutoff for short-range part.
Definition: LRBasis.h:40
virtual void set_rc(mRealType rc)=0
mRealType get_CellVolume() const
Definition: LRBasis.h:151
mRealType dfk_dk(mRealType k, const std::vector< mRealType > coefs) const
Definition: LRBasis.h:140
DECLARE_COULOMB_TYPES int BasisSize
size of the basis elements
Definition: LRBasis.h:38
mRealType df(int m, mRealType r) const
Definition: LRBasis.h:71
virtual mRealType c(int m, mRealType k) const =0
Define a serialized buffer to store anonymous data.
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>...
Definition: LRBasis.h:86
const ParticleLayout & get_Lattice() const
Definition: LRBasis.h:153