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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines