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 206 by gezelter, Thu Nov 4 20:51:23 2004 UTC vs.
branches/heatflux/src/UseTheForce/ForceField.cpp (file contents), Revision 1670 by chuckv, Fri Jan 27 19:07:19 2012 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + *
4 + * The University of Notre Dame grants you ("Licensee") a
5 + * non-exclusive, royalty free, license to use, modify and
6 + * redistribute this software in source and binary code form, provided
7 + * that the following conditions are met:
8 + *
9 + * 1. Redistributions of source code must retain the above copyright
10 + *    notice, this list of conditions and the following disclaimer.
11 + *
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.
16 + *
17 + * This software is provided "AS IS," without a warranty of any
18 + * kind. All express or implied conditions, representations and
19 + * warranties, including any implied warranty of merchantability,
20 + * fitness for a particular purpose or non-infringement, are hereby
21 + * excluded.  The University of Notre Dame and its licensors shall not
22 + * be liable for any damages suffered by licensee as a result of
23 + * using, modifying or distributing the software or its
24 + * derivatives. In no event will the University of Notre Dame or its
25 + * licensors be liable for any lost revenue, profit or data, or for
26 + * direct, indirect, special, consequential, incidental or punitive
27 + * damages, however caused and regardless of the theory of liability,
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 + /**
43 + * @file ForceField.cpp
44 + * @author tlin
45 + * @date 11/04/2004
46 + * @time 22:51am
47 + * @version 1.0
48 + */
49 +  
50 + #include <algorithm>
51   #include "UseTheForce/ForceField.hpp"
52 + #include "utils/simError.h"
53 + #include "utils/Tuple.hpp"
54 + #include "UseTheForce/DarkSide/atype_interface.h"
55 + #include "UseTheForce/DarkSide/fForceOptions_interface.h"
56 + #include "UseTheForce/DarkSide/switcheroo_interface.h"
57 + namespace OpenMD {
58  
59 < AtomType* ForceField::getMatchingAtomType(const string &at) {
59 >  ForceField::ForceField() {
60  
61 <  map<string, AtomType*>::iterator iter;
62 <  
63 <  iter = atomTypeMap.find(at);
64 <  if (iter != atomTypeMap.end()) {
65 <    return iter->second;
66 <  } else {
67 <    return NULL;
61 >    char* tempPath;
62 >    tempPath = getenv("FORCE_PARAM_PATH");
63 >    
64 >    if (tempPath == NULL) {
65 >      //convert a macro from compiler to a string in c++
66 >      STR_DEFINE(ffPath_, FRC_PATH );
67 >    } else {
68 >      ffPath_ = tempPath;
69 >    }
70    }
13 }
71  
15 BondType* ForceField::getMatchingBondType(const string &at1,
16                                          const string &at2) {
72  
73 <  map<pair<string,string>, BondType*>::iterator iter;
74 <  vector<BondType*> foundTypes;
73 >  ForceField::~ForceField() {
74 >    deleteAtypes();
75 >    deleteSwitch();
76 >  }
77  
78 <  iter = bondTypeMap.find(pair<at1, at2>);
79 <  if (iter != bondTypeMap.end()) {
80 <    // exact match, so just return it
81 <    return iter->second;
82 <  }
78 >  AtomType* ForceField::getAtomType(const std::string &at) {
79 >    std::vector<std::string> keys;
80 >    keys.push_back(at);
81 >    return atomTypeCont_.find(keys);
82 >  }
83  
84 <  iter = bondTypeMap.find(pair<at2, at1>);
85 <  if (iter != bondTypeMap.end()) {
86 <    // exact match in reverse order, so just return it
87 <    return iter->second;
88 <  }
84 >  BondType* ForceField::getBondType(const std::string &at1,
85 >                                    const std::string &at2) {
86 >    std::vector<std::string> keys;
87 >    keys.push_back(at1);
88 >    keys.push_back(at2);    
89  
90 <  iter = bondTypeMap.find(pair<at1, wildCardAtomTypeName>);
91 <  if (iter != bondTypeMap.end()) {
92 <    foundTypes.push_back(iter->second);
93 <  }
90 >    //try exact match first
91 >    BondType* bondType = bondTypeCont_.find(keys);
92 >    if (bondType) {
93 >      return bondType;
94 >    } else {
95 >      AtomType* atype1;
96 >      AtomType* atype2;
97 >      std::vector<std::string> at1key;
98 >      at1key.push_back(at1);
99 >      atype1 = atomTypeCont_.find(at1key);
100 >  
101 >      std::vector<std::string> at2key;
102 >      at2key.push_back(at2);
103 >      atype2 = atomTypeCont_.find(at2key);
104  
105 <  iter = bondTypeMap.find(pair<at2, wildCardAtomTypeName>);
106 <  if (iter != bondTypeMap.end()) {
107 <    foundTypes.push_back(iter->second);
41 <  }
105 >      // query atom types for their chains of responsibility
106 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
107 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
108  
109 <  iter = bondTypeMap.find(pair<wildCardAtomTypeName, at1>);
110 <  if (iter != bondTypeMap.end()) {
45 <    foundTypes.push_back(iter->second);
46 <  }
109 >      std::vector<AtomType*>::iterator i;
110 >      std::vector<AtomType*>::iterator j;
111  
112 <  iter = bondTypeMap.find(pair<wildCardAtomTypeName, at2>);
113 <  if (iter != bondTypeMap.end()) {
114 <    foundTypes.push_back(iter->second);
112 >      int ii = 0;
113 >      int jj = 0;
114 >      int bondTypeScore;
115 >
116 >      std::vector<std::pair<int, std::vector<std::string> > > foundBonds;
117 >
118 >      for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
119 >        jj = 0;
120 >        for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
121 >
122 >          bondTypeScore = ii + jj;
123 >
124 >          std::vector<std::string> myKeys;
125 >          myKeys.push_back((*i)->getName());
126 >          myKeys.push_back((*j)->getName());
127 >
128 >          BondType* bondType = bondTypeCont_.find(myKeys);
129 >          if (bondType) {
130 >            foundBonds.push_back(std::make_pair(bondTypeScore, myKeys));
131 >          }
132 >          jj++;
133 >        }
134 >        ii++;
135 >      }
136 >
137 >
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 >        BondType* bestType = bondTypeCont_.find(theKeys);
146 >        
147 >        return bestType;
148 >      } else {
149 >        //if no exact match found, try wild card match
150 >        return bondTypeCont_.find(keys, wildCardAtomTypeName_);      
151 >      }
152 >    }
153    }
154    
155 <  if (foundTypes.empty()) {
156 <    return NULL;
157 <  } else {
158 <    
155 >  BendType* ForceField::getBendType(const std::string &at1,
156 >                                    const std::string &at2,
157 >                                    const std::string &at3) {
158 >    std::vector<std::string> keys;
159 >    keys.push_back(at1);
160 >    keys.push_back(at2);    
161 >    keys.push_back(at3);    
162  
163 <
163 >    //try exact match first
164 >    BendType* bendType = bendTypeCont_.find(keys);
165 >    if (bendType) {
166 >      return bendType;
167 >    } else {
168  
169 +      AtomType* atype1;
170 +      AtomType* atype2;
171 +      AtomType* atype3;
172 +      std::vector<std::string> at1key;
173 +      at1key.push_back(at1);
174 +      atype1 = atomTypeCont_.find(at1key);
175 +  
176 +      std::vector<std::string> at2key;
177 +      at2key.push_back(at2);
178 +      atype2 = atomTypeCont_.find(at2key);
179  
180 +      std::vector<std::string> at3key;
181 +      at3key.push_back(at3);
182 +      atype3 = atomTypeCont_.find(at3key);
183  
184 +      // query atom types for their chains of responsibility
185 +      std::vector<AtomType*> at1Chain = atype1->allYourBase();
186 +      std::vector<AtomType*> at2Chain = atype2->allYourBase();
187 +      std::vector<AtomType*> at3Chain = atype3->allYourBase();
188 +
189 +      std::vector<AtomType*>::iterator i;
190 +      std::vector<AtomType*>::iterator j;
191 +      std::vector<AtomType*>::iterator k;
192 +
193 +      int ii = 0;
194 +      int jj = 0;
195 +      int kk = 0;
196 +      int IKscore;
197 +
198 +      std::vector<tuple3<int, int, std::vector<std::string> > > foundBends;
199 +
200 +      for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
201 +        ii = 0;
202 +        for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
203 +          kk = 0;
204 +          for (k = at3Chain.begin(); k != at3Chain.end(); k++) {
205 +          
206 +            IKscore = ii + kk;
207 +
208 +            std::vector<std::string> myKeys;
209 +            myKeys.push_back((*i)->getName());
210 +            myKeys.push_back((*j)->getName());
211 +            myKeys.push_back((*k)->getName());
212 +
213 +            BendType* bendType = bendTypeCont_.find(myKeys);
214 +            if (bendType) {
215 +              foundBends.push_back( make_tuple3(jj, IKscore, myKeys) );
216 +            }
217 +            kk++;
218 +          }
219 +          ii++;
220 +        }
221 +        jj++;
222 +      }
223 +      
224 +      if (foundBends.size() > 0) {
225 +        std::sort(foundBends.begin(), foundBends.end());
226 +        int jscore = foundBends[0].first;
227 +        int ikscore = foundBends[0].second;
228 +        std::vector<std::string> theKeys = foundBends[0].third;      
229 +        
230 +        BendType* bestType = bendTypeCont_.find(theKeys);  
231 +        return bestType;
232 +      } else {        
233 +        //if no exact match found, try wild card match
234 +        return bendTypeCont_.find(keys, wildCardAtomTypeName_);      
235 +      }
236 +    }
237 +  }
238 +
239 +  TorsionType* ForceField::getTorsionType(const std::string &at1,
240 +                                          const std::string &at2,
241 +                                          const std::string &at3,
242 +                                          const std::string &at4) {
243 +    std::vector<std::string> keys;
244 +    keys.push_back(at1);
245 +    keys.push_back(at2);    
246 +    keys.push_back(at3);    
247 +    keys.push_back(at4);    
248 +
249 +
250 +    //try exact match first
251 +    TorsionType* torsionType = torsionTypeCont_.find(keys);
252 +    if (torsionType) {
253 +      return torsionType;
254 +    } else {
255 +
256 +      AtomType* atype1;
257 +      AtomType* atype2;
258 +      AtomType* atype3;
259 +      AtomType* atype4;
260 +      std::vector<std::string> at1key;
261 +      at1key.push_back(at1);
262 +      atype1 = atomTypeCont_.find(at1key);
263    
264 +      std::vector<std::string> at2key;
265 +      at2key.push_back(at2);
266 +      atype2 = atomTypeCont_.find(at2key);
267  
268 +      std::vector<std::string> at3key;
269 +      at3key.push_back(at3);
270 +      atype3 = atomTypeCont_.find(at3key);
271  
272 < BendType* ForceField::getMatchingBendType(const string &at1, const string &at2,
273 <                                          const string &at3);
274 < TorsionType* ForceField::getMatchingTorsionType(const string &at1, const string &at2,
68 <                                                const string &at3, const string &at4);
272 >      std::vector<std::string> at4key;
273 >      at4key.push_back(at4);
274 >      atype4 = atomTypeCont_.find(at4key);
275  
276 < double ForceField::getRcutForAtomType(AtomType* at);
276 >      // query atom types for their chains of responsibility
277 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
278 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
279 >      std::vector<AtomType*> at3Chain = atype3->allYourBase();
280 >      std::vector<AtomType*> at4Chain = atype4->allYourBase();
281  
282 +      std::vector<AtomType*>::iterator i;
283 +      std::vector<AtomType*>::iterator j;
284 +      std::vector<AtomType*>::iterator k;
285 +      std::vector<AtomType*>::iterator l;
286  
287 < vector<vector<string> > generateWildcardSequence(const vector<string> atomTypes) {
288 <  
289 <   vector<vector<string> > results;
287 >      int ii = 0;
288 >      int jj = 0;
289 >      int kk = 0;
290 >      int ll = 0;
291 >      int ILscore;
292 >      int JKscore;
293  
294 <  
294 >      std::vector<tuple3<int, int, std::vector<std::string> > > foundTorsions;
295  
296 +      for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
297 +        kk = 0;
298 +        for (k = at3Chain.begin(); k != at3Chain.end(); k++) {
299 +          ii = 0;      
300 +          for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
301 +            ll = 0;
302 +            for (l = at4Chain.begin(); l != at4Chain.end(); l++) {
303 +          
304 +              ILscore = ii + ll;
305 +              JKscore = jj + kk;
306  
307 <   vector<vector< string> > getAllWildcardPermutations(const vector<string> myAts) {
308 <    
309 <     int nStrings;
310 <     vector<string> oneResult;
311 <     vector<vector<string> > allResults;
307 >              std::vector<std::string> myKeys;
308 >              myKeys.push_back((*i)->getName());
309 >              myKeys.push_back((*j)->getName());
310 >              myKeys.push_back((*k)->getName());
311 >              myKeys.push_back((*l)->getName());
312  
313 <     nStrings = myAts.size();
313 >              TorsionType* torsionType = torsionTypeCont_.find(myKeys);
314 >              if (torsionType) {
315 >                foundTorsions.push_back( make_tuple3(JKscore, ILscore, myKeys) );
316 >              }
317 >              ll++;
318 >            }
319 >            ii++;
320 >          }
321 >          kk++;
322 >        }
323 >        jj++;
324 >      }
325 >      
326 >      if (foundTorsions.size() > 0) {
327 >        std::sort(foundTorsions.begin(), foundTorsions.end());
328 >        int jkscore = foundTorsions[0].first;
329 >        int ilscore = foundTorsions[0].second;
330 >        std::vector<std::string> theKeys = foundTorsions[0].third;
331 >        
332 >        TorsionType* bestType = torsionTypeCont_.find(theKeys);
333 >        return bestType;
334 >      } else {
335 >        //if no exact match found, try wild card match
336 >        return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
337 >      }
338 >    }
339 >  }
340  
341 <     if (nStrings == 1) {
342 <       oneResult.push_back(wildcardCharacter);
343 <       allResults.push_back(oneResult);
344 <       return allResults;
345 <     } else {
346 <      
347 <       for (i=0; i < nStrings; i++) {
348 <         oneResult = myAts;
349 <         replace(oneResult.begin(), oneResult.end(),
341 >  InversionType* ForceField::getInversionType(const std::string &at1,
342 >                                              const std::string &at2,
343 >                                              const std::string &at3,
344 >                                              const std::string &at4) {
345 >    std::vector<std::string> keys;
346 >    keys.push_back(at1);
347 >    keys.push_back(at2);    
348 >    keys.push_back(at3);    
349 >    keys.push_back(at4);    
350 >
351 >    //try exact match first
352 >    InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(keys);
353 >    if (inversionType) {
354 >      return inversionType;
355 >    } else {
356 >      
357 >      AtomType* atype1;
358 >      AtomType* atype2;
359 >      AtomType* atype3;
360 >      AtomType* atype4;
361 >      std::vector<std::string> at1key;
362 >      at1key.push_back(at1);
363 >      atype1 = atomTypeCont_.find(at1key);
364 >      
365 >      std::vector<std::string> at2key;
366 >      at2key.push_back(at2);
367 >      atype2 = atomTypeCont_.find(at2key);
368 >      
369 >      std::vector<std::string> at3key;
370 >      at3key.push_back(at3);
371 >      atype3 = atomTypeCont_.find(at3key);
372 >      
373 >      std::vector<std::string> at4key;
374 >      at4key.push_back(at4);
375 >      atype4 = atomTypeCont_.find(at4key);
376 >
377 >      // query atom types for their chains of responsibility
378 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
379 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
380 >      std::vector<AtomType*> at3Chain = atype3->allYourBase();
381 >      std::vector<AtomType*> at4Chain = atype4->allYourBase();
382 >
383 >      std::vector<AtomType*>::iterator i;
384 >      std::vector<AtomType*>::iterator j;
385 >      std::vector<AtomType*>::iterator k;
386 >      std::vector<AtomType*>::iterator l;
387 >
388 >      int ii = 0;
389 >      int jj = 0;
390 >      int kk = 0;
391 >      int ll = 0;
392 >      int Iscore;
393 >      int JKLscore;
394 >      
395 >      std::vector<tuple3<int, int, std::vector<std::string> > > foundInversions;
396 >      
397 >      for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
398 >        kk = 0;
399 >        for (k = at3Chain.begin(); k != at3Chain.end(); k++) {
400 >          ii = 0;      
401 >          for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
402 >            ll = 0;
403 >            for (l = at4Chain.begin(); l != at4Chain.end(); l++) {
404 >              
405 >              Iscore = ii;
406 >              JKLscore = jj + kk + ll;
407 >              
408 >              std::vector<std::string> myKeys;
409 >              myKeys.push_back((*i)->getName());
410 >              myKeys.push_back((*j)->getName());
411 >              myKeys.push_back((*k)->getName());
412 >              myKeys.push_back((*l)->getName());
413 >              
414 >              InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(myKeys);
415 >              if (inversionType) {
416 >                foundInversions.push_back( make_tuple3(Iscore, JKLscore, myKeys) );
417 >              }
418 >              ll++;
419 >            }
420 >            ii++;
421 >          }
422 >          kk++;
423 >        }
424 >        jj++;
425 >      }
426 >        
427 >      if (foundInversions.size() > 0) {
428 >        std::sort(foundInversions.begin(), foundInversions.end());
429 >        int iscore = foundInversions[0].first;
430 >        int jklscore = foundInversions[0].second;
431 >        std::vector<std::string> theKeys = foundInversions[0].third;
432 >        
433 >        InversionType* bestType = inversionTypeCont_.permutedFindSkippingFirstElement(theKeys);
434 >        return bestType;
435 >      } else {
436 >        //if no exact match found, try wild card match
437 >        return inversionTypeCont_.find(keys, wildCardAtomTypeName_);
438 >      }
439 >    }
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);    
447 >    
448 >    //try exact match first
449 >    NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(keys);
450 >    if (nbiType) {
451 >      return nbiType;
452 >    } else {
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,
513 >                                         const std::string &at2){
514 >    std::vector<std::string> keys;
515 >    keys.push_back(at1);
516 >    keys.push_back(at2);    
517 >    return bondTypeCont_.find(keys);
518 >  }
519 >  
520 >  BendType* ForceField::getExactBendType(const std::string &at1,
521 >                                         const std::string &at2,
522 >                                         const std::string &at3){
523 >    std::vector<std::string> keys;
524 >    keys.push_back(at1);
525 >    keys.push_back(at2);    
526 >    keys.push_back(at3);    
527 >    return bendTypeCont_.find(keys);
528 >  }
529 >  
530 >  TorsionType* ForceField::getExactTorsionType(const std::string &at1,
531 >                                               const std::string &at2,
532 >                                               const std::string &at3,
533 >                                               const std::string &at4){
534 >    std::vector<std::string> keys;
535 >    keys.push_back(at1);
536 >    keys.push_back(at2);    
537 >    keys.push_back(at3);    
538 >    keys.push_back(at4);  
539 >    return torsionTypeCont_.find(keys);
540 >  }
541 >  
542 >  InversionType* ForceField::getExactInversionType(const std::string &at1,
543 >                                                   const std::string &at2,
544 >                                                   const std::string &at3,
545 >                                                   const std::string &at4){
546 >    std::vector<std::string> keys;
547 >    keys.push_back(at1);
548 >    keys.push_back(at2);    
549 >    keys.push_back(at3);    
550 >    keys.push_back(at4);  
551 >    return inversionTypeCont_.find(keys);
552 >  }
553 >  
554 >  NonBondedInteractionType* ForceField::getExactNonBondedInteractionType(const std::string &at1, const std::string &at2){
555 >    std::vector<std::string> keys;
556 >    keys.push_back(at1);
557 >    keys.push_back(at2);    
558 >    return nonBondedInteractionTypeCont_.find(keys);
559 >  }
560 >  
561 >
562 >  bool ForceField::addAtomType(const std::string &at, AtomType* atomType) {
563 >    std::vector<std::string> keys;
564 >    keys.push_back(at);
565 >    return atomTypeCont_.add(keys, atomType);
566 >  }
567 >
568 >  bool ForceField::replaceAtomType(const std::string &at, AtomType* atomType) {
569 >    std::vector<std::string> keys;
570 >    keys.push_back(at);
571 >    return atomTypeCont_.replace(keys, atomType);
572 >  }
573 >
574 >  bool ForceField::addBondType(const std::string &at1, const std::string &at2,
575 >                               BondType* bondType) {
576 >    std::vector<std::string> keys;
577 >    keys.push_back(at1);
578 >    keys.push_back(at2);    
579 >    return bondTypeCont_.add(keys, bondType);    
580 >  }
581 >  
582 >  bool ForceField::addBendType(const std::string &at1, const std::string &at2,
583 >                               const std::string &at3, BendType* bendType) {
584 >    std::vector<std::string> keys;
585 >    keys.push_back(at1);
586 >    keys.push_back(at2);    
587 >    keys.push_back(at3);    
588 >    return bendTypeCont_.add(keys, bendType);
589 >  }
590 >  
591 >  bool ForceField::addTorsionType(const std::string &at1,
592 >                                  const std::string &at2,
593 >                                  const std::string &at3,
594 >                                  const std::string &at4,
595 >                                  TorsionType* torsionType) {
596 >    std::vector<std::string> keys;
597 >    keys.push_back(at1);
598 >    keys.push_back(at2);    
599 >    keys.push_back(at3);    
600 >    keys.push_back(at4);    
601 >    return torsionTypeCont_.add(keys, torsionType);
602 >  }
603 >
604 >  bool ForceField::addInversionType(const std::string &at1,
605 >                                    const std::string &at2,
606 >                                    const std::string &at3,
607 >                                    const std::string &at4,
608 >                                    InversionType* inversionType) {
609 >    std::vector<std::string> keys;
610 >    keys.push_back(at1);
611 >    keys.push_back(at2);    
612 >    keys.push_back(at3);    
613 >    keys.push_back(at4);    
614 >    return inversionTypeCont_.add(keys, inversionType);
615 >  }
616 >  
617 >  bool ForceField::addNonBondedInteractionType(const std::string &at1,
618 >                                               const std::string &at2,
619 >                                               NonBondedInteractionType* nbiType) {
620 >    std::vector<std::string> keys;
621 >    keys.push_back(at1);
622 >    keys.push_back(at2);    
623 >    return nonBondedInteractionTypeCont_.add(keys, nbiType);
624 >  }
625 >  
626 >  RealType ForceField::getRcutFromAtomType(AtomType* at) {
627 >    /**@todo */
628 >    GenericData* data;
629 >    RealType rcut = 0.0;
630 >    
631 >    if (at->isLennardJones()) {
632 >      data = at->getPropertyByName("LennardJones");
633 >      if (data != NULL) {
634 >        LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
635 >        
636 >        if (ljData != NULL) {
637 >          LJParam ljParam = ljData->getData();
638 >          
639 >          //by default use 2.5*sigma as cutoff radius
640 >          rcut = 2.5 * ljParam.sigma;
641 >          
642 >        } else {
643 >          sprintf( painCave.errMsg,
644 >                   "Can not cast GenericData to LJParam\n");
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 = OPENMD_ERROR;
652 >        painCave.isFatal = 1;
653 >        simError();          
654 >      }
655 >    }
656 >    return rcut;    
657 >  }
658 >  
659 >
660 >  ifstrstream* ForceField::openForceFieldFile(const std::string& filename) {
661 >    std::string forceFieldFilename(filename);
662 >    ifstrstream* ffStream = new ifstrstream();
663 >    
664 >    //try to open the force filed file in current directory first    
665 >    ffStream->open(forceFieldFilename.c_str());
666 >    if(!ffStream->is_open()){
667 >
668 >      forceFieldFilename = ffPath_ + "/" + forceFieldFilename;
669 >      ffStream->open( forceFieldFilename.c_str() );
670 >
671 >      //if current directory does not contain the force field file,
672 >      //try to open it in the path        
673 >      if(!ffStream->is_open()){
674 >
675 >        sprintf( painCave.errMsg,
676 >                 "Error opening the force field parameter file:\n"
677 >                 "\t%s\n"
678 >                 "\tHave you tried setting the FORCE_PARAM_PATH environment "
679 >                 "variable?\n",
680 >                 forceFieldFilename.c_str() );
681 >        painCave.severity = OPENMD_ERROR;
682 >        painCave.isFatal = 1;
683 >        simError();
684 >      }
685 >    }  
686 >    return ffStream;
687 >  }
688 >
689 >  void ForceField::setFortranForceOptions(){
690 >    ForceOptions theseFortranOptions;
691 >    forceFieldOptions_.makeFortranOptions(theseFortranOptions);
692 >    setfForceOptions(&theseFortranOptions);
693 >  }
694 > } //end namespace OpenMD

Comparing:
trunk/src/UseTheForce/ForceField.cpp (property svn:keywords), Revision 206 by gezelter, Thu Nov 4 20:51:23 2004 UTC vs.
branches/heatflux/src/UseTheForce/ForceField.cpp (property svn:keywords), Revision 1670 by chuckv, Fri Jan 27 19:07:19 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines