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

Comparing:
trunk/OOPSE-3.0/src/types/AtomType.cpp (file contents), Revision 1638 by chrisfen, Fri Oct 22 23:00:06 2004 UTC vs.
branches/new_design/OOPSE-3.0/src/types/AtomType.cpp (file contents), Revision 1787 by tim, Mon Nov 29 14:40:30 2004 UTC

# Line 7 | Line 7
7   #include "utils/simError.h"
8   #define __C
9   #include "UseTheForce/DarkSide/atype_interface.h"
10 <
10 > #include "UseTheForce/DarkSide/lj_interface.h"
11 > #include "UseTheForce/DarkSide/eam_interface.h"
12 > #include "UseTheForce/DarkSide/charge_interface.h"
13   namespace oopse {
14    AtomType::AtomType(){
15      
16      // initialize to an error:
17      atp.ident = -1;
18 <    // make the type empty:
19 <    name = NULL;
20 <    // and massless:
19 <    mass = 0.0;
18 >
19 >    // and mass_less:
20 >    mass_ = 0.0;
21      
22      // atom type is a Tabula Rasa:
23 +    atp.is_Directional = 0;
24      atp.is_LennardJones = 0;
25      atp.is_Electrostatic = 0;
26      atp.is_Charge = 0;
27 <    atp.is_Directional = 0;
27 >    atp.is_Dipole = 0;
28      atp.is_Sticky = 0;
29      atp.is_GayBerne = 0;
30      atp.is_EAM = 0;
# Line 30 | Line 32 | namespace oopse {
32      atp.is_FLARB = 0;  
33    }
34      
35 <  AtomType::~AtomType() {
34 <    if ( name != NULL ) free(name);
35 <  }
36 <
37 <  void AtomType::complete() {
35 >  void AtomType::makeFortranAtomType() {
36      
37      int status;
38  
39 <    if (name == NULL) {
39 >    if (name_.empty()) {
40        sprintf( painCave.errMsg,
41                 "Attempting to complete an AtomType without giving "
42 <               "it a name!\n");
42 >               "it a name_!\n");
43        painCave.severity = OOPSE_ERROR;
44        painCave.isFatal = 1;
45        simError();
# Line 50 | Line 48 | namespace oopse {
48      if (atp.ident == -1) {
49        sprintf( painCave.errMsg,
50                 "Attempting to complete AtomType %s without setting the"
51 <               " ident!/n", name);
51 >               " ident!/n", name_.c_str());
52        painCave.severity = OOPSE_ERROR;
53        painCave.isFatal = 1;
54        simError();          
# Line 62 | Line 60 | namespace oopse {
60      
61      if (status != 0) {
62        sprintf( painCave.errMsg,
63 <               "Fortran rejected AtomType %s!\n", name);
63 >               "Fortran rejected AtomType %s!\n", name_.c_str());
64        painCave.severity = OOPSE_ERROR;
65        painCave.isFatal = 1;
66        simError();          
67      }
68    }
69 +
70 +
71 + void AtomType::complete() {
72 +    int isError;
73 +    GenericData* data;
74 +    
75 +    //notify a new LJtype atom type is created
76 +    if (isLennardJones()) {
77 +        data = getPropertyByName("LennardJones");
78 +        if (data != NULL) {
79 +            LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
80 +
81 +            if (ljData != NULL) {
82 +                LJParam ljParam = ljData->getData();
83 +                
84 +                newLJtype(&atp.ident, &ljParam.sigma, &ljParam.epsilon, &isError);
85 +
86 +                if (isError != 0) {
87 +                    sprintf( painCave.errMsg,
88 +                           "Fortran rejected newLJtype\n");
89 +                    painCave.severity = OOPSE_ERROR;
90 +                    painCave.isFatal = 1;
91 +                    simError();          
92 +                }
93 +                
94 +            } else {
95 +                    sprintf( painCave.errMsg,
96 +                           "Can not cast GenericData to LJParam\n");
97 +                    painCave.severity = OOPSE_ERROR;
98 +                    painCave.isFatal = 1;
99 +                    simError();          
100 +            }            
101 +        } else {
102 +            sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
103 +            painCave.severity = OOPSE_ERROR;
104 +            painCave.isFatal = 1;
105 +            simError();          
106 +        }
107 +    }
108 +
109 +    if (isCharge()) {
110 +        data = getPropertyByName("Charge");
111 +        if (data != NULL) {
112 +            DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data);
113 +
114 +            if (doubleData != NULL) {
115 +                double charge = doubleData->getData();
116 +                newChargeType(&atp.ident, &charge, &isError);
117 +
118 +                if (isError != 0) {
119 +                    sprintf( painCave.errMsg,
120 +                           "Fortran rejected newChargeType\n");
121 +                    painCave.severity = OOPSE_ERROR;
122 +                    painCave.isFatal = 1;
123 +                    simError();          
124 +                }
125 +            } else {
126 +                    sprintf( painCave.errMsg,
127 +                           "Can not cast GenericData to DoubleGenericData\n");
128 +                    painCave.severity = OOPSE_ERROR;
129 +                    painCave.isFatal = 1;
130 +                    simError();          
131 +            }
132 +        } else {
133 +            sprintf( painCave.errMsg, "Can not find Charge Parameters\n");
134 +            painCave.severity = OOPSE_ERROR;
135 +            painCave.isFatal = 1;
136 +            simError();          
137 +        }
138 +    }
139 +
140 +    if (isEAM()) {
141 +        data = getPropertyByName("EAM");
142 +        if (data != NULL) {
143 +            EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
144 +
145 +            if (eamData != NULL) {
146 +
147 +                EAMParam eamParam = eamData->getData();
148 +                
149 +
150 +                newEAMtype(&eamParam.latticeConstant, &eamParam.nrho, &eamParam.drho,  &eamParam.nr, &eamParam.dr, &eamParam.rcut,
151 +                                &eamParam.rvals[0], &eamParam.rhovals[0], &eamParam.Frhovals[0], &atp.ident, &isError );
152 +
153 +                if (isError != 0) {
154 +                    sprintf( painCave.errMsg,
155 +                           "Fortran rejected newEAMtype\n");
156 +                    painCave.severity = OOPSE_ERROR;
157 +                    painCave.isFatal = 1;
158 +                    simError();          
159 +                }
160 +            } else {
161 +                    sprintf( painCave.errMsg,
162 +                           "Can not cast GenericData to EAMParam\n");
163 +                    painCave.severity = OOPSE_ERROR;
164 +                    painCave.isFatal = 1;
165 +                    simError();          
166 +            }
167 +        } else {
168 +            sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
169 +            painCave.severity = OOPSE_ERROR;
170 +            painCave.isFatal = 1;
171 +            simError();          
172 +        }
173 +    }
174 +
175 +    
176   }
177 +
178 + void AtomType::addProperty(GenericData* genData) {
179 +    properties_.addProperty(genData);  
180 + }
181 +
182 + void AtomType::removeProperty(const std::string& propName) {
183 +    properties_.removeProperty(propName);  
184 + }
185 +
186 + void AtomType::clearProperties() {
187 +    properties_.clearProperties();
188 + }
189 +
190 + std::vector<std::string> AtomType::getPropertyNames() {
191 +    return properties_.getPropertyNames();  
192 + }
193 +      
194 + std::vector<GenericData*> AtomType::getProperties() {
195 +    return properties_.getProperties();
196 + }
197 +
198 + GenericData* AtomType::getPropertyByName(const std::string& propName) {
199 +    return properties_.getPropertyByName(propName);
200 + }  
201 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines