ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.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

# User Rev Content
1 gezelter 2094 /*
2 gezelter 1930 * 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 gezelter 1632 #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 gezelter 1930 #include "UseTheForce/DarkSide/lj_interface.h"
52     #include "UseTheForce/DarkSide/eam_interface.h"
53 gezelter 2089 #include "UseTheForce/DarkSide/electrostatic_interface.h"
54 chuckv 2427 #include "UseTheForce/DarkSide/suttonchen_interface.h"
55 gezelter 1632 namespace oopse {
56     AtomType::AtomType(){
57    
58     // initialize to an error:
59     atp.ident = -1;
60 gezelter 1652
61 gezelter 1930 // and mass_less:
62     mass_ = 0.0;
63 gezelter 1632
64     // atom type is a Tabula Rasa:
65 gezelter 1670 atp.is_Directional = 0;
66 gezelter 1632 atp.is_LennardJones = 0;
67     atp.is_Charge = 0;
68 gezelter 1670 atp.is_Dipole = 0;
69 tim 2097 atp.is_SplitDipole = 0;
70 gezelter 1930 atp.is_Quadrupole = 0;
71 gezelter 1632 atp.is_Sticky = 0;
72 chrisfen 2220 atp.is_StickyPower = 0;
73 gezelter 1632 atp.is_GayBerne = 0;
74     atp.is_EAM = 0;
75     atp.is_Shape = 0;
76     atp.is_FLARB = 0;
77 chuckv 2427 atp.is_SC = 0;
78 chuckv 2406 atp.is_MEAM = 0;
79 gezelter 1632 }
80    
81 gezelter 1930 void AtomType::makeFortranAtomType() {
82 gezelter 1632
83     int status;
84    
85 gezelter 1930 if (name_.empty()) {
86 gezelter 1632 sprintf( painCave.errMsg,
87     "Attempting to complete an AtomType without giving "
88 gezelter 1930 "it a name_!\n");
89 gezelter 1632 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 gezelter 1930 " ident!/n", name_.c_str());
98 gezelter 1632 painCave.severity = OOPSE_ERROR;
99     painCave.isFatal = 1;
100     simError();
101     }
102    
103     status = 0;
104 chrisfen 2211
105 chrisfen 1638 makeAtype(&atp, &status);
106 gezelter 1632
107     if (status != 0) {
108     sprintf( painCave.errMsg,
109 gezelter 1930 "Fortran rejected AtomType %s!\n", name_.c_str());
110 gezelter 1632 painCave.severity = OOPSE_ERROR;
111     painCave.isFatal = 1;
112     simError();
113     }
114     }
115 gezelter 1930
116    
117 gezelter 2204 void AtomType::complete() {
118 gezelter 1930 int isError;
119     GenericData* data;
120    
121     //notify a new LJtype atom type is created
122     if (isLennardJones()) {
123 gezelter 2204 data = getPropertyByName("LennardJones");
124     if (data != NULL) {
125     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
126 gezelter 1930
127 gezelter 2204 if (ljData != NULL) {
128     LJParam ljParam = ljData->getData();
129 gezelter 1930
130 chrisfen 2220 newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &ljParam.soft_pot,
131     &isError);
132 gezelter 1930
133 gezelter 2204 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 gezelter 1930
141 gezelter 2204 } 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 gezelter 1930 }
155    
156 gezelter 2089 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 gezelter 1930 if (isCharge()) {
168 gezelter 2204 data = getPropertyByName("Charge");
169     if (data != NULL) {
170     DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
171 gezelter 1930
172 gezelter 2204 if (doubleData != NULL) {
173     double charge = doubleData->getData();
174     setCharge(&atp.ident, &charge, &isError);
175 gezelter 2089
176 gezelter 2204 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 gezelter 1930 }
197    
198     if (isEAM()) {
199 gezelter 2204 data = getPropertyByName("EAM");
200     if (data != NULL) {
201     EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
202 gezelter 1930
203 gezelter 2204 if (eamData != NULL) {
204 gezelter 1930
205 gezelter 2204 EAMParam eamParam = eamData->getData();
206 gezelter 1930
207    
208 chrisfen 2220 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 gezelter 1930
213 gezelter 2204 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 gezelter 1930 }
234    
235    
236 chuckv 2427 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 gezelter 2204 }
275 gezelter 1930
276 gezelter 2204 void AtomType::addProperty(GenericData* genData) {
277 gezelter 1930 properties_.addProperty(genData);
278 gezelter 2204 }
279 gezelter 1930
280 gezelter 2204 void AtomType::removeProperty(const std::string& propName) {
281 gezelter 1930 properties_.removeProperty(propName);
282 gezelter 2204 }
283 gezelter 1930
284 gezelter 2204 void AtomType::clearProperties() {
285 gezelter 1930 properties_.clearProperties();
286 gezelter 2204 }
287 gezelter 1930
288 gezelter 2204 std::vector<std::string> AtomType::getPropertyNames() {
289 gezelter 1930 return properties_.getPropertyNames();
290 gezelter 2204 }
291 gezelter 1930
292 gezelter 2204 std::vector<GenericData*> AtomType::getProperties() {
293 gezelter 1930 return properties_.getProperties();
294 gezelter 2204 }
295 gezelter 1930
296 gezelter 2204 GenericData* AtomType::getPropertyByName(const std::string& propName) {
297 gezelter 1930 return properties_.getPropertyByName(propName);
298 gezelter 2204 }
299 gezelter 1930 }