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: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 //                    Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //                    Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 //                    Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef QMCPLUSPLUS_MPC_H
17 #define QMCPLUSPLUS_MPC_H
18 #include "QMCHamiltonians/OperatorBase.h"
19 #include "LongRange/LRCoulombSingleton.h"
20 
21 #if defined(HAVE_EINSPLINE)
22 #include "einspline/bspline.h"
23 #else
24 class UBspline_3d_d;
25 #endif
26 namespace qmcplusplus
27 {
28 /** @ingroup hamiltonian
29  *\brief Calculates the Model Periodic Coulomb potential using PBCs
30  */
31 
32 class MPC : public OperatorBase
33 {
34 protected:
35   UBspline_3d_d *VlongSpline, *DensitySpline;
36   double Vconst;
37   void compute_g_G(double& g_0_N, std::vector<double>& g_G_N, int N);
38   void init_gvecs();
39   void init_f_G();
40   void init_spline();
41   double Ecut;
42   std::vector<TinyVector<int, OHMMS_DIM>> Gints;
43   std::vector<PosType> Gvecs;
44   std::vector<ComplexType> Rho_G;
45   TinyVector<int, OHMMS_DIM> SplineDim;
46   int MaxDim;
47   Return_t evalSR(ParticleSet& P) const;
48   Return_t evalLR(ParticleSet& P) const;
49   // AA table ID
50   const int d_aa_ID;
51 
52 public:
53   ParticleSet* PtclRef;
54   // Store the average electron charge density in reciprocal space
55   std::vector<ComplexType> RhoAvg_G;
56   std::vector<RealType> f_G;
57   // The G=0 component
58   double f_0;
59 
60   bool FirstTime;
61   int NumSpecies;
62   int ChargeAttribIndx;
63   int MemberAttribIndx;
64   int NParticles;
65   RealType myConst;
66   RealType myRcut;
67   std::vector<RealType> Zat, Zspec;
68   std::vector<int> NofSpecies;
69 
70   MPC(ParticleSet& ref, double cutoff);
71 
72   /// copy constructor
73   // MPC(const MPC& c);
74 
75   ~MPC();
76 
77   void resetTargetParticleSet(ParticleSet& P);
78 
79   Return_t evaluate(ParticleSet& P);
80 
81   /** implement all-walker stuff */
82   virtual void addEnergy(MCWalkerConfiguration& W, std::vector<RealType>& LocalEnergy);
83 
84   /** Do nothing */
85   bool put(xmlNodePtr cur);
86 
get(std::ostream & os)87   bool get(std::ostream& os) const
88   {
89     os << "MPC potential: " << PtclRef->getName();
90     return true;
91   }
92 
93   OperatorBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi);
94 
95   void initBreakup();
96 };
97 
98 } // namespace qmcplusplus
99 #endif
100