25double const CutoffFunction::PI = 4.0 * atan(1.0);
26double const CutoffFunction::PI_2 = 2.0 * atan(1.0);
27double const CutoffFunction::E = exp(1.0);
28double const CutoffFunction::TANH_PRE = pow((E + 1 / E) / (E - 1 / E), 3);
30CutoffFunction::CutoffFunction() : cutoffType(CT_HARD ),
89 throw invalid_argument(
"ERROR: Unknown cutoff type.\n");
98 rcinv = 1.0 / cutoffRadius;
104 if (alpha < 0.0 || alpha >= 1.0)
106 throw invalid_argument(
"ERROR: 0 <= alpha < 1.0 is required.\n");
116 if (r <
rci)
return 1.0;
117 double const x = (r -
rci) *
iw;
118 return 0.5 * (cos(
PI * x) + 1.0);
123 if (r <
rci)
return 0.0;
124 double const x = (r -
rci) *
iw;
136 double const x = (r -
rci) *
iw;
137 double const temp = cos(
PI * x);
138 fc = 0.5 * (temp + 1.0);
139 dfc = -0.5 *
iw *
PI * sqrt(1.0 - temp * temp);
145 double const temp = tanh(1.0 - r *
rcinv);
146 return temp * temp * temp;
151 double temp = tanh(1.0 - r *
rcinv);
153 return 3.0 * temp * (temp - 1.0) *
rcinv;
158 double const temp = tanh(1.0 - r *
rcinv);
159 double const temp2 = temp * temp;
161 dfc = 3.0 * temp2 * (temp2 - 1.0) *
rcinv;
167 double const temp = tanh(1.0 - r *
rcinv);
168 return TANH_PRE * temp * temp * temp;
173 double temp = tanh(1.0 - r *
rcinv);
180 double const temp = tanh(1.0 - r *
rcinv);
181 double const temp2 = temp * temp;
189 if (r <
rci)
return 1.0;
190 double const x = (r -
rci) *
iw;
196 if (r <
rci)
return 0.0;
197 double const x = (r -
rci) *
iw;
209 double const x = (r -
rci) *
iw;
void fdf(double x, double &fx, double &dfx) const
Calculate function and derivative at once.
double df(double x) const
Calculate derivative of function at argument .
void setType(Type const type)
Set function type.
double f(double x) const
Calculate function value .
Type
List of available function types.
double fHARD(double r) const
CutoffType
List of available cutoff function types.
double rci
Inner cutoff for cutoff function types which allow shifting.
static double const TANH_PRE
double fCORE(double r) const
void fdfCOS(double r, double &fc, double &dfc) const
void fdfHARD(double r, double &fc, double &dfc) const
void fdfTANH(double r, double &fc, double &dfc) const
double rcinv
Inverse cutoff radius .
double fTANHU(double r) const
void fdfTANHU(double r, double &fc, double &dfc) const
double iw
Inverse width of cutoff function .
void fdfCORE(double r, double &fc, double &dfc) const
double fTANH(double r) const
void setCutoffParameter(double const alpha)
Set parameter for polynomial cutoff function (CT_POLY).
double(CutoffFunction::* fPtr)(double r) const
Function pointer to f.
double dfCOS(double r) const
double fCOS(double r) const
double dfTANH(double r) const
double dfCORE(double r) const
double(CutoffFunction::* dfPtr)(double r) const
Function pointer to df.
double dfTANHU(double r) const
void setCutoffType(CutoffType const cutoffType)
Set cutoff type.
double rc
Outer cutoff radius .
CutoffType cutoffType
Cutoff function type.
double alpha
Cutoff function parameter for CT_POLYn and CT_EXP .
double dfHARD(double r) const
CoreFunction core
Core functions used by POLYN, if any.
void setCutoffRadius(double const cutoffRadius)
Set cutoff radius.
void(CutoffFunction::* fdfPtr)(double r, double &fc, double &dfc) const
Function pointer to fdf.