ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/io/MetalNonMetalInteractionsSectionParser.cpp
Revision: 1442
Committed: Mon May 10 17:28:26 2010 UTC (14 years, 11 months ago) by gezelter
File size: 6556 byte(s)
Log Message:
Adding property set to svn entries

File Contents

# User Rev Content
1 chuckv 1150 /*
2     * Copyright (c) 2007 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 chuckv 1150 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 chuckv 1150 * 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 chuckv 1150 */
41    
42     #include "io/MetalNonMetalInteractionsSectionParser.hpp"
43     #include "types/AtomType.hpp"
44     #include "types/ShiftedMorseInteractionType.hpp"
45     #include "types/MAWInteractionType.hpp"
46     #include "types/LennardJonesInteractionType.hpp"
47     #include "types/RepulsiveMorseInteractionType.hpp"
48     #include "UseTheForce/ForceField.hpp"
49     #include "utils/simError.h"
50 gezelter 1390 namespace OpenMD {
51 chuckv 1150
52     MetalNonMetalInteractionsSectionParser::MetalNonMetalInteractionsSectionParser(ForceFieldOptions& options) : options_(options){
53     setSectionName("MetalNonMetalInteractions");
54    
55     stringToEnumMap_["MAW"] = MAW;
56     stringToEnumMap_["ShiftedMorse"] = ShiftedMorse;
57     stringToEnumMap_["LennardJones"] = LennardJones;
58 chuckv 1229 stringToEnumMap_["RepulsiveMorse"] = RepulsiveMorse;
59 chuckv 1150
60     }
61    
62     void MetalNonMetalInteractionsSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){
63     StringTokenizer tokenizer(line);
64     NonBondedInteractionType* nbiType = NULL;
65     int nTokens = tokenizer.countTokens();
66    
67     if (nTokens < 3) {
68     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Not enough tokens at line %d\n",
69     lineNo);
70     painCave.isFatal = 1;
71     simError();
72     }
73    
74     std::string at1 = tokenizer.nextToken();
75     std::string at2 = tokenizer.nextToken();
76 chuckv 1229 std::string itype = tokenizer.nextToken();
77    
78 gezelter 1238 MetalNonMetalInteractionTypeEnum nbit = getMetalNonMetalInteractionTypeEnum(itype);
79 chuckv 1150 nTokens -= 3;
80 gezelter 1238 NonBondedInteractionType* interactionType;
81 chuckv 1229
82 chuckv 1150 //switch is a nightmare to maintain
83     switch(nbit) {
84     case MAW :
85 gezelter 1238 if (nTokens < 5) {
86     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Not enough tokens at line %d\n",
87     lineNo);
88     painCave.isFatal = 1;
89     simError();
90     } else {
91     RealType r_e = tokenizer.nextTokenAsDouble();
92     RealType D_e = tokenizer.nextTokenAsDouble();
93     RealType beta = tokenizer.nextTokenAsDouble();
94     RealType ca1 = tokenizer.nextTokenAsDouble();
95     RealType cb1 = tokenizer.nextTokenAsDouble();
96     interactionType = new MAWInteractionType(D_e, beta, r_e, ca1, cb1);
97     }
98     break;
99    
100 chuckv 1150 case ShiftedMorse :
101 gezelter 1238 if (nTokens < 3) {
102     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Not enough tokens at line %d\n",
103     lineNo);
104     painCave.isFatal = 1;
105     simError();
106     } else {
107     RealType r0 = tokenizer.nextTokenAsDouble();
108     RealType D0 = tokenizer.nextTokenAsDouble();
109     RealType beta0 = tokenizer.nextTokenAsDouble();
110     interactionType = new ShiftedMorseInteractionType(D0, beta0, r0);
111     }
112     break;
113 chuckv 1150
114 gezelter 1238 case RepulsiveMorse :
115     if (nTokens < 3) {
116     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Not enough tokens at line %d\n",
117     lineNo);
118     painCave.isFatal = 1;
119     simError();
120     } else {
121     RealType r0 = tokenizer.nextTokenAsDouble();
122     RealType D0 = tokenizer.nextTokenAsDouble();
123     RealType beta0 = tokenizer.nextTokenAsDouble();
124     interactionType = new RepulsiveMorseInteractionType(D0, beta0, r0);
125     }
126     break;
127 chuckv 1162
128 chuckv 1150 case LennardJones :
129 gezelter 1238 if (nTokens < 2) {
130     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Not enough tokens at line %d\n",
131     lineNo);
132     painCave.isFatal = 1;
133     simError();
134     } else {
135     RealType sigma = tokenizer.nextTokenAsDouble();
136     RealType epsilon = tokenizer.nextTokenAsDouble();
137     interactionType = new LennardJonesInteractionType(sigma, epsilon);
138     }
139     break;
140 chuckv 1150
141     case Unknown :
142     default:
143     sprintf(painCave.errMsg, "MetalNonMetalInteractionsSectionParser Error: Unknown Interaction Type at line %d\n",
144     lineNo);
145     painCave.isFatal = 1;
146     simError();
147    
148     break;
149    
150     }
151    
152     if (interactionType != NULL) {
153     ff.addNonBondedInteractionType(at1, at2, interactionType);
154     }
155    
156     }
157    
158     MetalNonMetalInteractionsSectionParser::MetalNonMetalInteractionTypeEnum MetalNonMetalInteractionsSectionParser::getMetalNonMetalInteractionTypeEnum(const std::string& str) {
159     std::map<std::string, MetalNonMetalInteractionTypeEnum>::iterator i;
160     i = stringToEnumMap_.find(str);
161    
162     return i == stringToEnumMap_.end() ? Unknown : i->second;
163     }
164    
165 gezelter 1390 } //end namespace OpenMD
166 chuckv 1150

Properties

Name Value
svn:keywords Author Id Revision Date