JDFTx  1.2.0
ErfFMTweight.h
1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx. If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_FLUID_ERFFMTWEIGHT_H
21 #define JDFTX_FLUID_ERFFMTWEIGHT_H
22 
23 #include <electronic/SphericalHarmonics.h>
24 #include <cmath>
25 
28 {
29 public:
30  ErfFMTweight(double R, double sigma) : R(R),sigma(sigma)
31  { //root and curvature of the saddle point integrand used in w0, w1v and w2m:
32  r0 = sqrt(pow(0.5*R,2) - pow(sigma,2)) + 0.5*R;
33  c0 = 1 - pow(sigma/r0,2);
34  }
35 
37  void operator()(double G, double& w0, double& w1, double& w2, double& w3, double& w1v, double& w2m) const
38  { //Weights without saddle point approx:
39  double prefac = exp(-0.5*pow(G*sigma,2));
40  double j0 = bessel_jl(0, G*R);
41  double j2 = bessel_jl(2, G*R);
42  double softness = pow(sigma/R,2);
43  //---
44  w1 = R * prefac * j0;
45  w2 = 4*M_PI*pow(R,2) * prefac * (j0 + softness*cos(G*R));
46  w3 = (4*M_PI*pow(R,3)/3) * prefac * (j0*(1+3*softness) + j2);
47 
48  //Weights with saddle point approx:
49  prefac = exp(-0.5*pow(sigma ? (r0-R)/sigma : 0.0, 2))/sqrt(c0) * exp(-(0.5/c0)*pow(G*sigma,2));
50  j0 = bessel_jl(0, G*r0);
51  j2 = bessel_jl(2, G*r0);
52  double j4 = bessel_jl(4, G*r0);
53  softness = pow(sigma/r0,2)/c0;
54  //---
55  w0 = prefac * j0;
56  w1v = -pow(r0,2)/3 * prefac * (j0*(1+3*softness) + j2);
57  w2m = (4*M_PI*pow(r0,4)/15) * prefac * (j0*(1+softness*(10+softness*15)) + 10*j2*(1.0/7+softness) + (3.0/7)*j4);
58  }
59 
60 private:
61  double R, sigma, r0, c0;
62 };
63 
64 #endif // JDFTX_FLUID_ERFFMTWEIGHT_H
ScalarField pow(const ScalarField &, double alpha)
Elementwise power (preserve input)
ScalarField sqrt(const ScalarField &)
Elementwise square root (preserve input)
void operator()(double G, double &w0, double &w1, double &w2, double &w3, double &w1v, double &w2m) const
set the weights at a given G
Definition: ErfFMTweight.h:37
Utility for creating soft FMT weight functions.
Definition: ErfFMTweight.h:27
ScalarField exp(const ScalarField &)
Elementwise exponential (preserve input)