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