QMCPACK
NLPP.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: Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 // http://pathintegrals.info //
15 /////////////////////////////////////////////////////////////
16 
17 #ifndef NLPP_CLASS_H
18 #define NLPP_CLASS_H
19 
20 #include "PotentialBase.h"
21 #include "IO.h"
22 #include "CubicSplineCommon.h"
23 #include <vector>
24 using namespace IO;
25 
27 {
28 protected:
29  // The projector is given by norm*deltaVl(r)*ul(r)
30  double ProjectorNorm;
31  inline double jl(int l, double x);
33  double qCurrent, rCurrent;
34  typedef enum
35  {
37  EKB,
40  CHECK_CHI_R
41  } IntegrandType;
43  double A(double q, double qp);
44 
45 public:
46  int l;
47  // V stores the potential
48  // DeltaV stores the potential less to the local potential
50  CubicSplineCommon V, DeltaV, u;
51  double rc, R0;
52  double Occupation, Eigenvalue;
53  // The Kleinman-Bylander projection energy
54  double E_KB;
55  // The unfiltered projection operators in real-space and reciprocal
56  // space.
58  // These store the real and reciprocal-space representation of the
59  // filtered projector
61 
62  // This is used as the integrand for the various integrals that are required.
63  inline double operator()(double x);
64 
65  void SetupProjector(double G_max, double G_FFT);
66  void Read(IOSectionClass& in, std::shared_ptr<Grid>& grid);
67  void Write(IOSectionClass& out);
68 };
69 
70 class NLPPClass : public Potential
71 {
72 protected:
73  int lLocal;
74  std::vector<ChannelPotential> Vl;
75  // The charge of the ion. The potential should have a tail of
76  // V(r) = -Zion/r for large r.
77  double Zion;
79  std::string Symbol;
80  std::shared_ptr<Grid> PotentialGrid;
81 
82 public:
83  // General accessor functions
84  bool IsNonlocal() override;
85  inline int LocalChannel() { return lLocal; }
86  inline int NumChannels() { return Vl.size(); }
87  inline CubicSplineCommon& GetLocalSpline() { return Vl[lLocal].V; }
88  inline double GetValenceCharge() { return Zion; }
89 
90  // Nonlocal part accessor functions:
91  inline double GetChi_r(int l, double r) { return Vl[l].chi_r(r); }
92  inline double GetZeta_r(int l, double r) { return Vl[l].zeta_r(r); }
93  inline double GetChi_q(int l, double q) { return Vl[l].chi_q(q); }
94  inline double GetZeta_q(int l, double q) { return Vl[l].zeta_q(q); }
95  // HACK HACK HACK
96  //inline double GetChi_r (int l, double r) { return Vl[l].zeta_r(r); }
97  inline double GetE_KB(int l) { return Vl[l].E_KB; }
98  inline double GetR0(int l) { return Vl[l].R0; }
99  inline double Getrc(int l) { return Vl[l].rc; }
100  inline double GetDeltaV(int l, double r) { return Vl[l].DeltaV(r); }
101  // Override default for local potentials
102  double V(int l, double r) override;
103  double dVdr(int l, double r) override;
104  double d2Vdr2(int l, double r) override;
105 
106 
107  // Required member functions: These give information about the
108  // local part of the pseudopotential only
109  double V(double r) override;
110  double dVdr(double r) override;
111  double d2Vdr2(double r) override;
112 
113  // IO routines
114  void Write(IOSectionClass& out) override;
115  void Read(IOSectionClass& in) override;
116  void SetupProjectors(double G_max, double G_FFT);
117 };
118 
119 
120 inline double ChannelPotential::jl(int l, double x)
121 {
122  if (std::abs(x) > 0.0)
123  {
124  if (l == 0)
125  return sin(x) / x;
126  else if (l == 1)
127  {
128  if (x < 1.0e-4)
129  return x / 3.0 - x * x * x / 30.0 + x * x * x * x * x / 840.0 - x * x * x * x * x * x * x / 45360.0;
130  else
131  return sin(x) / (x * x) - cos(x) / x;
132  }
133  else if (l == 2)
134  {
135  if (x < 1.0e-2)
136  return x * x / 15.0 - x * x * x * x / 210.0 + x * x * x * x * x * x / 7560.0 -
137  x * x * x * x * x * x * x * x / 498960.0;
138  else
139  return ((3.0 / (x * x * x) - 1.0 / x) * sin(x) - 3.0 / (x * x) * cos(x));
140  }
141  else
142  {
143  std::cerr << "j(l,x) not implemented for l > 2.\n";
144  abort();
145  }
146  }
147  else
148  { // x -> 0 limit
149  if (l == 0)
150  return 1.0;
151  else
152  return 0.0;
153  }
154 }
155 
156 
157 inline double ChannelPotential::operator()(double x)
158 {
159  switch (Job)
160  {
161  case NORM:
162  return u(x) * DeltaV(x) * DeltaV(x) * u(x);
163  case EKB:
164  return u(x) * DeltaV(x) * u(x);
165  case ZETA_Q:
166  return jl(l, qCurrent * x) * x * x * zeta_r(x);
167  case CHI_R:
168  return 2.0 / M_PI * x * x * chi_q(x) * jl(l, x * rCurrent);
169  case CHECK_CHI_R:
170  return chi_r(x) * chi_r(x) * x * x;
171  default:
172  return 0.0;
173  }
174 }
175 
176 
177 #endif
double GetValenceCharge()
Definition: NLPP.h:88
CubicSplineCommon V
Definition: NLPP.h:50
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
double operator()(double x)
Definition: NLPP.h:157
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
Definition: NLPP.h:70
double ProjectorNorm
Definition: NLPP.h:30
double GetR0(int l)
Definition: NLPP.h:98
The CubicSplineCommon class is a third-order spline representation of a function. ...
double E_KB
Definition: NLPP.h:54
LinearGrid qGrid
Definition: NLPP.h:32
double Zion
Definition: NLPP.h:77
Definition: IO.h:24
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
double GetZeta_r(int l, double r)
Definition: NLPP.h:92
double GetE_KB(int l)
Definition: NLPP.h:97
double Getrc(int l)
Definition: NLPP.h:99
Linear Grid inherets from Grid.
Definition: Grid.h:73
int n_principal
Definition: NLPP.h:49
std::shared_ptr< Grid > PotentialGrid
Definition: NLPP.h:80
double rCurrent
Definition: NLPP.h:33
double GetChi_q(int l, double q)
Definition: NLPP.h:93
int AtomicNumber
Definition: NLPP.h:78
std::string Symbol
Definition: NLPP.h:79
CubicSplineCommon zeta_r
Definition: NLPP.h:57
CubicSplineCommon & GetLocalSpline()
Definition: NLPP.h:87
int NumChannels()
Definition: NLPP.h:86
Wrapper class for IOTreeClass that gives a nearly identical interface as the OutputSectionClass.
Definition: IO.h:110
int lLocal
Definition: NLPP.h:73
int LocalChannel()
Definition: NLPP.h:85
double GetDeltaV(int l, double r)
Definition: NLPP.h:100
double GetChi_r(int l, double r)
Definition: NLPP.h:91
double GetZeta_q(int l, double q)
Definition: NLPP.h:94
IntegrandType Job
Definition: NLPP.h:42
double Occupation
Definition: NLPP.h:52
double jl(int l, double x)
Definition: NLPP.h:120
std::vector< ChannelPotential > Vl
Definition: NLPP.h:74
double rc
Definition: NLPP.h:51
CubicSplineCommon chi_r
Definition: NLPP.h:60