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 1530 by gezelter, Tue Dec 28 21:47:55 2010 UTC vs.
Revision 1653 by gezelter, Wed Sep 28 19:37:06 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines