ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/types/AtomType.cpp
Revision: 1930
Committed: Wed Jan 12 22:41:40 2005 UTC (19 years, 5 months ago) by gezelter
File size: 8194 byte(s)
Log Message:
merging new_design branch into OOPSE-2.0

File Contents

# User Rev Content
1 gezelter 1930 /*
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 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     #include "UseTheForce/DarkSide/charge_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     newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &isError);
126    
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     if (isCharge()) {
151     data = getPropertyByName("Charge");
152     if (data != NULL) {
153     DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
154    
155     if (doubleData != NULL) {
156     double charge = doubleData->getData();
157     newChargeType(&atp.ident, &charge, &isError);
158    
159     if (isError != 0) {
160     sprintf( painCave.errMsg,
161     "Fortran rejected newChargeType\n");
162     painCave.severity = OOPSE_ERROR;
163     painCave.isFatal = 1;
164     simError();
165     }
166     } else {
167     sprintf( painCave.errMsg,
168     "Can not cast GenericData to DoubleGenericData\n");
169     painCave.severity = OOPSE_ERROR;
170     painCave.isFatal = 1;
171     simError();
172     }
173     } else {
174     sprintf( painCave.errMsg, "Can not find Charge Parameters\n");
175     painCave.severity = OOPSE_ERROR;
176     painCave.isFatal = 1;
177     simError();
178     }
179     }
180    
181     if (isEAM()) {
182     data = getPropertyByName("EAM");
183     if (data != NULL) {
184     EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
185    
186     if (eamData != NULL) {
187    
188     EAMParam eamParam = eamData->getData();
189    
190    
191     newEAMtype(&eamParam.latticeConstant, &eamParam.nrho, &eamParam.drho, &eamParam.nr, &eamParam.dr, &eamParam.rcut,
192     &eamParam.rvals[0], &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident, &isError );
193    
194     if (isError != 0) {
195     sprintf( painCave.errMsg,
196     "Fortran rejected newEAMtype\n");
197     painCave.severity = OOPSE_ERROR;
198     painCave.isFatal = 1;
199     simError();
200     }
201     } else {
202     sprintf( painCave.errMsg,
203     "Can not cast GenericData to EAMParam\n");
204     painCave.severity = OOPSE_ERROR;
205     painCave.isFatal = 1;
206     simError();
207     }
208     } else {
209     sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
210     painCave.severity = OOPSE_ERROR;
211     painCave.isFatal = 1;
212     simError();
213     }
214     }
215    
216    
217 gezelter 1632 }
218 gezelter 1930
219     void AtomType::addProperty(GenericData* genData) {
220     properties_.addProperty(genData);
221     }
222    
223     void AtomType::removeProperty(const std::string& propName) {
224     properties_.removeProperty(propName);
225     }
226    
227     void AtomType::clearProperties() {
228     properties_.clearProperties();
229     }
230    
231     std::vector<std::string> AtomType::getPropertyNames() {
232     return properties_.getPropertyNames();
233     }
234    
235     std::vector<GenericData*> AtomType::getProperties() {
236     return properties_.getProperties();
237     }
238    
239     GenericData* AtomType::getPropertyByName(const std::string& propName) {
240     return properties_.getPropertyByName(propName);
241     }
242     }