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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines