-
Notifications
You must be signed in to change notification settings - Fork 1
/
cutoff.h
41 lines (36 loc) · 954 Bytes
/
cutoff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <cmath>
#include <complex>
template <int LMAX>
struct CutFunc{
typedef std::complex<double> cplx_t;
double gammmainv[1+LMAX];
double rcut [1+LMAX];
cplx_t kcut [1+LMAX];
CutFunc(){
double val = sqrt(4.0*atan(1.0));
for(int ell=0; ell<=LMAX; ell++){
gammmainv[ell] = 1.0 / val;
val *= (0.5 + ell);
}
}
void eval_rcut(const double x){
const double xexp = exp(-x);
double xpow = sqrt(x);
double val = sqrt(4.0*atan(1.0)) * erfc(xpow);
for(int ell=0; ell<=LMAX; ell++){
rcut[ell] = val * gammmainv[ell];
val = (0.5 + ell)*val + xpow * xexp;
xpow *= x;
}
}
void eval_kcut(const double kn2, const double kappa){
const double pi = 4.0 * atan(1.0);
const double gauss = exp(-kn2 * ((pi/kappa)*(pi/kappa)));
const cplx_t ratio(0.0, -pi * kn2);
cplx_t coef = 1.0 / sqrt(pi * kn2);
for(int ell=0; ell<=LMAX; ell++){
kcut[ell] = coef * (gauss * gammmainv[ell]);
coef *= ratio;
}
}
};