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: Jordan E. Vincent, University of Illinois at Urbana-Champaign
8 //                    Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 //                    Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
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_RPA_JASTROW_H
17 #define QMCPLUSPLUS_RPA_JASTROW_H
18 
19 #include "QMCWaveFunctions/WaveFunctionComponent.h"
20 #include "LongRange/LRHandlerBase.h"
21 #include "QMCWaveFunctions/Jastrow/BsplineFunctor.h"
22 #include "QMCWaveFunctions/Jastrow/SplineFunctors.h"
23 #include "QMCWaveFunctions/Jastrow/LRBreakupUtilities.h"
24 #include "QMCWaveFunctions/Jastrow/kSpaceJastrow.h"
25 
26 namespace qmcplusplus
27 {
28 /** JastrowBuilder using RPA functor
29  *  Modification of RPAJastrow
30  *
31  */
32 struct RPAJastrow : public WaveFunctionComponent
33 {
34   typedef LRHandlerBase HandlerType;
35   typedef BsplineFunctor<RealType> FuncType;
36   typedef LinearGrid<RealType> GridType;
37 
38   RPAJastrow(ParticleSet& target, bool is_manager);
39 
40   ~RPAJastrow();
41 
42   bool put(xmlNodePtr cur);
43 
44   void buildOrbital(const std::string& name,
45                     const std::string& UL,
46                     const std::string& US,
47                     const std::string& RF,
48                     RealType R,
49                     RealType K);
50 
51   void makeShortRange();
52   void makeLongRange();
53 
setHandlerRPAJastrow54   void setHandler(HandlerType* Handler) { myHandler = Handler; };
55 
56   /** check out optimizable variables
57     */
58   void checkOutVariables(const opt_variables_type& o);
59 
60   /** check in an optimizable parameter
61         * @param o a super set of optimizable variables
62     */
63   void checkInVariables(opt_variables_type& o);
64 
65   /** print the state, e.g., optimizables */
66   void reportStatus(std::ostream& os);
67 
68   /** reset the parameters during optimizations
69     */
70   void resetParameters(const opt_variables_type& active);
71 
72   LogValueType evaluateLog(const ParticleSet& P, ParticleSet::ParticleGradient_t& G, ParticleSet::ParticleLaplacian_t& L);
73 
74   PsiValueType ratio(ParticleSet& P, int iat);
75   GradType evalGrad(ParticleSet& P, int iat);
76   PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);
77 
78   void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false);
79 
80   void restore(int iat);
81 
82   void registerData(ParticleSet& P, WFBufferType& buf);
83 
84   LogValueType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false);
85 
86   void copyFromBuffer(ParticleSet& P, WFBufferType& buf);
87 
88   WaveFunctionComponent* makeClone(ParticleSet& tqp) const;
89 
90 private:
91   bool IsManager;
92   bool IgnoreSpin;
93   bool DropLongRange;
94   bool DropShortRange;
95   RealType Rs;
96   RealType Kc;
97   RealType Rcut;
98   std::string ID_Rs;
99   std::string rpafunc;
100   std::string MyName;
101 
102   ///@}
103   /** main handler
104    */
105   HandlerType* myHandler;
106   ///object to handle the long-range part
107   kSpaceJastrow* LongRangeRPA;
108   ///@{objects to handle the short-range part
109   ///two-body Jastrow function
110   WaveFunctionComponent* ShortRangeRPA;
111   ///numerical function owned by ShortRangeRPA
112   FuncType* nfunc;
113   GridType* myGrid;
114   ///adaptor function to initialize nfunc
115   ShortRangePartAdapter<RealType>* SRA;
116   ParticleSet& targetPtcl;
117   ///A list of WaveFunctionComponent*
118   std::vector<WaveFunctionComponent*> Psi;
119 };
120 } // namespace qmcplusplus
121 #endif
122