ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/UseTheForce/ForceField.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-4/src/UseTheForce/ForceField.cpp (file contents):
Revision 1716, Fri Nov 5 21:04:13 2004 UTC vs.
Revision 1720 by tim, Sat Nov 6 05:21:55 2004 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project
3 + *
4 + * Contact: oopse@oopse.org
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU Lesser General Public License
8 + * as published by the Free Software Foundation; either version 2.1
9 + * of the License, or (at your option) any later version.
10 + * All we ask is that proper credit is given for our work, which includes
11 + * - but is not limited to - adding the above copyright notice to the beginning
12 + * of your source code files, and to any copyright notice that you may distribute
13 + * with programs based on this work.
14 + *
15 + * This program is distributed in the hope that it will be useful,
16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 + * GNU Lesser General Public License for more details.
19 + *
20 + * You should have received a copy of the GNU Lesser General Public License
21 + * along with this program; if not, write to the Free Software
22 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 + *
24 + */
25 +
26 + /**
27 +  * @file ForceField.cpp
28 +  * @author tlin
29 +  * @date 11/04/2004
30 +  * @time 22:51am
31 +  * @version 1.0
32 +  */
33 +  
34   #include "UseTheForce/ForceField.hpp"
35 + namespace oopse {
36  
37 < AtomType* ForceField::getMatchingAtomType(const string &at) {
37 > ForceField::ForceField() : hasVariant_(false){
38 >    char* tempPath;
39 >    tempPath = getenv("FORCE_PARAM_PATH");
40  
41 <  map<string, AtomType*>::iterator iter;
42 <  
43 <  iter = atomTypeMap.find(at);
44 <  if (iter != atomTypeMap.end()) {
45 <    return iter->second;
46 <  } else {
11 <    return NULL;
12 <  }
41 >    if (tempPath == NULL) {
42 >        //convert a macro from compiler to a string in c++
43 >        STR_DEFINE(ffPath_, FRC_PATH );
44 >    } else {
45 >        ffPath_ = tempPath;
46 >    }
47   }
48  
49 < BondType* ForceField::getMatchingBondType(const string &at1,
50 <                                          const string &at2) {
49 > AtomType* ForceField::getAtomType(const std::string &at) {
50 >    std::vector<std::string> keys;
51 >    keys.push_back(at);
52 >    return atomTypeCont_.find(keys);
53 > }
54  
55 <  map<pair<string,string>, BondType*>::iterator iter;
56 <  vector<BondType*> foundTypes;
55 > BondType* ForceField::getBondType(const std::string &at1, const std::string &at2) {
56 >    std::vector<std::string> keys;
57 >    keys.push_back(at1);
58 >    keys.push_back(at2);    
59 >    return bondTypeCont_.find(keys, wildCardAtomTypeName_);
60  
61 <  iter = bondTypeMap.find(pair<at1, at2>);
22 <  if (iter != bondTypeMap.end()) {
23 <    // exact match, so just return it
24 <    return iter->second;
25 <  }
61 > }
62  
63 <  iter = bondTypeMap.find(pair<at2, at1>);
64 <  if (iter != bondTypeMap.end()) {
65 <    // exact match in reverse order, so just return it
66 <    return iter->second;
67 <  }
63 > BendType* ForceField::getBendType(const std::string &at1, const std::string &at2,
64 >                        const std::string &at3) {
65 >    std::vector<std::string> keys;
66 >    keys.push_back(at1);
67 >    keys.push_back(at2);    
68 >    keys.push_back(at3);    
69 >    return bendTypeCont_.find(keys, wildCardAtomTypeName_);
70 > }
71  
72 <  iter = bondTypeMap.find(pair<at1, wildCardAtomTypeName>);
73 <  if (iter != bondTypeMap.end()) {
74 <    foundTypes.push_back(iter->second);
75 <  }
72 > TorsionType* ForceField::getTorsionType(const std::string &at1, const std::string &at2,
73 >                              const std::string &at3, const std::string &at4) {
74 >    std::vector<std::string> keys;
75 >    keys.push_back(at1);
76 >    keys.push_back(at2);    
77 >    keys.push_back(at3);    
78 >    keys.push_back(at4);    
79 >    return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
80  
81 <  iter = bondTypeMap.find(pair<at2, wildCardAtomTypeName>);
39 <  if (iter != bondTypeMap.end()) {
40 <    foundTypes.push_back(iter->second);
41 <  }
81 > }
82  
83 <  iter = bondTypeMap.find(pair<wildCardAtomTypeName, at1>);
84 <  if (iter != bondTypeMap.end()) {
85 <    foundTypes.push_back(iter->second);
86 <  }
83 > void ForceField::addAtomType(const std::string &at, AtomType* atomType) {
84 >    std::vector<std::string> keys;
85 >    keys.push_back(at);
86 >    return atomTypeCont_.add(keys);
87 > }
88  
89 <  iter = bondTypeMap.find(pair<wildCardAtomTypeName, at2>);
90 <  if (iter != bondTypeMap.end()) {
91 <    foundTypes.push_back(iter->second);
92 <  }
93 <  
53 <  if (foundTypes.empty()) {
54 <    return NULL;
55 <  } else {
56 <    
89 > void ForceField::addBondType(const std::string &at1, const std::string &at2, BondType* bondType) {
90 >    std::vector<std::string> keys;
91 >    keys.push_back(at1);
92 >    keys.push_back(at2);    
93 >    return bondTypeCont_.add(keys);
94  
95 <
95 > }
96  
97 + void ForceField::addBendType(const std::string &at1, const std::string &at2,
98 +                        const std::string &at3, BendType* bendType) {
99 +    std::vector<std::string> keys;
100 +    keys.push_back(at1);
101 +    keys.push_back(at2);    
102 +    keys.push_back(at3);    
103 +    return bendTypeCont_.add(keys);
104 + }
105  
106 + void ForceField::addTorsionType(const std::string &at1, const std::string &at2,
107 +                              const std::string &at3, const std::string &at4, TorsionType* torsionType) {
108 +    std::vector<std::string> keys;
109 +    keys.push_back(at1);
110 +    keys.push_back(at2);    
111 +    keys.push_back(at3);    
112 +    keys.push_back(at4);    
113 +    return torsionTypeCont_.add(keys);
114 + }
115  
116 <  
116 > double ForceField::getRcutForAtomType(AtomType* at) {
117  
118 + }
119  
120 < BendType* ForceField::getMatchingBendType(const string &at1, const string &at2,
66 <                                          const string &at3);
67 < TorsionType* ForceField::getMatchingTorsionType(const string &at1, const string &at2,
68 <                                                const string &at3, const string &at4);
69 <
70 < double ForceField::getRcutForAtomType(AtomType* at);
71 <
72 <
73 < vector<vector<string> > generateWildcardSequence(const vector<string> atomTypes) {
74 <  
75 <   vector<vector<string> > results;
76 <
77 <  
78 <
79 <
80 <   vector<vector< string> > getAllWildcardPermutations(const vector<string> myAts) {
81 <    
82 <     int nStrings;
83 <     vector<string> oneResult;
84 <     vector<vector<string> > allResults;
85 <
86 <     nStrings = myAts.size();
87 <
88 <     if (nStrings == 1) {
89 <       oneResult.push_back(wildcardCharacter);
90 <       allResults.push_back(oneResult);
91 <       return allResults;
92 <     } else {
93 <      
94 <       for (i=0; i < nStrings; i++) {
95 <         oneResult = myAts;
96 <         replace(oneResult.begin(), oneResult.end(),
120 > } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines