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 1586 by gezelter, Tue Jun 21 06:34:35 2011 UTC vs.
Revision 1869 by gezelter, Tue Apr 30 17:03:03 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 53 | 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 <    
58 <    // Do sanity checking on the AtomType we were passed before
59 <    // building any data structures:
60 <    if (!atomType->isSC()) {
61 <      sprintf( painCave.errMsg,
62 <               "SC::getSCParam was passed an atomType (%s) that does not\n"
63 <               "\tappear to be a Sutton-Chen (SC) atom.\n",
64 <               atomType->getName().c_str());
65 <      painCave.severity = OPENMD_ERROR;
66 <      painCave.isFatal = 1;
67 <      simError();
68 <    }
69 <    
70 <    GenericData* data = atomType->getPropertyByName("SC");
71 <    if (data == NULL) {
72 <      sprintf( painCave.errMsg, "SC::getSCParam could not find SC\n"
73 <               "\tparameters for atomType %s.\n",
74 <               atomType->getName().c_str());
75 <      painCave.severity = OPENMD_ERROR;
76 <      painCave.isFatal = 1;
77 <      simError();
78 <    }
79 <    
80 <    SCParamGenericData* scData = dynamic_cast<SCParamGenericData*>(data);
81 <    if (scData == NULL) {
82 <      sprintf( painCave.errMsg,
83 <               "SC::getSCParam could not convert GenericData to SCParamGenericData\n"
84 <               "\tfor atom type %s\n", atomType->getName().c_str());
85 <      painCave.severity = OPENMD_ERROR;
86 <      painCave.isFatal = 1;
87 <      simError();          
88 <    }
89 <    
90 <    return scData->getData();
91 <  }
57 >  SC::~SC() {
58 >    initialized_ = false;
59  
60 <  RealType SC::getC(AtomType* atomType) {    
61 <    SCParam scParam = getSCParam(atomType);
62 <    return scParam.c;
60 >    MixingMap.clear();
61 >    SCMap.clear();
62 >    SClist.clear();
63    }
64 <
98 <  RealType SC::getM(AtomType* atomType) {    
99 <    SCParam scParam = getSCParam(atomType);
100 <    return scParam.m;
101 <  }
102 <
64 >        
65    RealType SC::getM(AtomType* atomType1, AtomType* atomType2) {    
66 <    RealType m1 = getM(atomType1);
67 <    RealType m2 = getM(atomType2);
66 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
67 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
68 >    RealType m1 = sca1.getM();
69 >    RealType m2 = sca2.getM();
70      return 0.5 * (m1 + m2);
71    }
72  
109  RealType SC::getN(AtomType* atomType) {    
110    SCParam scParam = getSCParam(atomType);
111    return scParam.n;
112  }
113
73    RealType SC::getN(AtomType* atomType1, AtomType* atomType2) {    
74 <    RealType n1 = getN(atomType1);
75 <    RealType n2 = getN(atomType2);
74 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
75 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
76 >    RealType n1 = sca1.getN();
77 >    RealType n2 = sca2.getN();
78      return 0.5 * (n1 + n2);
118  }
119
120  RealType SC::getAlpha(AtomType* atomType) {    
121    SCParam scParam = getSCParam(atomType);
122    return scParam.alpha;
79    }
80  
81    RealType SC::getAlpha(AtomType* atomType1, AtomType* atomType2) {    
82 <    RealType alpha1 = getAlpha(atomType1);
83 <    RealType alpha2 = getAlpha(atomType2);
82 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
83 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
84 >    RealType alpha1 = sca1.getAlpha();
85 >    RealType alpha2 = sca2.getAlpha();
86  
87      ForceFieldOptions& fopts = forceField_->getForceFieldOptions();
88      std::string DistanceMix = fopts.getDistanceMixingRule();
# Line 136 | Line 94 | namespace OpenMD {
94        return 0.5 * (alpha1 + alpha2);
95    }
96  
97 <  RealType SC::getEpsilon(AtomType* atomType) {    
98 <    SCParam scParam = getSCParam(atomType);
99 <    return scParam.epsilon;
100 <  }
101 <
144 <  RealType SC::getEpsilon(AtomType* atomType1, AtomType* atomType2) {    
145 <    RealType epsilon1 = getEpsilon(atomType1);
146 <    RealType epsilon2 = getEpsilon(atomType2);
97 >  RealType SC::getEpsilon(AtomType* atomType1, AtomType* atomType2) {  
98 >    SuttonChenAdapter sca1 = SuttonChenAdapter(atomType1);
99 >    SuttonChenAdapter sca2 = SuttonChenAdapter(atomType2);
100 >    RealType epsilon1 = sca1.getEpsilon();
101 >    RealType epsilon2 = sca2.getEpsilon();
102      return sqrt(epsilon1 * epsilon2);
103    }
104  
# Line 155 | Line 110 | namespace OpenMD {
110  
111      for (at = atomTypes->beginType(i); at != NULL;
112           at = atomTypes->nextType(i)) {
113 <      if (at->isSC())
113 >      SuttonChenAdapter sca = SuttonChenAdapter(at);
114 >      if (sca.isSuttonChen())
115          addType(at);
116      }    
117      initialized_ = true;
# Line 165 | Line 121 | namespace OpenMD {
121  
122    void SC::addType(AtomType* atomType){
123  
124 +    SuttonChenAdapter sca = SuttonChenAdapter(atomType);
125      SCAtomData scAtomData;
126      
127 <    scAtomData.c = getC(atomType);
128 <    scAtomData.m = getM(atomType);
129 <    scAtomData.n = getN(atomType);
130 <    scAtomData.alpha = getAlpha(atomType);
131 <    scAtomData.epsilon = getEpsilon(atomType);
127 >    scAtomData.c = sca.getC();
128 >    scAtomData.m = sca.getM();
129 >    scAtomData.n = sca.getN();
130 >    scAtomData.alpha = sca.getAlpha();
131 >    scAtomData.epsilon = sca.getEpsilon();
132      scAtomData.rCut = 2.0 * scAtomData.alpha;
133  
134      // add it to the map:
178    AtomTypeProperties atp = atomType->getATP();    
135  
136      pair<map<int,AtomType*>::iterator,bool> ret;    
137 <    ret = SClist.insert( pair<int, AtomType*>(atp.ident, atomType) );
137 >    ret = SClist.insert( pair<int, AtomType*>(atomType->getIdent(), atomType) );
138      if (ret.second == false) {
139        sprintf( painCave.errMsg,
140                 "SC already had a previous entry with ident %d\n",
141 <               atp.ident);
141 >               atomType->getIdent() );
142        painCave.severity = OPENMD_INFO;
143        painCave.isFatal = 0;
144        simError();        
# Line 330 | Line 286 | namespace OpenMD {
286      *(sdat.dfrhodrho) = 0.5 * *(sdat.frho) / *(sdat.rho);
287  
288      (*(sdat.pot))[METALLIC_FAMILY] += u;
289 <    *(sdat.particlePot) += u;
290 <    
289 >    if (sdat.doParticlePot) {
290 >      *(sdat.particlePot) += u;
291 >    }
292 >
293      return;
294    }
295    
# Line 367 | Line 325 | namespace OpenMD {
325        
326        *(idat.f1) += *(idat.d) * dudr / *(idat.rij) ;
327          
328 <      // particlePot is the difference between the full potential and
329 <      // the full potential without the presence of a particular
330 <      // particle (atom1).
331 <      //
332 <      // This reduces the density at other particle locations, so we
333 <      // need to recompute the density at atom2 assuming atom1 didn't
334 <      // contribute.  This then requires recomputing the density
335 <      // functional for atom2 as well.
336 <          
337 <      *(idat.particlePot1) -= data2.c * data2.epsilon *
338 <        sqrt( *(idat.rho2) - rhtmp) + *(idat.frho2);
328 >      if (idat.doParticlePot) {
329 >        // particlePot is the difference between the full potential and
330 >        // the full potential without the presence of a particular
331 >        // particle (atom1).
332 >        //
333 >        // This reduces the density at other particle locations, so we
334 >        // need to recompute the density at atom2 assuming atom1 didn't
335 >        // contribute.  This then requires recomputing the density
336 >        // functional for atom2 as well.
337 >        
338 >        *(idat.particlePot1) -= data2.c * data2.epsilon *
339 >          sqrt( *(idat.rho2) - rhtmp) + *(idat.frho2);
340  
341 <      *(idat.particlePot2) -= data1.c * data1.epsilon *
342 <        sqrt( *(idat.rho1) - rhtmp) + *(idat.frho1);
341 >        *(idat.particlePot2) -= data1.c * data1.epsilon *
342 >          sqrt( *(idat.rho1) - rhtmp) + *(idat.frho1);
343 >      }
344        
345        (*(idat.pot))[METALLIC_FAMILY] += pot_temp;
346      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines