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

Comparing trunk/src/UseTheForce/ForceField.cpp (file contents):
Revision 1289 by cli2, Wed Sep 10 19:40:06 2008 UTC vs.
Revision 1604 by jmichalk, Mon Aug 8 18:53:40 2011 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
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).                        
40   */
41  
42   /**
# Line 54 | Line 54
54   #include "UseTheForce/DarkSide/atype_interface.h"
55   #include "UseTheForce/DarkSide/fForceOptions_interface.h"
56   #include "UseTheForce/DarkSide/switcheroo_interface.h"
57 < namespace oopse {
57 > namespace OpenMD {
58  
59    ForceField::ForceField() {
60 +
61      char* tempPath;
62      tempPath = getenv("FORCE_PARAM_PATH");
63 <
63 >    
64      if (tempPath == NULL) {
65        //convert a macro from compiler to a string in c++
66        STR_DEFINE(ffPath_, FRC_PATH );
# Line 348 | Line 349 | namespace oopse {
349      keys.push_back(at4);    
350  
351      //try exact match first
352 <    InversionType* inversionType = inversionTypeCont_.find(keys);
352 >    InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(keys);
353      if (inversionType) {
354        return inversionType;
355      } else {
# Line 410 | Line 411 | namespace oopse {
411                myKeys.push_back((*k)->getName());
412                myKeys.push_back((*l)->getName());
413                
414 <              InversionType* inversionType = inversionTypeCont_.find(myKeys);
414 >              InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(myKeys);
415                if (inversionType) {
416                  foundInversions.push_back( make_tuple3(Iscore, JKLscore, myKeys) );
417                }
# Line 429 | Line 430 | namespace oopse {
430          int jklscore = foundInversions[0].second;
431          std::vector<std::string> theKeys = foundInversions[0].third;
432          
433 <        InversionType* bestType = inversionTypeCont_.find(theKeys);
433 >        InversionType* bestType = inversionTypeCont_.permutedFindSkippingFirstElement(theKeys);
434          return bestType;
435        } else {
436          //if no exact match found, try wild card match
# Line 439 | Line 440 | namespace oopse {
440    }
441    
442    NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) {
443 +
444      std::vector<std::string> keys;
445      keys.push_back(at1);
446      keys.push_back(at2);    
# Line 448 | Line 450 | namespace oopse {
450      if (nbiType) {
451        return nbiType;
452      } else {
453 <      //if no exact match found, try wild card match
454 <      return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);
455 <    }    
453 >      AtomType* atype1;
454 >      AtomType* atype2;
455 >      std::vector<std::string> at1key;
456 >      at1key.push_back(at1);
457 >      atype1 = atomTypeCont_.find(at1key);
458 >  
459 >      std::vector<std::string> at2key;
460 >      at2key.push_back(at2);
461 >      atype2 = atomTypeCont_.find(at2key);
462 >
463 >      // query atom types for their chains of responsibility
464 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
465 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
466 >
467 >      std::vector<AtomType*>::iterator i;
468 >      std::vector<AtomType*>::iterator j;
469 >
470 >      int ii = 0;
471 >      int jj = 0;
472 >      int nbiTypeScore;
473 >
474 >      std::vector<std::pair<int, std::vector<std::string> > > foundNBI;
475 >
476 >      for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
477 >        jj = 0;
478 >        for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
479 >
480 >          nbiTypeScore = ii + jj;
481 >
482 >          std::vector<std::string> myKeys;
483 >          myKeys.push_back((*i)->getName());
484 >          myKeys.push_back((*j)->getName());
485 >
486 >          NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(myKeys);
487 >          if (nbiType) {
488 >            foundNBI.push_back(std::make_pair(nbiTypeScore, myKeys));
489 >          }
490 >          jj++;
491 >        }
492 >        ii++;
493 >      }
494 >
495 >
496 >      if (foundNBI.size() > 0) {
497 >        // sort the foundNBI by the score:
498 >        std::sort(foundNBI.begin(), foundNBI.end());
499 >    
500 >        int bestScore = foundNBI[0].first;
501 >        std::vector<std::string> theKeys = foundNBI[0].second;
502 >        
503 >        NonBondedInteractionType* bestType = nonBondedInteractionTypeCont_.find(theKeys);        
504 >        return bestType;
505 >      } else {
506 >         //if no exact match found, try wild card match
507 >        return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);
508 >      }
509 >    }
510    }
511    
512    BondType* ForceField::getExactBondType(const std::string &at1,
# Line 586 | Line 642 | namespace oopse {
642          } else {
643            sprintf( painCave.errMsg,
644                     "Can not cast GenericData to LJParam\n");
645 <          painCave.severity = OOPSE_ERROR;
645 >          painCave.severity = OPENMD_ERROR;
646            painCave.isFatal = 1;
647            simError();          
648          }            
649        } else {
650          sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
651 <        painCave.severity = OOPSE_ERROR;
651 >        painCave.severity = OPENMD_ERROR;
652          painCave.isFatal = 1;
653          simError();          
654        }
# Line 622 | Line 678 | namespace oopse {
678                   "\tHave you tried setting the FORCE_PARAM_PATH environment "
679                   "variable?\n",
680                   forceFieldFilename.c_str() );
681 <        painCave.severity = OOPSE_ERROR;
681 >        painCave.severity = OPENMD_ERROR;
682          painCave.isFatal = 1;
683          simError();
684        }
# Line 635 | Line 691 | namespace oopse {
691      forceFieldOptions_.makeFortranOptions(theseFortranOptions);
692      setfForceOptions(&theseFortranOptions);
693    }
694 < } //end namespace oopse
694 > } //end namespace OpenMD

Comparing trunk/src/UseTheForce/ForceField.cpp (property svn:keywords):
Revision 1289 by cli2, Wed Sep 10 19:40:06 2008 UTC vs.
Revision 1604 by jmichalk, Mon Aug 8 18:53:40 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines