ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/types/AtomType.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/types/AtomType.cpp (file contents):
Revision 1632 by gezelter, Fri Oct 22 20:21:36 2004 UTC vs.
Revision 2220 by chrisfen, Thu May 5 14:47:35 2005 UTC

# Line 1 | Line 1
1 + /*
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   #include <stdlib.h>
43   #include <stdio.h>
44   #include <string.h>
# Line 7 | Line 48
48   #include "utils/simError.h"
49   #define __C
50   #include "UseTheForce/DarkSide/atype_interface.h"
51 <
51 > #include "UseTheForce/DarkSide/lj_interface.h"
52 > #include "UseTheForce/DarkSide/eam_interface.h"
53 > #include "UseTheForce/DarkSide/electrostatic_interface.h"
54   namespace oopse {
55    AtomType::AtomType(){
56      
57      // initialize to an error:
58      atp.ident = -1;
59 <    // make the type empty:
60 <    name = NULL;
61 <    // and massless:
19 <    mass = 0.0;
59 >
60 >    // and mass_less:
61 >    mass_ = 0.0;
62      
63      // atom type is a Tabula Rasa:
64 +    atp.is_Directional = 0;
65      atp.is_LennardJones = 0;
23    atp.is_Electrostatic = 0;
66      atp.is_Charge = 0;
67 <    atp.is_Directional = 0;
67 >    atp.is_Dipole = 0;
68 >    atp.is_SplitDipole = 0;
69 >    atp.is_Quadrupole = 0;
70      atp.is_Sticky = 0;
71 +    atp.is_StickyPower = 0;
72      atp.is_GayBerne = 0;
73      atp.is_EAM = 0;
74      atp.is_Shape = 0;
75      atp.is_FLARB = 0;  
76    }
77      
78 <  AtomType::~AtomType() {
34 <    if ( name != NULL ) delete name;
35 <  }
36 <
37 <  void AtomType::complete() {
78 >  void AtomType::makeFortranAtomType() {
79      
80      int status;
81  
82 <    if (name == NULL) {
82 >    if (name_.empty()) {
83        sprintf( painCave.errMsg,
84                 "Attempting to complete an AtomType without giving "
85 <               "it a name!\n");
85 >               "it a name_!\n");
86        painCave.severity = OOPSE_ERROR;
87        painCave.isFatal = 1;
88        simError();
# Line 50 | Line 91 | namespace oopse {
91      if (atp.ident == -1) {
92        sprintf( painCave.errMsg,
93                 "Attempting to complete AtomType %s without setting the"
94 <               " ident!/n", name);
94 >               " ident!/n", name_.c_str());
95        painCave.severity = OOPSE_ERROR;
96        painCave.isFatal = 1;
97        simError();          
98      }
99  
100      status = 0;
60
61    makeAtype(atp, &status);  
101      
102 +    makeAtype(&atp, &status);  
103 +    
104      if (status != 0) {
105        sprintf( painCave.errMsg,
106 <               "Fortran rejected AtomType %s!\n", name);
106 >               "Fortran rejected AtomType %s!\n", name_.c_str());
107        painCave.severity = OOPSE_ERROR;
108        painCave.isFatal = 1;
109        simError();          
110      }
111    }
112 +
113 +
114 +  void AtomType::complete() {
115 +    int isError;
116 +    GenericData* data;
117 +    
118 +    //notify a new LJtype atom type is created
119 +    if (isLennardJones()) {
120 +      data = getPropertyByName("LennardJones");
121 +      if (data != NULL) {
122 +        LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
123 +
124 +        if (ljData != NULL) {
125 +          LJParam ljParam = ljData->getData();
126 +                
127 +          newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &ljParam.soft_pot,
128 +              &isError);
129 +
130 +          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 +                
138 +        } 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 +    }
152 +
153 +    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 +    if (isCharge()) {
165 +      data = getPropertyByName("Charge");
166 +      if (data != NULL) {
167 +        DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
168 +
169 +        if (doubleData != NULL) {
170 +          double charge = doubleData->getData();
171 +          setCharge(&atp.ident, &charge, &isError);
172 +                
173 +          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 +    }
194 +
195 +    if (isEAM()) {
196 +      data = getPropertyByName("EAM");
197 +      if (data != NULL) {
198 +        EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
199 +
200 +        if (eamData != NULL) {
201 +
202 +          EAMParam eamParam = eamData->getData();
203 +                
204 +
205 +          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 +
210 +          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 +    }
231 +
232 +    
233 +  }
234 +
235 +  void AtomType::addProperty(GenericData* genData) {
236 +    properties_.addProperty(genData);  
237 +  }
238 +
239 +  void AtomType::removeProperty(const std::string& propName) {
240 +    properties_.removeProperty(propName);  
241 +  }
242 +
243 +  void AtomType::clearProperties() {
244 +    properties_.clearProperties();
245 +  }
246 +
247 +  std::vector<std::string> AtomType::getPropertyNames() {
248 +    return properties_.getPropertyNames();  
249 +  }
250 +      
251 +  std::vector<GenericData*> AtomType::getProperties() {
252 +    return properties_.getProperties();
253 +  }
254 +
255 +  GenericData* AtomType::getPropertyByName(const std::string& propName) {
256 +    return properties_.getPropertyByName(propName);
257 +  }  
258   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines