| 36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
| 39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 42 |
|
|
| 43 |
|
#include <cmath> |
| 44 |
+ |
#include <iostream> |
| 45 |
+ |
#include <cstdio> |
| 46 |
|
|
| 47 |
|
#include "nonbonded/SwitchingFunction.hpp" |
| 48 |
|
#include "utils/simError.h" |
| 51 |
|
namespace OpenMD { |
| 52 |
|
|
| 53 |
|
SwitchingFunction::SwitchingFunction() : np_(150), haveSpline_(false), |
| 54 |
< |
isCubic_(true), functionType_(cubic) {} |
| 54 |
> |
isCubic_(true), functionType_(cubic) { |
| 55 |
> |
switchSpline_ = new CubicSpline(); |
| 56 |
> |
} |
| 57 |
|
|
| 58 |
|
void SwitchingFunction::setSwitchType(SwitchingFunctionType sft) { |
| 59 |
|
if ((sft == fifth_order_poly) || (sft == cubic)) { |
| 60 |
|
if (haveSpline_) { |
| 61 |
|
delete switchSpline_; |
| 62 |
+ |
switchSpline_ = new CubicSpline(); |
| 63 |
|
setSwitch(rin_, rout_); |
| 64 |
|
} |
| 65 |
|
} else { |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
// setup r -> sw lookup spline |
| 105 |
– |
CubicSpline* switchSpline_ = new CubicSpline(); |
| 111 |
|
if (functionType_ == fifth_order_poly) { |
| 112 |
|
isCubic_ = false; |
| 113 |
|
RealType c0 = 1.0; |
| 145 |
|
return; |
| 146 |
|
} |
| 147 |
|
|
| 148 |
< |
bool SwitchingFunction::getSwitch(RealType r2, RealType sw, RealType dswdr, |
| 149 |
< |
RealType r) { |
| 148 |
> |
bool SwitchingFunction::getSwitch(const RealType &r2, RealType &sw, |
| 149 |
> |
RealType &dswdr, RealType &r) { |
| 150 |
> |
|
| 151 |
|
sw = 1.0; |
| 152 |
|
dswdr = 0.0; |
| 153 |
+ |
|
| 154 |
|
bool in_switching_region = false; |
| 155 |
|
|
| 156 |
|
if (r2 > rin2_) { |
| 157 |
|
if (r2 > rout2_) { |
| 158 |
|
sw = 0.0; |
| 152 |
– |
dswdr = 0.0; |
| 153 |
– |
return in_switching_region; |
| 159 |
|
} else { |
| 160 |
|
in_switching_region = true; |
| 161 |
|
r = sqrt(r2); |
| 162 |
|
pair<RealType, RealType> result = switchSpline_->getValueAndDerivativeAt(r); |
| 163 |
|
sw = result.first; |
| 164 |
|
dswdr = result.second; |
| 160 |
– |
return in_switching_region; |
| 165 |
|
} |
| 162 |
– |
} else { |
| 163 |
– |
return in_switching_region; |
| 166 |
|
} |
| 167 |
+ |
return in_switching_region; |
| 168 |
|
} |
| 169 |
|
} |