ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/types/AtomType.cpp
Revision: 2427
Committed: Mon Nov 14 21:29:36 2005 UTC (18 years, 7 months ago) by chuckv
File size: 8944 byte(s)
Log Message:
Sutton-Chen almost done. Just need to fix do_forces to use Sutton-Chen.

File Contents

# Content
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. 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 <stdlib.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <iostream>
46
47 #include "types/AtomType.hpp"
48 #include "utils/simError.h"
49 #define __C
50 #include "UseTheForce/DarkSide/atype_interface.h"
51 #include "UseTheForce/DarkSide/lj_interface.h"
52 #include "UseTheForce/DarkSide/eam_interface.h"
53 #include "UseTheForce/DarkSide/electrostatic_interface.h"
54 #include "UseTheForce/DarkSide/suttonchen_interface.h"
55 namespace oopse {
56 AtomType::AtomType(){
57
58 // initialize to an error:
59 atp.ident = -1;
60
61 // and mass_less:
62 mass_ = 0.0;
63
64 // atom type is a Tabula Rasa:
65 atp.is_Directional = 0;
66 atp.is_LennardJones = 0;
67 atp.is_Charge = 0;
68 atp.is_Dipole = 0;
69 atp.is_SplitDipole = 0;
70 atp.is_Quadrupole = 0;
71 atp.is_Sticky = 0;
72 atp.is_StickyPower = 0;
73 atp.is_GayBerne = 0;
74 atp.is_EAM = 0;
75 atp.is_Shape = 0;
76 atp.is_FLARB = 0;
77 atp.is_SC = 0;
78 atp.is_MEAM = 0;
79 }
80
81 void AtomType::makeFortranAtomType() {
82
83 int status;
84
85 if (name_.empty()) {
86 sprintf( painCave.errMsg,
87 "Attempting to complete an AtomType without giving "
88 "it a name_!\n");
89 painCave.severity = OOPSE_ERROR;
90 painCave.isFatal = 1;
91 simError();
92 }
93
94 if (atp.ident == -1) {
95 sprintf( painCave.errMsg,
96 "Attempting to complete AtomType %s without setting the"
97 " ident!/n", name_.c_str());
98 painCave.severity = OOPSE_ERROR;
99 painCave.isFatal = 1;
100 simError();
101 }
102
103 status = 0;
104
105 makeAtype(&atp, &status);
106
107 if (status != 0) {
108 sprintf( painCave.errMsg,
109 "Fortran rejected AtomType %s!\n", name_.c_str());
110 painCave.severity = OOPSE_ERROR;
111 painCave.isFatal = 1;
112 simError();
113 }
114 }
115
116
117 void AtomType::complete() {
118 int isError;
119 GenericData* data;
120
121 //notify a new LJtype atom type is created
122 if (isLennardJones()) {
123 data = getPropertyByName("LennardJones");
124 if (data != NULL) {
125 LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
126
127 if (ljData != NULL) {
128 LJParam ljParam = ljData->getData();
129
130 newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &ljParam.soft_pot,
131 &isError);
132
133 if (isError != 0) {
134 sprintf( painCave.errMsg,
135 "Fortran rejected newLJtype\n");
136 painCave.severity = OOPSE_ERROR;
137 painCave.isFatal = 1;
138 simError();
139 }
140
141 } else {
142 sprintf( painCave.errMsg,
143 "Can not cast GenericData to LJParam\n");
144 painCave.severity = OOPSE_ERROR;
145 painCave.isFatal = 1;
146 simError();
147 }
148 } else {
149 sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
150 painCave.severity = OOPSE_ERROR;
151 painCave.isFatal = 1;
152 simError();
153 }
154 }
155
156 if (isElectrostatic()) {
157 newElectrostaticType(&atp, &isError);
158 if (isError != 0) {
159 sprintf( painCave.errMsg,
160 "Fortran rejected newElectrostaticType\n");
161 painCave.severity = OOPSE_ERROR;
162 painCave.isFatal = 1;
163 simError();
164 }
165 }
166
167 if (isCharge()) {
168 data = getPropertyByName("Charge");
169 if (data != NULL) {
170 DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
171
172 if (doubleData != NULL) {
173 double charge = doubleData->getData();
174 setCharge(&atp.ident, &charge, &isError);
175
176 if (isError != 0) {
177 sprintf( painCave.errMsg,
178 "Fortran rejected setCharge\n");
179 painCave.severity = OOPSE_ERROR;
180 painCave.isFatal = 1;
181 simError();
182 }
183 } else {
184 sprintf( painCave.errMsg,
185 "Can not cast GenericData to DoubleGenericData\n");
186 painCave.severity = OOPSE_ERROR;
187 painCave.isFatal = 1;
188 simError();
189 }
190 } else {
191 sprintf( painCave.errMsg, "Can not find Charge Parameters\n");
192 painCave.severity = OOPSE_ERROR;
193 painCave.isFatal = 1;
194 simError();
195 }
196 }
197
198 if (isEAM()) {
199 data = getPropertyByName("EAM");
200 if (data != NULL) {
201 EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
202
203 if (eamData != NULL) {
204
205 EAMParam eamParam = eamData->getData();
206
207
208 newEAMtype(&eamParam.latticeConstant, &eamParam.nrho, &eamParam.drho,
209 &eamParam.nr, &eamParam.dr, &eamParam.rcut, &eamParam.rvals[0],
210 &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident,
211 &isError );
212
213 if (isError != 0) {
214 sprintf( painCave.errMsg,
215 "Fortran rejected newEAMtype\n");
216 painCave.severity = OOPSE_ERROR;
217 painCave.isFatal = 1;
218 simError();
219 }
220 } else {
221 sprintf( painCave.errMsg,
222 "Can not cast GenericData to EAMParam\n");
223 painCave.severity = OOPSE_ERROR;
224 painCave.isFatal = 1;
225 simError();
226 }
227 } else {
228 sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
229 painCave.severity = OOPSE_ERROR;
230 painCave.isFatal = 1;
231 simError();
232 }
233 }
234
235
236 if (isSC()) {
237 data = getPropertyByName("SC");
238 if (data != NULL) {
239 SCParamGenericData* SCData = dynamic_cast<SCParamGenericData*>(data);
240
241 if (SCData != NULL) {
242
243 SCParam scParam = SCData->getData();
244
245
246 newSCtype(&atp.ident, &scParam.c, &scParam.m,
247 &scParam.n, &scParam.alpha, &scParam.epsilon,
248 &isError );
249
250 if (isError != 0) {
251 sprintf( painCave.errMsg,
252 "Fortran rejected newSCtype\n");
253 painCave.severity = OOPSE_ERROR;
254 painCave.isFatal = 1;
255 simError();
256 }
257 } else {
258 sprintf( painCave.errMsg,
259 "Can not cast GenericData to SCParam\n");
260 painCave.severity = OOPSE_ERROR;
261 painCave.isFatal = 1;
262 simError();
263 }
264 } else {
265 sprintf( painCave.errMsg, "Can not find SC Parameters\n");
266 painCave.severity = OOPSE_ERROR;
267 painCave.isFatal = 1;
268 simError();
269 }
270 }
271
272
273
274 }
275
276 void AtomType::addProperty(GenericData* genData) {
277 properties_.addProperty(genData);
278 }
279
280 void AtomType::removeProperty(const std::string& propName) {
281 properties_.removeProperty(propName);
282 }
283
284 void AtomType::clearProperties() {
285 properties_.clearProperties();
286 }
287
288 std::vector<std::string> AtomType::getPropertyNames() {
289 return properties_.getPropertyNames();
290 }
291
292 std::vector<GenericData*> AtomType::getProperties() {
293 return properties_.getProperties();
294 }
295
296 GenericData* AtomType::getPropertyByName(const std::string& propName) {
297 return properties_.getPropertyByName(propName);
298 }
299 }