ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/io/MetalNonMetalInteractionsSectionParser.cpp
Revision: 1254
Committed: Fri Jun 6 15:55:54 2008 UTC (16 years, 10 months ago) by chuckv
Original Path: trunk/src/io/MetalNonMetalInteractionsSectionParser.cpp
File size: 6513 byte(s)
Log Message:
Removed accidental print lines.

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     * 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
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
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     namespace oopse {
51    
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     } //end namespace oopse
166