ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/types/AtomType.cpp
Revision: 2204
Committed: Fri Apr 15 22:04:00 2005 UTC (19 years, 2 months ago) by gezelter
File size: 7620 byte(s)
Log Message:
xemacs has been drafted to perform our indentation services

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 gezelter 1632 namespace oopse {
55     AtomType::AtomType(){
56    
57     // initialize to an error:
58     atp.ident = -1;
59 gezelter 1652
60 gezelter 1930 // and mass_less:
61     mass_ = 0.0;
62 gezelter 1632
63     // atom type is a Tabula Rasa:
64 gezelter 1670 atp.is_Directional = 0;
65 gezelter 1632 atp.is_LennardJones = 0;
66     atp.is_Charge = 0;
67 gezelter 1670 atp.is_Dipole = 0;
68 tim 2097 atp.is_SplitDipole = 0;
69 gezelter 1930 atp.is_Quadrupole = 0;
70 gezelter 1632 atp.is_Sticky = 0;
71     atp.is_GayBerne = 0;
72     atp.is_EAM = 0;
73     atp.is_Shape = 0;
74     atp.is_FLARB = 0;
75     }
76    
77 gezelter 1930 void AtomType::makeFortranAtomType() {
78 gezelter 1632
79     int status;
80    
81 gezelter 1930 if (name_.empty()) {
82 gezelter 1632 sprintf( painCave.errMsg,
83     "Attempting to complete an AtomType without giving "
84 gezelter 1930 "it a name_!\n");
85 gezelter 1632 painCave.severity = OOPSE_ERROR;
86     painCave.isFatal = 1;
87     simError();
88     }
89    
90     if (atp.ident == -1) {
91     sprintf( painCave.errMsg,
92     "Attempting to complete AtomType %s without setting the"
93 gezelter 1930 " ident!/n", name_.c_str());
94 gezelter 1632 painCave.severity = OOPSE_ERROR;
95     painCave.isFatal = 1;
96     simError();
97     }
98    
99     status = 0;
100    
101 chrisfen 1638 makeAtype(&atp, &status);
102 gezelter 1632
103     if (status != 0) {
104     sprintf( painCave.errMsg,
105 gezelter 1930 "Fortran rejected AtomType %s!\n", name_.c_str());
106 gezelter 1632 painCave.severity = OOPSE_ERROR;
107     painCave.isFatal = 1;
108     simError();
109     }
110     }
111 gezelter 1930
112    
113 gezelter 2204 void AtomType::complete() {
114 gezelter 1930 int isError;
115     GenericData* data;
116    
117     //notify a new LJtype atom type is created
118     if (isLennardJones()) {
119 gezelter 2204 data = getPropertyByName("LennardJones");
120     if (data != NULL) {
121     LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
122 gezelter 1930
123 gezelter 2204 if (ljData != NULL) {
124     LJParam ljParam = ljData->getData();
125 gezelter 1930
126 gezelter 2204 newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &ljParam.soft_pot, &isError);
127 gezelter 1930
128 gezelter 2204 if (isError != 0) {
129     sprintf( painCave.errMsg,
130     "Fortran rejected newLJtype\n");
131     painCave.severity = OOPSE_ERROR;
132     painCave.isFatal = 1;
133     simError();
134     }
135 gezelter 1930
136 gezelter 2204 } else {
137     sprintf( painCave.errMsg,
138     "Can not cast GenericData to LJParam\n");
139     painCave.severity = OOPSE_ERROR;
140     painCave.isFatal = 1;
141     simError();
142     }
143     } else {
144     sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
145     painCave.severity = OOPSE_ERROR;
146     painCave.isFatal = 1;
147     simError();
148     }
149 gezelter 1930 }
150    
151 gezelter 2089 if (isElectrostatic()) {
152     newElectrostaticType(&atp, &isError);
153     if (isError != 0) {
154     sprintf( painCave.errMsg,
155     "Fortran rejected newElectrostaticType\n");
156     painCave.severity = OOPSE_ERROR;
157     painCave.isFatal = 1;
158     simError();
159     }
160     }
161    
162 gezelter 1930 if (isCharge()) {
163 gezelter 2204 data = getPropertyByName("Charge");
164     if (data != NULL) {
165     DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
166 gezelter 1930
167 gezelter 2204 if (doubleData != NULL) {
168     double charge = doubleData->getData();
169     setCharge(&atp.ident, &charge, &isError);
170 gezelter 2089
171 gezelter 2204 if (isError != 0) {
172     sprintf( painCave.errMsg,
173     "Fortran rejected setCharge\n");
174     painCave.severity = OOPSE_ERROR;
175     painCave.isFatal = 1;
176     simError();
177     }
178     } else {
179     sprintf( painCave.errMsg,
180     "Can not cast GenericData to DoubleGenericData\n");
181     painCave.severity = OOPSE_ERROR;
182     painCave.isFatal = 1;
183     simError();
184     }
185     } else {
186     sprintf( painCave.errMsg, "Can not find Charge Parameters\n");
187     painCave.severity = OOPSE_ERROR;
188     painCave.isFatal = 1;
189     simError();
190     }
191 gezelter 1930 }
192    
193     if (isEAM()) {
194 gezelter 2204 data = getPropertyByName("EAM");
195     if (data != NULL) {
196     EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
197 gezelter 1930
198 gezelter 2204 if (eamData != NULL) {
199 gezelter 1930
200 gezelter 2204 EAMParam eamParam = eamData->getData();
201 gezelter 1930
202    
203 gezelter 2204 newEAMtype(&eamParam.latticeConstant, &eamParam.nrho, &eamParam.drho, &eamParam.nr, &eamParam.dr, &eamParam.rcut,
204     &eamParam.rvals[0], &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident, &isError );
205 gezelter 1930
206 gezelter 2204 if (isError != 0) {
207     sprintf( painCave.errMsg,
208     "Fortran rejected newEAMtype\n");
209     painCave.severity = OOPSE_ERROR;
210     painCave.isFatal = 1;
211     simError();
212     }
213     } else {
214     sprintf( painCave.errMsg,
215     "Can not cast GenericData to EAMParam\n");
216     painCave.severity = OOPSE_ERROR;
217     painCave.isFatal = 1;
218     simError();
219     }
220     } else {
221     sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
222     painCave.severity = OOPSE_ERROR;
223     painCave.isFatal = 1;
224     simError();
225     }
226 gezelter 1930 }
227    
228    
229 gezelter 2204 }
230 gezelter 1930
231 gezelter 2204 void AtomType::addProperty(GenericData* genData) {
232 gezelter 1930 properties_.addProperty(genData);
233 gezelter 2204 }
234 gezelter 1930
235 gezelter 2204 void AtomType::removeProperty(const std::string& propName) {
236 gezelter 1930 properties_.removeProperty(propName);
237 gezelter 2204 }
238 gezelter 1930
239 gezelter 2204 void AtomType::clearProperties() {
240 gezelter 1930 properties_.clearProperties();
241 gezelter 2204 }
242 gezelter 1930
243 gezelter 2204 std::vector<std::string> AtomType::getPropertyNames() {
244 gezelter 1930 return properties_.getPropertyNames();
245 gezelter 2204 }
246 gezelter 1930
247 gezelter 2204 std::vector<GenericData*> AtomType::getProperties() {
248 gezelter 1930 return properties_.getProperties();
249 gezelter 2204 }
250 gezelter 1930
251 gezelter 2204 GenericData* AtomType::getPropertyByName(const std::string& propName) {
252 gezelter 1930 return properties_.getPropertyByName(propName);
253 gezelter 2204 }
254 gezelter 1930 }