ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/types/AtomType.cpp
Revision: 2094
Committed: Wed Mar 9 14:26:15 2005 UTC (19 years, 4 months ago) by gezelter
File size: 8543 byte(s)
Log Message:
added splitDipole and fixed quadrupole stuff

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