ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/brains/ForceField.cpp
(Generate patch)

Comparing trunk/src/UseTheForce/ForceField.cpp (file contents):
Revision 1269 by gezelter, Tue Jul 1 13:28:23 2008 UTC vs.
Revision 1282 by gezelter, Wed Jul 30 18:11:19 2008 UTC

# Line 124 | Line 124 | namespace oopse {
124            myKeys.push_back((*i)->getName());
125            myKeys.push_back((*j)->getName());
126  
127 +          std::cerr << "looking for " << myKeys[0] << " " << myKeys[1] << "\n";
128            BondType* bondType = bondTypeCont_.find(myKeys);
129            if (bondType) {
130              foundBonds.push_back(std::make_pair(bondTypeScore, myKeys));
# Line 133 | Line 134 | namespace oopse {
134          ii++;
135        }
136  
136      // sort the foundBonds by the score:
137  
138 <      std::sort(foundBonds.begin(), foundBonds.end());
139 <      
140 <      int bestScore = foundBonds[0].first;
141 <      std::vector<std::string> theKeys = foundBonds[0].second;
142 <
143 <      std::cout << "best matching bond = " << theKeys[0] << "\t" << theKeys[1]  << "\t(score = "<< bestScore << ")\n";      
144 <      BondType* bestType = bondTypeCont_.find(theKeys);
145 <      if (bestType)
146 <        return bestType;
147 <      else {
148 <        //if no exact match found, try wild card match
149 <        return bondTypeCont_.find(keys, wildCardAtomTypeName_);      
138 >      if (foundBonds.size() > 0) {
139 >        // sort the foundBonds by the score:
140 >        std::sort(foundBonds.begin(), foundBonds.end());
141 >    
142 >        int bestScore = foundBonds[0].first;
143 >        std::vector<std::string> theKeys = foundBonds[0].second;
144 >        
145 >        std::cout << "best matching bond = " << theKeys[0] << "\t" << theKeys[1]  << "\t(score = "<< bestScore << ")\n";      
146 >        BondType* bestType = bondTypeCont_.find(theKeys);
147 >        
148 >        return bestType;
149 >      } else {
150 >        //if no exact match found, try wild card match
151 >        return bondTypeCont_.find(keys, wildCardAtomTypeName_);      
152        }
153      }
154    }
# Line 220 | Line 222 | namespace oopse {
222          jj++;
223        }
224        
225 <      std::sort(foundBends.begin(), foundBends.end());
226 <
227 <      int jscore = foundBends[0].first;
228 <      int ikscore = foundBends[0].second;
229 <      std::vector<std::string> theKeys = foundBends[0].third;
230 <
231 <      std::cout << "best matching bend = " << theKeys[0] << "\t" <<theKeys[1]  << "\t" << theKeys[2] << "\t(scores = "<< jscore << "\t" << ikscore << ")\n";      
232 <
233 <      BendType* bestType = bendTypeCont_.find(theKeys);  
234 <      if (bestType)
235 <        return bestType;
234 <      else {
235 <      
225 >      if (foundBends.size() > 0) {
226 >        std::sort(foundBends.begin(), foundBends.end());
227 >        int jscore = foundBends[0].first;
228 >        int ikscore = foundBends[0].second;
229 >        std::vector<std::string> theKeys = foundBends[0].third;
230 >        
231 >        std::cout << "best matching bend = " << theKeys[0] << "\t" <<theKeys[1]  << "\t" << theKeys[2] << "\t(scores = "<< jscore << "\t" << ikscore << ")\n";      
232 >        
233 >        BendType* bestType = bendTypeCont_.find(theKeys);  
234 >        return bestType;
235 >      } else {        
236          //if no exact match found, try wild card match
237          return bendTypeCont_.find(keys, wildCardAtomTypeName_);      
238        }
239      }
240    }
241  
242
242    TorsionType* ForceField::getTorsionType(const std::string &at1,
243                                            const std::string &at2,
244                                            const std::string &at3,
# Line 327 | Line 326 | namespace oopse {
326          jj++;
327        }
328        
329 <      std::sort(foundTorsions.begin(), foundTorsions.end());
329 >      if (foundTorsions.size() > 0) {
330 >        std::sort(foundTorsions.begin(), foundTorsions.end());
331 >        int jkscore = foundTorsions[0].first;
332 >        int ilscore = foundTorsions[0].second;
333 >        std::vector<std::string> theKeys = foundTorsions[0].third;
334 >        
335 >        std::cout << "best matching torsion = " << theKeys[0] << "\t" <<theKeys[1]  << "\t" << theKeys[2] << "\t" << theKeys[3] << "\t(scores = "<< jkscore << "\t" << ilscore << ")\n";
336 >                
337 >        TorsionType* bestType = torsionTypeCont_.find(theKeys);
338 >        return bestType;
339 >      } else {
340 >        //if no exact match found, try wild card match
341 >        return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
342 >      }
343 >    }
344 >  }
345  
346 <      int jkscore = foundTorsions[0].first;
347 <      int ilscore = foundTorsions[0].second;
348 <      std::vector<std::string> theKeys = foundTorsions[0].third;
346 >  InversionType* ForceField::getInversionType(const std::string &at1,
347 >                                              const std::string &at2,
348 >                                              const std::string &at3,
349 >                                              const std::string &at4) {
350 >    std::vector<std::string> keys;
351 >    keys.push_back(at1);
352 >    keys.push_back(at2);    
353 >    keys.push_back(at3);    
354 >    keys.push_back(at4);    
355  
356 <      std::cout << "best matching torsion = " << theKeys[0] << "\t" <<theKeys[1]  << "\t" << theKeys[2] << "\t" << theKeys[3] << "\t(scores = "<< jkscore << "\t" << ilscore << ")\n";
356 >    //try exact match first
357 >    InversionType* inversionType = inversionTypeCont_.find(keys);
358 >    if (inversionType) {
359 >      return inversionType;
360 >    } else {
361 >      
362 >      AtomType* atype1;
363 >      AtomType* atype2;
364 >      AtomType* atype3;
365 >      AtomType* atype4;
366 >      std::vector<std::string> at1key;
367 >      at1key.push_back(at1);
368 >      atype1 = atomTypeCont_.find(at1key);
369 >      
370 >      std::vector<std::string> at2key;
371 >      at2key.push_back(at2);
372 >      atype2 = atomTypeCont_.find(at2key);
373 >      
374 >      std::vector<std::string> at3key;
375 >      at3key.push_back(at3);
376 >      atype3 = atomTypeCont_.find(at3key);
377 >      
378 >      std::vector<std::string> at4key;
379 >      at4key.push_back(at4);
380 >      atype4 = atomTypeCont_.find(at4key);
381  
382 +      // query atom types for their chains of responsibility
383 +      std::vector<AtomType*> at1Chain = atype1->allYourBase();
384 +      std::vector<AtomType*> at2Chain = atype2->allYourBase();
385 +      std::vector<AtomType*> at3Chain = atype3->allYourBase();
386 +      std::vector<AtomType*> at4Chain = atype4->allYourBase();
387 +
388 +      std::vector<AtomType*>::iterator i;
389 +      std::vector<AtomType*>::iterator j;
390 +      std::vector<AtomType*>::iterator k;
391 +      std::vector<AtomType*>::iterator l;
392 +
393 +      int ii = 0;
394 +      int jj = 0;
395 +      int kk = 0;
396 +      int ll = 0;
397 +      int Iscore;
398 +      int JKLscore;
399        
400 <      TorsionType* bestType = torsionTypeCont_.find(theKeys);
401 <      if (bestType) {
402 <        return bestType;
400 >      std::vector<tuple3<int, int, std::vector<std::string> > > foundInversions;
401 >      
402 >      for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
403 >        kk = 0;
404 >        for (k = at3Chain.begin(); k != at3Chain.end(); k++) {
405 >          ii = 0;      
406 >          for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
407 >            ll = 0;
408 >            for (l = at4Chain.begin(); l != at4Chain.end(); l++) {
409 >              
410 >              Iscore = ii;
411 >              JKLscore = jj + kk + ll;
412 >              
413 >              std::vector<std::string> myKeys;
414 >              myKeys.push_back((*i)->getName());
415 >              myKeys.push_back((*j)->getName());
416 >              myKeys.push_back((*k)->getName());
417 >              myKeys.push_back((*l)->getName());
418 >              
419 >              InversionType* inversionType = inversionTypeCont_.find(myKeys);
420 >              if (inversionType) {
421 >                foundInversions.push_back( make_tuple3(Iscore, JKLscore, myKeys) );
422 >              }
423 >              ll++;
424 >            }
425 >            ii++;
426 >          }
427 >          kk++;
428 >        }
429 >        jj++;
430 >      }
431 >        
432 >      if (foundInversions.size() > 0) {
433 >        std::sort(foundInversions.begin(), foundInversions.end());
434 >        int iscore = foundInversions[0].first;
435 >        int jklscore = foundInversions[0].second;
436 >        std::vector<std::string> theKeys = foundInversions[0].third;
437 >        
438 >        std::cout << "best matching inversion = " << theKeys[0] << "\t" <<theKeys[1]  << "\t" << theKeys[2] << "\t" << theKeys[3] << "\t(scores = "<< iscore << "\t" << jklscore << ")\n";
439 >                
440 >        InversionType* bestType = inversionTypeCont_.find(theKeys);
441 >        return bestType;
442        } else {
443          //if no exact match found, try wild card match
444 <        return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
444 >        return inversionTypeCont_.find(keys, wildCardAtomTypeName_);
445        }
446      }
447    }
448 <
448 >  
449    NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) {
450      std::vector<std::string> keys;
451      keys.push_back(at1);
# Line 390 | Line 490 | namespace oopse {
490      keys.push_back(at4);  
491      return torsionTypeCont_.find(keys);
492    }
493 <
493 >  
494 >  InversionType* ForceField::getExactInversionType(const std::string &at1,
495 >                                                   const std::string &at2,
496 >                                                   const std::string &at3,
497 >                                                   const std::string &at4){
498 >    std::vector<std::string> keys;
499 >    keys.push_back(at1);
500 >    keys.push_back(at2);    
501 >    keys.push_back(at3);    
502 >    keys.push_back(at4);  
503 >    return inversionTypeCont_.find(keys);
504 >  }
505 >  
506    NonBondedInteractionType* ForceField::getExactNonBondedInteractionType(const std::string &at1, const std::string &at2){
507      std::vector<std::string> keys;
508      keys.push_back(at1);
509      keys.push_back(at2);    
510      return nonBondedInteractionTypeCont_.find(keys);
511    }
512 +  
513  
401
514    bool ForceField::addAtomType(const std::string &at, AtomType* atomType) {
515      std::vector<std::string> keys;
516      keys.push_back(at);
517      return atomTypeCont_.add(keys, atomType);
518    }
519  
520 +  bool ForceField::replaceAtomType(const std::string &at, AtomType* atomType) {
521 +    std::vector<std::string> keys;
522 +    keys.push_back(at);
523 +    return atomTypeCont_.replace(keys, atomType);
524 +  }
525 +
526    bool ForceField::addBondType(const std::string &at1, const std::string &at2,
527                                 BondType* bondType) {
528      std::vector<std::string> keys;
# Line 435 | Line 553 | namespace oopse {
553      return torsionTypeCont_.add(keys, torsionType);
554    }
555  
556 +  bool ForceField::addInversionType(const std::string &at1,
557 +                                    const std::string &at2,
558 +                                    const std::string &at3,
559 +                                    const std::string &at4,
560 +                                    InversionType* inversionType) {
561 +    std::vector<std::string> keys;
562 +    keys.push_back(at1);
563 +    keys.push_back(at2);    
564 +    keys.push_back(at3);    
565 +    keys.push_back(at4);    
566 +    return inversionTypeCont_.add(keys, inversionType);
567 +  }
568 +  
569    bool ForceField::addNonBondedInteractionType(const std::string &at1,
570                                                 const std::string &at2,
571                                                 NonBondedInteractionType* nbiType) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines