20 #ifndef JDFTX_ELECTRONIC_RADIALFUNCTION_H 21 #define JDFTX_ELECTRONIC_RADIALFUNCTION_H 35 const double* coeffPref()
const {
return coeffGpu; }
37 const double* coeffPref()
const {
return coeff.data(); }
41 __hostanddev__
const double* getCoeff()
const 51 void init(
int l,
int nSamples,
double dG,
const char* filename,
double scale=1.0);
52 void init(
int l,
const std::vector<double>& samples,
double dG);
53 void set(
const std::vector<double>&
coeff,
double dGInv);
55 void free(
bool rFuncDelete=
true);
59 {
double Gindex = G *
dGinv;
60 if(Gindex >= nCoeff-5)
return 0.;
66 #ifndef __in_a_cu_file__ 67 template<
typename Func,
typename... Args>
void init(
int l,
double dG,
double Gmax,
const Func& func, Args... args)
69 { std::vector<double> samples(
unsigned(ceil(Gmax/dG))+5);
70 for(
unsigned i=0; i<samples.size(); i++) samples[i] = func(i*dG, args...);
75 static inline double cusplessExpTilde(
double G,
double norm,
double a)
77 double den = 1./(1.+aG*aG);
78 return norm * den*den*den;
82 static inline double exponentialTilde(
double G,
double norm,
double a)
85 double den = 1./(1.+aG*aG);
86 return norm * den*den;
90 static inline double gaussTilde(
double G,
double norm,
double sigma)
91 {
double sigmaG = sigma*G;
92 return norm *
exp(-0.5*sigmaG*sigmaG);
95 explicit operator bool()
const {
return nCoeff; }
102 { std::vector<double>
r;
103 std::vector<double>
dr;
104 std::vector<double>
f;
108 void set(std::vector<double> r, std::vector<double> dr);
117 double transform(
int l,
double G)
const;
121 void transform(
int l,
double dG,
int nGrid,
RadialFunctionG& func)
const;
124 #endif // JDFTX_ELECTRONIC_RADIALFUNCTION_H int nCoeff
number of coefficients
Definition: RadialFunction.h:31
std::vector< double > f
sample value
Definition: RadialFunction.h:104
void init(int l, int nSamples, double dG, const char *filename, double scale=1.0)
read and initialize from an ascii file (DFT PSP format)
__hostanddev__ double value(const double *coeff, double x)
Compute value of quintic spline. Warning: x is not range-checked.
A function on a non-uniform real-space radial grid.
Definition: RadialFunction.h:101
double * coeffGpu
coefficients on gpu
Definition: RadialFunction.h:34
G-space radial function stored on a uniform grid (of |G|)
Definition: RadialFunction.h:28
ScalarField exp(const ScalarField &)
Elementwise exponential (preserve input)
std::vector< double > dr
radial weight
Definition: RadialFunction.h:103
std::vector< double > coeff
coefficients on cpu
Definition: RadialFunction.h:32
__hostanddev__ double operator()(double G) const
Blip (quintic spline evaluation)
Definition: RadialFunction.h:58
void updateGmax(int l, int nSamples)
if created from a RadialFunctionR, increase nCoeff if necessary (call when lattice is modified) ...
Spline interpolation routines.
RadialFunctionR * rFunc
copy of the real-space radial version (if created from one)
Definition: RadialFunction.h:64
double dGinv
inverse sample spacing
Definition: RadialFunction.h:30
std::vector< double > r
radial location
Definition: RadialFunction.h:102