ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/types/AtomType.cpp
Revision: 2220
Committed: Thu May 5 14:47:35 2005 UTC (19 years, 2 months ago) by chrisfen
File size: 7708 byte(s)
Log Message:
OOPSE setup for TAP water.  It's not parametrized, but OOPSE will now let me run it...

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