ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/UseTheForce/ForceField.cpp
Revision: 1555
Committed: Tue May 10 20:54:47 2011 UTC (13 years, 11 months ago) by gezelter
File size: 21163 byte(s)
Log Message:
Bug fix to traverse the base chains for NON-bonded interactions as
well as bonded.  This allows one to specify Metal - non-Metal
interactions based on base types instead of exact matches.


File Contents

# User Rev Content
1 gezelter 507 /*
2 gezelter 246 * 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 gezelter 1390 * 1. Redistributions of source code must retain the above copyright
10 gezelter 246 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 gezelter 246 * 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 gezelter 1390 *
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 gezelter 246 */
41    
42 gezelter 507 /**
43     * @file ForceField.cpp
44     * @author tlin
45     * @date 11/04/2004
46     * @time 22:51am
47     * @version 1.0
48     */
49 gezelter 246
50 gezelter 1269 #include <algorithm>
51 gezelter 206 #include "UseTheForce/ForceField.hpp"
52 gezelter 246 #include "utils/simError.h"
53 gezelter 1269 #include "utils/Tuple.hpp"
54 tim 475 #include "UseTheForce/DarkSide/atype_interface.h"
55 chuckv 821 #include "UseTheForce/DarkSide/fForceOptions_interface.h"
56 gezelter 939 #include "UseTheForce/DarkSide/switcheroo_interface.h"
57 gezelter 1390 namespace OpenMD {
58 gezelter 206
59 gezelter 507 ForceField::ForceField() {
60 gezelter 1460
61 gezelter 246 char* tempPath;
62     tempPath = getenv("FORCE_PARAM_PATH");
63 gezelter 1460
64 gezelter 246 if (tempPath == NULL) {
65 gezelter 1460 //convert a macro from compiler to a string in c++
66     STR_DEFINE(ffPath_, FRC_PATH );
67 gezelter 246 } else {
68 gezelter 507 ffPath_ = tempPath;
69 gezelter 246 }
70 gezelter 507 }
71 gezelter 206
72 tim 475
73 gezelter 507 ForceField::~ForceField() {
74 tim 475 deleteAtypes();
75 gezelter 939 deleteSwitch();
76 gezelter 507 }
77 tim 475
78 gezelter 507 AtomType* ForceField::getAtomType(const std::string &at) {
79 gezelter 246 std::vector<std::string> keys;
80     keys.push_back(at);
81     return atomTypeCont_.find(keys);
82 gezelter 507 }
83 gezelter 206
84 cpuglis 1195 BondType* ForceField::getBondType(const std::string &at1,
85     const std::string &at2) {
86 gezelter 246 std::vector<std::string> keys;
87     keys.push_back(at1);
88     keys.push_back(at2);
89 gezelter 206
90 gezelter 246 //try exact match first
91     BondType* bondType = bondTypeCont_.find(keys);
92     if (bondType) {
93 gezelter 507 return bondType;
94 gezelter 246 } else {
95 gezelter 1269 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     // query atom types for their chains of responsibility
106     std::vector<AtomType*> at1Chain = atype1->allYourBase();
107     std::vector<AtomType*> at2Chain = atype2->allYourBase();
108    
109     std::vector<AtomType*>::iterator i;
110     std::vector<AtomType*>::iterator j;
111    
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 gezelter 1277 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 gezelter 1269 }
152 gezelter 246 }
153 gezelter 507 }
154 gezelter 1269
155 cpuglis 1195 BendType* ForceField::getBendType(const std::string &at1,
156     const std::string &at2,
157 gezelter 507 const std::string &at3) {
158 gezelter 246 std::vector<std::string> keys;
159     keys.push_back(at1);
160     keys.push_back(at2);
161     keys.push_back(at3);
162 gezelter 206
163 gezelter 246 //try exact match first
164     BendType* bendType = bendTypeCont_.find(keys);
165     if (bendType) {
166 gezelter 507 return bendType;
167 gezelter 246 } else {
168 gezelter 1269
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 gezelter 1277 if (foundBends.size() > 0) {
225     std::sort(foundBends.begin(), foundBends.end());
226     int jscore = foundBends[0].first;
227     int ikscore = foundBends[0].second;
228 cli2 1289 std::vector<std::string> theKeys = foundBends[0].third;
229 gezelter 1277
230     BendType* bestType = bendTypeCont_.find(theKeys);
231     return bestType;
232     } else {
233 gezelter 1269 //if no exact match found, try wild card match
234     return bendTypeCont_.find(keys, wildCardAtomTypeName_);
235     }
236 gezelter 246 }
237 gezelter 507 }
238 gezelter 206
239 cpuglis 1195 TorsionType* ForceField::getTorsionType(const std::string &at1,
240     const std::string &at2,
241     const std::string &at3,
242     const std::string &at4) {
243 gezelter 246 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 gezelter 206
249 gezelter 1269
250     //try exact match first
251 gezelter 246 TorsionType* torsionType = torsionTypeCont_.find(keys);
252     if (torsionType) {
253 gezelter 507 return torsionType;
254 gezelter 246 } else {
255 gezelter 1269
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     std::vector<std::string> at4key;
273     at4key.push_back(at4);
274     atype4 = atomTypeCont_.find(at4key);
275    
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     int ii = 0;
288     int jj = 0;
289     int kk = 0;
290     int ll = 0;
291     int ILscore;
292     int JKscore;
293    
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     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     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 gezelter 1277 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 gezelter 1269 } else {
335     //if no exact match found, try wild card match
336     return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
337     }
338 gezelter 246 }
339 gezelter 507 }
340 gezelter 206
341 cli2 1275 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 cli2 1303 InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(keys);
353 cli2 1275 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 cli2 1303 InversionType* inversionType = inversionTypeCont_.permutedFindSkippingFirstElement(myKeys);
415 cli2 1275 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 gezelter 1277
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 cli2 1303 InversionType* bestType = inversionTypeCont_.permutedFindSkippingFirstElement(theKeys);
434 gezelter 1277 return bestType;
435 cli2 1275 } else {
436     //if no exact match found, try wild card match
437     return inversionTypeCont_.find(keys, wildCardAtomTypeName_);
438     }
439     }
440     }
441    
442 chuckv 1151 NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) {
443     std::vector<std::string> keys;
444     keys.push_back(at1);
445     keys.push_back(at2);
446 cpuglis 1195
447 chuckv 1151 //try exact match first
448     NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(keys);
449     if (nbiType) {
450     return nbiType;
451     } else {
452 gezelter 1555 AtomType* atype1;
453     AtomType* atype2;
454     std::vector<std::string> at1key;
455     at1key.push_back(at1);
456     atype1 = atomTypeCont_.find(at1key);
457    
458     std::vector<std::string> at2key;
459     at2key.push_back(at2);
460     atype2 = atomTypeCont_.find(at2key);
461    
462     // query atom types for their chains of responsibility
463     std::vector<AtomType*> at1Chain = atype1->allYourBase();
464     std::vector<AtomType*> at2Chain = atype2->allYourBase();
465    
466     std::vector<AtomType*>::iterator i;
467     std::vector<AtomType*>::iterator j;
468    
469     int ii = 0;
470     int jj = 0;
471     int nbiTypeScore;
472    
473     std::vector<std::pair<int, std::vector<std::string> > > foundNBI;
474    
475     for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
476     jj = 0;
477     for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
478    
479     nbiTypeScore = ii + jj;
480    
481     std::vector<std::string> myKeys;
482     myKeys.push_back((*i)->getName());
483     myKeys.push_back((*j)->getName());
484    
485     NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(myKeys);
486     if (nbiType) {
487     foundNBI.push_back(std::make_pair(nbiTypeScore, myKeys));
488     }
489     jj++;
490     }
491     ii++;
492     }
493    
494    
495     if (foundNBI.size() > 0) {
496     // sort the foundNBI by the score:
497     std::sort(foundNBI.begin(), foundNBI.end());
498    
499     int bestScore = foundNBI[0].first;
500     std::vector<std::string> theKeys = foundNBI[0].second;
501    
502     NonBondedInteractionType* bestType = nonBondedInteractionTypeCont_.find(theKeys);
503    
504     return bestType;
505     } else {
506     //if no exact match found, try wild card match
507     return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);
508     }
509     }
510 chuckv 1151 }
511 cpuglis 1195
512     BondType* ForceField::getExactBondType(const std::string &at1,
513     const std::string &at2){
514 gezelter 246 std::vector<std::string> keys;
515     keys.push_back(at1);
516     keys.push_back(at2);
517     return bondTypeCont_.find(keys);
518 gezelter 507 }
519 cpuglis 1195
520     BendType* ForceField::getExactBendType(const std::string &at1,
521     const std::string &at2,
522 gezelter 507 const std::string &at3){
523 gezelter 246 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 gezelter 507 }
529 cpuglis 1195
530     TorsionType* ForceField::getExactTorsionType(const std::string &at1,
531     const std::string &at2,
532     const std::string &at3,
533     const std::string &at4){
534 gezelter 246 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 gezelter 507 }
541 cli2 1275
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 chuckv 1151 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 cli2 1275
561 chuckv 1151
562 gezelter 507 bool ForceField::addAtomType(const std::string &at, AtomType* atomType) {
563 gezelter 246 std::vector<std::string> keys;
564     keys.push_back(at);
565     return atomTypeCont_.add(keys, atomType);
566 gezelter 507 }
567 gezelter 206
568 gezelter 1282 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 cpuglis 1195 bool ForceField::addBondType(const std::string &at1, const std::string &at2,
575     BondType* bondType) {
576 gezelter 246 std::vector<std::string> keys;
577     keys.push_back(at1);
578     keys.push_back(at2);
579 cpuglis 1195 return bondTypeCont_.add(keys, bondType);
580 gezelter 507 }
581 cpuglis 1195
582 gezelter 507 bool ForceField::addBendType(const std::string &at1, const std::string &at2,
583     const std::string &at3, BendType* bendType) {
584 gezelter 246 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 gezelter 507 }
590 cpuglis 1195
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 gezelter 246 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 gezelter 507 }
603 gezelter 206
604 cli2 1275 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 cpuglis 1195 bool ForceField::addNonBondedInteractionType(const std::string &at1,
618     const std::string &at2,
619     NonBondedInteractionType* nbiType) {
620 chuckv 1151 std::vector<std::string> keys;
621     keys.push_back(at1);
622     keys.push_back(at2);
623     return nonBondedInteractionTypeCont_.add(keys, nbiType);
624     }
625 cpuglis 1195
626 tim 963 RealType ForceField::getRcutFromAtomType(AtomType* at) {
627 gezelter 246 /**@todo */
628     GenericData* data;
629 tim 963 RealType rcut = 0.0;
630 cpuglis 1195
631 gezelter 246 if (at->isLennardJones()) {
632 gezelter 507 data = at->getPropertyByName("LennardJones");
633     if (data != NULL) {
634     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
635 cpuglis 1195
636 gezelter 507 if (ljData != NULL) {
637     LJParam ljParam = ljData->getData();
638 cpuglis 1195
639 gezelter 507 //by default use 2.5*sigma as cutoff radius
640     rcut = 2.5 * ljParam.sigma;
641 cpuglis 1195
642 gezelter 507 } else {
643     sprintf( painCave.errMsg,
644     "Can not cast GenericData to LJParam\n");
645 gezelter 1390 painCave.severity = OPENMD_ERROR;
646 gezelter 507 painCave.isFatal = 1;
647     simError();
648     }
649     } else {
650     sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
651 gezelter 1390 painCave.severity = OPENMD_ERROR;
652 gezelter 507 painCave.isFatal = 1;
653     simError();
654     }
655 gezelter 246 }
656     return rcut;
657 gezelter 507 }
658 cpuglis 1195
659 gezelter 206
660 gezelter 507 ifstrstream* ForceField::openForceFieldFile(const std::string& filename) {
661 gezelter 246 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 gezelter 507 forceFieldFilename = ffPath_ + "/" + forceFieldFilename;
669     ffStream->open( forceFieldFilename.c_str() );
670 gezelter 246
671 gezelter 507 //if current directory does not contain the force field file,
672     //try to open it in the path
673     if(!ffStream->is_open()){
674 gezelter 246
675 gezelter 507 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 gezelter 1390 painCave.severity = OPENMD_ERROR;
682 gezelter 507 painCave.isFatal = 1;
683     simError();
684     }
685 gezelter 246 }
686     return ffStream;
687 gezelter 507 }
688 gezelter 246
689 chuckv 821 void ForceField::setFortranForceOptions(){
690     ForceOptions theseFortranOptions;
691     forceFieldOptions_.makeFortranOptions(theseFortranOptions);
692     setfForceOptions(&theseFortranOptions);
693     }
694 gezelter 1390 } //end namespace OpenMD

Properties

Name Value
svn:keywords Author Id Revision Date