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

Comparing branches/development/src/nonbonded/SC.cpp (file contents):
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1868 by gezelter, Tue Apr 30 15:56:54 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).          
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   */
# Line 54 | Line 54 | namespace OpenMD {
54    SC::SC() : name_("SC"), initialized_(false), forceField_(NULL),
55               scRcut_(0.0), np_(3000) {}
56    
57 <  SCParam SC::getSCParam(AtomType* atomType) {
58 <    
59 <    // Do sanity checking on the AtomType we were passed before
60 <    // building any data structures:
61 <    if (!atomType->isSC()) {
62 <      sprintf( painCave.errMsg,
63 <               "SC::getSCParam was passed an atomType (%s) that does not\n"
64 <               "\tappear to be a Sutton-Chen (SC) atom.\n",
65 <               atomType->getName().c_str());
66 <      painCave.severity = OPENMD_ERROR;
67 <      painCave.isFatal = 1;
68 <      simError();
57 >  SC::~SC() {
58 >    initialized_ = false;
59 >
60 >    map<pair<AtomType*, AtomType*>, SCInteractionData>::iterator it;
61 >    for (it = MixingMap.begin(); it != MixingMap.end(); ++it) {
62 >      SCInteractionData mixer = (*it).second;
63 >      delete mixer.V;
64 >      delete mixer.phi;
65      }
70    
71    GenericData* data = atomType->getPropertyByName("SC");
72    if (data == NULL) {
73      sprintf( painCave.errMsg, "SC::getSCParam could not find SC\n"
74               "\tparameters for atomType %s.\n",
75               atomType->getName().c_str());
76      painCave.severity = OPENMD_ERROR;
77      painCave.isFatal = 1;
78      simError();
79    }
80    
81    SCParamGenericData* scData = dynamic_cast<SCParamGenericData*>(data);
82    if (scData == NULL) {
83      sprintf( painCave.errMsg,
84               "SC::getSCParam could not convert GenericData to SCParamGenericData\n"
85               "\tfor atom type %s\n", atomType->getName().c_str());
86      painCave.severity = OPENMD_ERROR;
87      painCave.isFatal = 1;
88      simError();          
89    }
90    
91    return scData->getData();
92  }
66  
67 <  RealType SC::getC(AtomType* atomType) {    
68 <    SCParam scParam = getSCParam(atomType);
69 <    return scParam.c;
67 >    MixingMap.clear();
68 >    SCMap.clear();
69 >    SClist.clear();
70    }
71 <
99 <  RealType SC::getM(AtomType* atomType) {    
100 <    SCParam scParam = getSCParam(atomType);
101 <    return scParam.m;
102 <  }
103 <
71 >        
72    RealType SC::getM(AtomType* atomType1, AtomType* atomType2) {    
73 <    RealType m1 = getM(atomType1);
74 <    RealType m2 = getM(atomType2);
73 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
74 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
75 >    RealType m1 = sca1.getM();
76 >    RealType m2 = sca2.getM();
77      return 0.5 * (m1 + m2);
78    }
79  
110  RealType SC::getN(AtomType* atomType) {    
111    SCParam scParam = getSCParam(atomType);
112    return scParam.n;
113  }
114
80    RealType SC::getN(AtomType* atomType1, AtomType* atomType2) {    
81 <    RealType n1 = getN(atomType1);
82 <    RealType n2 = getN(atomType2);
81 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
82 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
83 >    RealType n1 = sca1.getN();
84 >    RealType n2 = sca2.getN();
85      return 0.5 * (n1 + n2);
119  }
120
121  RealType SC::getAlpha(AtomType* atomType) {    
122    SCParam scParam = getSCParam(atomType);
123    return scParam.alpha;
86    }
87  
88    RealType SC::getAlpha(AtomType* atomType1, AtomType* atomType2) {    
89 <    RealType alpha1 = getAlpha(atomType1);
90 <    RealType alpha2 = getAlpha(atomType2);
89 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
90 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
91 >    RealType alpha1 = sca1.getAlpha();
92 >    RealType alpha2 = sca2.getAlpha();
93  
94      ForceFieldOptions& fopts = forceField_->getForceFieldOptions();
95      std::string DistanceMix = fopts.getDistanceMixingRule();
# Line 137 | Line 101 | namespace OpenMD {
101        return 0.5 * (alpha1 + alpha2);
102    }
103  
104 <  RealType SC::getEpsilon(AtomType* atomType) {    
105 <    SCParam scParam = getSCParam(atomType);
106 <    return scParam.epsilon;
107 <  }
108 <
145 <  RealType SC::getEpsilon(AtomType* atomType1, AtomType* atomType2) {    
146 <    RealType epsilon1 = getEpsilon(atomType1);
147 <    RealType epsilon2 = getEpsilon(atomType2);
104 >  RealType SC::getEpsilon(AtomType* atomType1, AtomType* atomType2) {  
105 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
106 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
107 >    RealType epsilon1 = sca1.getEpsilon();
108 >    RealType epsilon2 = sca2.getEpsilon();
109      return sqrt(epsilon1 * epsilon2);
110    }
111  
# Line 156 | Line 117 | namespace OpenMD {
117  
118      for (at = atomTypes->beginType(i); at != NULL;
119           at = atomTypes->nextType(i)) {
120 <      if (at->isSC())
120 >      SuttonChenAdapter sca = SuttonChenAdapter(at);
121 >      if (sca.isSuttonChen())
122          addType(at);
123      }    
124      initialized_ = true;
# Line 166 | Line 128 | namespace OpenMD {
128  
129    void SC::addType(AtomType* atomType){
130  
131 +    SuttonChenAdapter sca = SuttonChenAdapter(atomType);
132      SCAtomData scAtomData;
133      
134 <    scAtomData.c = getC(atomType);
135 <    scAtomData.m = getM(atomType);
136 <    scAtomData.n = getN(atomType);
137 <    scAtomData.alpha = getAlpha(atomType);
138 <    scAtomData.epsilon = getEpsilon(atomType);
134 >    scAtomData.c = sca.getC();
135 >    scAtomData.m = sca.getM();
136 >    scAtomData.n = sca.getN();
137 >    scAtomData.alpha = sca.getAlpha();
138 >    scAtomData.epsilon = sca.getEpsilon();
139      scAtomData.rCut = 2.0 * scAtomData.alpha;
140  
141      // add it to the map:
179    AtomTypeProperties atp = atomType->getATP();    
142  
143      pair<map<int,AtomType*>::iterator,bool> ret;    
144 <    ret = SClist.insert( pair<int, AtomType*>(atp.ident, atomType) );
144 >    ret = SClist.insert( pair<int, AtomType*>(atomType->getIdent(), atomType) );
145      if (ret.second == false) {
146        sprintf( painCave.errMsg,
147                 "SC already had a previous entry with ident %d\n",
148 <               atp.ident);
148 >               atomType->getIdent() );
149        painCave.severity = OPENMD_INFO;
150        painCave.isFatal = 0;
151        simError();        
# Line 331 | Line 293 | namespace OpenMD {
293      *(sdat.dfrhodrho) = 0.5 * *(sdat.frho) / *(sdat.rho);
294  
295      (*(sdat.pot))[METALLIC_FAMILY] += u;
296 <    *(sdat.particlePot) += u;
297 <    
296 >    if (sdat.doParticlePot) {
297 >      *(sdat.particlePot) += u;
298 >    }
299 >
300      return;
301    }
302    
# Line 368 | Line 332 | namespace OpenMD {
332        
333        *(idat.f1) += *(idat.d) * dudr / *(idat.rij) ;
334          
335 <      // particlePot is the difference between the full potential and
336 <      // the full potential without the presence of a particular
337 <      // particle (atom1).
338 <      //
339 <      // This reduces the density at other particle locations, so we
340 <      // need to recompute the density at atom2 assuming atom1 didn't
341 <      // contribute.  This then requires recomputing the density
342 <      // functional for atom2 as well.
343 <          
344 <      *(idat.particlePot1) -= data2.c * data2.epsilon *
345 <        sqrt( *(idat.rho2) - rhtmp) + *(idat.frho2);
335 >      if (idat.doParticlePot) {
336 >        // particlePot is the difference between the full potential and
337 >        // the full potential without the presence of a particular
338 >        // particle (atom1).
339 >        //
340 >        // This reduces the density at other particle locations, so we
341 >        // need to recompute the density at atom2 assuming atom1 didn't
342 >        // contribute.  This then requires recomputing the density
343 >        // functional for atom2 as well.
344 >        
345 >        *(idat.particlePot1) -= data2.c * data2.epsilon *
346 >          sqrt( *(idat.rho2) - rhtmp) + *(idat.frho2);
347  
348 <      *(idat.particlePot2) -= data1.c * data1.epsilon *
349 <        sqrt( *(idat.rho1) - rhtmp) + *(idat.frho1);
348 >        *(idat.particlePot2) -= data1.c * data1.epsilon *
349 >          sqrt( *(idat.rho1) - rhtmp) + *(idat.frho1);
350 >      }
351        
352        (*(idat.pot))[METALLIC_FAMILY] += pot_temp;
353      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines