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

Comparing branches/development/src/nonbonded/MAW.cpp (file contents):
Revision 1554 by gezelter, Sat Apr 30 02:54:02 2011 UTC vs.
Revision 1874 by gezelter, Wed May 15 15:09:35 2013 UTC

# Line 35 | Line 35
35   *                                                                      
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).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
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 <stdio.h>
# Line 50 | Line 51 | namespace OpenMD {
51  
52   namespace OpenMD {
53  
54 <  MAW::MAW() : name_("MAW"), initialized_(false), forceField_(NULL),
54 <                   shiftedPot_(false), shiftedFrc_(false) {}
54 >  MAW::MAW() : name_("MAW"), initialized_(false), forceField_(NULL) {}
55    
56    void MAW::initialize() {    
57  
58      ForceField::NonBondedInteractionTypeContainer* nbiTypes = forceField_->getNonBondedInteractionTypes();
59      ForceField::NonBondedInteractionTypeContainer::MapTypeIterator j;
60      NonBondedInteractionType* nbt;
61 +    ForceField::NonBondedInteractionTypeContainer::KeyType keys;
62  
63      for (nbt = nbiTypes->beginType(j); nbt != NULL;
64           nbt = nbiTypes->nextType(j)) {
65        
66        if (nbt->isMAW()) {
67 <        pair<AtomType*, AtomType*> atypes = nbt->getAtomTypes();
68 <        
69 <        GenericData* data = nbt->getPropertyByName("MAW");
70 <        if (data == NULL) {
71 <          sprintf( painCave.errMsg, "MAW::initialize could not find\n"
72 <                   "\tMAW parameters for %s - %s interaction.\n",
73 <                   atypes.first->getName().c_str(),
73 <                   atypes.second->getName().c_str());
74 <          painCave.severity = OPENMD_ERROR;
75 <          painCave.isFatal = 1;
76 <          simError();
77 <        }
78 <        
79 <        MAWData* mawData = dynamic_cast<MAWData*>(data);
80 <        if (mawData == NULL) {
67 >        keys = nbiTypes->getKeys(j);
68 >        AtomType* at1 = forceField_->getAtomType(keys[0]);
69 >        AtomType* at2 = forceField_->getAtomType(keys[1]);
70 >
71 >        MAWInteractionType* mit = dynamic_cast<MAWInteractionType*>(nbt);
72 >
73 >        if (mit == NULL) {
74            sprintf( painCave.errMsg,
75 <                   "MAW::initialize could not convert GenericData to\n"
76 <                   "\tMAWData for %s - %s interaction.\n",
77 <                   atypes.first->getName().c_str(),
78 <                   atypes.second->getName().c_str());
75 >                   "MAW::initialize could not convert NonBondedInteractionType\n"
76 >                   "\tto MAWInteractionType for %s - %s interaction.\n",
77 >                   at1->getName().c_str(),
78 >                   at2->getName().c_str());
79            painCave.severity = OPENMD_ERROR;
80            painCave.isFatal = 1;
81            simError();          
82          }
83          
84 <        MAWParam mawParam = mawData->getData();
85 <
86 <        RealType De = mawParam.De;
87 <        RealType beta = mawParam.beta;
88 <        RealType Re = mawParam.Re;
96 <        RealType ca1 = mawParam.ca1;
97 <        RealType cb1 = mawParam.cb1;
84 >        RealType De = mit->getD();
85 >        RealType beta = mit->getBeta();
86 >        RealType Re = mit->getR();
87 >        RealType ca1 = mit->getCA1();
88 >        RealType cb1 = mit->getCB1();
89          
90 <        addExplicitInteraction(atypes.first, atypes.second,
90 >        addExplicitInteraction(at1, at2,
91                                 De, beta, Re, ca1, cb1);
92        }
93      }  
# Line 129 | Line 120 | namespace OpenMD {
120      if (!initialized_) initialize();
121      
122      map<pair<AtomType*, AtomType*>, MAWInteractionData>::iterator it;
123 <    it = MixingMap.find( *(idat.atypes) );
123 >    it = MixingMap.find( idat.atypes );
124      if (it != MixingMap.end()) {
125        MAWInteractionData mixer = (*it).second;
126        
# Line 144 | Line 135 | namespace OpenMD {
135        RealType ca1 = mixer.ca1;
136        RealType cb1 = mixer.cb1;
137  
138 <      bool j_is_Metal = idat.atypes->second->isMetal();
138 >      bool j_is_Metal = idat.atypes.second->isMetal();
139  
140        Vector3d r;
141        RotMat3x3d Atrans;
# Line 172 | Line 163 | namespace OpenMD {
163        myPot  = D_e * (expfnc2  - 2.0 * expfnc);
164        myDeriv   = 2.0 * D_e * beta * (expfnc - expfnc2);
165        
166 <      if (MAW::shiftedPot_ || MAW::shiftedFrc_) {
166 >      if (idat.shiftedPot || idat.shiftedForce) {
167          exptC     = -beta*( *(idat.rcut)  - R_e);
168          expfncC   = exp(exptC);
169          expfnc2C  = expfncC*expfncC;
170        }
171        
172 <      if (MAW::shiftedPot_) {
172 >      if (idat.shiftedPot) {
173          myPotC = D_e * (expfnc2C - 2.0 * expfncC);
174          myDerivC = 0.0;
175 <      } else if (MAW::shiftedFrc_) {
175 >      } else if (idat.shiftedForce) {
176          myPotC = D_e * (expfnc2C - 2.0 * expfncC);
177 <        myDerivC  = 2.0 * D_e * beta * (expfnc2C - expfnc2C);
177 >        myDerivC  = 2.0 * D_e * beta * (expfncC - expfnc2C);
178          myPotC += myDerivC * ( *(idat.rij)  -  *(idat.rcut) );
179        } else {
180          myPotC = 0.0;
# Line 194 | Line 185 | namespace OpenMD {
185        RealType y = r.y();
186        RealType z = r.z();
187        RealType x2 = x * x;
197      RealType y2 = y * y;
188        RealType z2 = z * z;
189  
190        RealType r3 = *(idat.r2) *  *(idat.rij) ;
# Line 221 | Line 211 | namespace OpenMD {
211        
212        RealType pot_temp = *(idat.vdwMult) * Vmorse * Vang;
213        *(idat.vpair) += pot_temp;
214 <      idat.pot[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp;
214 >      (*(idat.pot))[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp;
215            
216        Vector3d dVmorsedr = (myDeriv - myDerivC) * Vector3d(x, y, z) /  *(idat.rij) ;
217        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines