ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/nonbonded/SwitchingFunction.cpp
(Generate patch)

Comparing branches/development/src/nonbonded/SwitchingFunction.cpp (file contents):
Revision 1535 by gezelter, Tue Dec 28 21:47:55 2010 UTC vs.
Revision 1536 by gezelter, Wed Jan 5 14:49:05 2011 UTC

# Line 40 | Line 40
40   */
41  
42   #include <cmath>
43 + #include <iostream>
44  
45   #include "nonbonded/SwitchingFunction.hpp"
46   #include "utils/simError.h"
# Line 48 | Line 49 | namespace OpenMD {
49   namespace OpenMD {
50  
51    SwitchingFunction::SwitchingFunction() : np_(150), haveSpline_(false),
52 <                                           isCubic_(true), functionType_(cubic) {}
52 >                                           isCubic_(true), functionType_(cubic) {
53 >    switchSpline_ = new CubicSpline();
54 >  }
55  
56    void SwitchingFunction::setSwitchType(SwitchingFunctionType sft) {
57      if ((sft == fifth_order_poly) || (sft == cubic)) {
58        if (haveSpline_) {
59          delete switchSpline_;
60 +        switchSpline_ = new CubicSpline();
61          setSwitch(rin_, rout_);
62        }
63      } else {
# Line 102 | Line 106 | namespace OpenMD {
106      }
107      
108      // setup r -> sw lookup spline
105    CubicSpline* switchSpline_ = new CubicSpline();
109      if (functionType_ == fifth_order_poly) {
110        isCubic_ = false;
111        RealType c0 = 1.0;
# Line 140 | Line 143 | namespace OpenMD {
143      return;
144    }
145  
146 <  bool SwitchingFunction::getSwitch(RealType r2, RealType sw, RealType dswdr,
147 <                                    RealType r) {
146 >  bool SwitchingFunction::getSwitch(const RealType &r2, RealType &sw, RealType &dswdr,
147 >                                    RealType &r) {
148 >
149      sw = 1.0;
150      dswdr = 0.0;
151 +
152      bool in_switching_region = false;
153  
154      if (r2 > rin2_) {
155        if (r2 > rout2_) {
156          sw = 0.0;
152        dswdr = 0.0;
153        return in_switching_region;
157        } else {
158          in_switching_region = true;
159          r = sqrt(r2);
160          pair<RealType, RealType> result = switchSpline_->getValueAndDerivativeAt(r);
161          sw = result.first;
162          dswdr = result.second;
160        return in_switching_region;
163        }
162    } else {
163      return in_switching_region;
164      }
165 +    return in_switching_region;
166    }
167   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines