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

Comparing branches/development/src/nonbonded/Morse.cpp (file contents):
Revision 1583 by gezelter, Thu Jun 16 22:00:08 2011 UTC vs.
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 36 | Line 36
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 <stdio.h>
# Line 45 | Line 46
46   #include <cmath>
47   #include "nonbonded/Morse.hpp"
48   #include "utils/simError.h"
49 < #include "types/NonBondedInteractionType.hpp"
49 > #include "types/MorseInteractionType.hpp"
50  
51   using namespace std;
52  
# Line 55 | Line 56 | namespace OpenMD {
56    
57    void Morse::initialize() {    
58  
58    stringToEnumMap_["shiftedMorse"] = shiftedMorse;
59    stringToEnumMap_["repulsiveMorse"] = repulsiveMorse;
60
59      ForceField::NonBondedInteractionTypeContainer* nbiTypes = forceField_->getNonBondedInteractionTypes();
60      ForceField::NonBondedInteractionTypeContainer::MapTypeIterator j;
61      NonBondedInteractionType* nbt;
62 +    ForceField::NonBondedInteractionTypeContainer::KeyType keys;
63  
64      for (nbt = nbiTypes->beginType(j); nbt != NULL;
65           nbt = nbiTypes->nextType(j)) {
66        
67        if (nbt->isMorse()) {
68 <        
69 <        pair<AtomType*, AtomType*> atypes = nbt->getAtomTypes();
70 <        
72 <        GenericData* data = nbt->getPropertyByName("Morse");
73 <        if (data == NULL) {
74 <          sprintf( painCave.errMsg, "Morse::initialize could not find\n"
75 <                   "\tMorse parameters for %s - %s interaction.\n",
76 <                   atypes.first->getName().c_str(),
77 <                   atypes.second->getName().c_str());
78 <          painCave.severity = OPENMD_ERROR;
79 <          painCave.isFatal = 1;
80 <          simError();
81 <        }
82 <        
83 <        MorseData* morseData = dynamic_cast<MorseData*>(data);
84 <        if (morseData == NULL) {
85 <          sprintf( painCave.errMsg,
86 <                   "Morse::initialize could not convert GenericData to\n"
87 <                   "\tMorseData for %s - %s interaction.\n",
88 <                   atypes.first->getName().c_str(),
89 <                   atypes.second->getName().c_str());
90 <          painCave.severity = OPENMD_ERROR;
91 <          painCave.isFatal = 1;
92 <          simError();          
93 <        }
94 <        
95 <        MorseParam morseParam = morseData->getData();
68 >        keys = nbiTypes->getKeys(j);
69 >        AtomType* at1 = forceField_->getAtomType(keys[0]);
70 >        AtomType* at2 = forceField_->getAtomType(keys[1]);
71  
72 <        RealType De = morseParam.De;
98 <        RealType Re = morseParam.Re;
99 <        RealType beta = morseParam.beta;
100 <        string interactionType = morseParam.interactionType;
72 >        MorseInteractionType* mit = dynamic_cast<MorseInteractionType*>(nbt);
73  
74 <        toUpper(interactionType);
103 <        map<string, MorseInteractionType>::iterator i;
104 <        i = stringToEnumMap_.find(interactionType);
105 <        if (i != stringToEnumMap_.end()) {
106 <          addExplicitInteraction(atypes.first, atypes.second,
107 <                                 De, Re, beta, i->second );
108 <        } else {
74 >        if (mit == NULL) {
75            sprintf( painCave.errMsg,
76 <                   "Morse::initialize found unknown Morse interaction type\n"
77 <                   "\t(%s) for %s - %s interaction.\n",
78 <                   morseParam.interactionType.c_str(),
79 <                   atypes.first->getName().c_str(),
114 <                   atypes.second->getName().c_str());
76 >                   "Morse::initialize could not convert NonBondedInteractionType\n"
77 >                   "\tto MorseInteractionType for %s - %s interaction.\n",
78 >                   at1->getName().c_str(),
79 >                   at2->getName().c_str());
80            painCave.severity = OPENMD_ERROR;
81            painCave.isFatal = 1;
82            simError();          
83          }
84 +        
85 +        RealType De = mit->getD();
86 +        RealType Re = mit->getR();
87 +        RealType beta = mit->getBeta();
88 +  
89 +        MorseType variant = mit->getInteractionType();
90 +        addExplicitInteraction(at1, at2, De, Re, beta, variant );
91        }
92      }  
93      initialized_ = true;
# Line 123 | Line 95 | namespace OpenMD {
95        
96    void Morse::addExplicitInteraction(AtomType* atype1, AtomType* atype2,
97                                       RealType De, RealType Re, RealType beta,
98 <                                     MorseInteractionType mit) {
98 >                                     MorseType mt) {
99  
100      MorseInteractionData mixer;
101      mixer.De = De;
102      mixer.Re = Re;
103      mixer.beta = beta;
104 <    mixer.interactionType = mit;
104 >    mixer.variant = mt;
105  
106      pair<AtomType*, AtomType*> key1, key2;
107      key1 = make_pair(atype1, atype2);
# Line 158 | Line 130 | namespace OpenMD {
130        RealType De = mixer.De;
131        RealType Re = mixer.Re;
132        RealType beta = mixer.beta;
133 <      MorseInteractionType interactionType = mixer.interactionType;
133 >      MorseType variant = mixer.variant;
134        
135        // V(r) = D_e exp(-a(r-re)(exp(-a(r-re))-2)
136        
# Line 177 | Line 149 | namespace OpenMD {
149        }
150        
151        
152 <      switch(interactionType) {
153 <      case shiftedMorse : {
152 >      switch(variant) {
153 >      case mtShifted : {
154          
155          myPot  = De * (expfnc2  - 2.0 * expfnc);
156          myDeriv   = 2.0 * De * beta * (expfnc - expfnc2);
# Line 197 | Line 169 | namespace OpenMD {
169          
170          break;
171        }
172 <      case repulsiveMorse : {
172 >      case mtRepulsive : {
173          
174          myPot  = De * expfnc2;
175          myDeriv  = -2.0 * De * beta * expfnc2;
# Line 216 | Line 188 | namespace OpenMD {
188          
189          break;
190        }
191 +      case mtUnknown: {
192 +        // don't know what to do so don't do anything
193 +        break;
194        }
195 +      }
196        
197        RealType pot_temp = *(idat.vdwMult) * (myPot - myPotC);
198        *(idat.vpair) += pot_temp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines