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 "types/DirectionalAtomType.hpp" |
43 |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
44 |
#include "UseTheForce/DarkSide/sticky_interface.h" |
45 |
#include "UseTheForce/DarkSide/gb_interface.h" |
46 |
#include "utils/simError.h" |
47 |
namespace oopse { |
48 |
|
49 |
void DirectionalAtomType::complete() { |
50 |
|
51 |
// |
52 |
AtomType::complete(); |
53 |
|
54 |
int isError = 0; |
55 |
GenericData* data; |
56 |
|
57 |
//setup dipole atom type in fortran side |
58 |
if (isDipole()) { |
59 |
data = getPropertyByName("Dipole"); |
60 |
if (data != NULL) { |
61 |
DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data); |
62 |
|
63 |
if (doubleData != NULL) { |
64 |
double dipole = doubleData->getData(); |
65 |
|
66 |
setDipoleMoment(&atp.ident, &dipole, &isError); |
67 |
if (isError != 0) { |
68 |
sprintf( painCave.errMsg, |
69 |
"Fortran rejected setDipoleMoment\n"); |
70 |
painCave.severity = OOPSE_ERROR; |
71 |
painCave.isFatal = 1; |
72 |
simError(); |
73 |
} |
74 |
|
75 |
} else { |
76 |
sprintf( painCave.errMsg, |
77 |
"Can not cast GenericData to DoubleGenericData\n"); |
78 |
painCave.severity = OOPSE_ERROR; |
79 |
painCave.isFatal = 1; |
80 |
simError(); |
81 |
} |
82 |
} else { |
83 |
sprintf( painCave.errMsg, "Can not find Dipole Parameters\n"); |
84 |
painCave.severity = OOPSE_ERROR; |
85 |
painCave.isFatal = 1; |
86 |
simError(); |
87 |
} |
88 |
} |
89 |
|
90 |
if (isSplitDipole()) { |
91 |
data = getPropertyByName("SplitDipoleDistance"); |
92 |
if (data != NULL) { |
93 |
DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data); |
94 |
|
95 |
if (doubleData != NULL) { |
96 |
double splitDipoleDistance = doubleData->getData(); |
97 |
|
98 |
setSplitDipoleDistance(&atp.ident, &splitDipoleDistance, &isError); |
99 |
if (isError != 0) { |
100 |
sprintf( painCave.errMsg, |
101 |
"Fortran rejected setSplitDipoleDistance\n"); |
102 |
painCave.severity = OOPSE_ERROR; |
103 |
painCave.isFatal = 1; |
104 |
simError(); |
105 |
} |
106 |
|
107 |
} else { |
108 |
sprintf( painCave.errMsg, |
109 |
"Can not cast GenericData to DoubleGenericData\n"); |
110 |
painCave.severity = OOPSE_ERROR; |
111 |
painCave.isFatal = 1; |
112 |
simError(); |
113 |
} |
114 |
} else { |
115 |
sprintf( painCave.errMsg, "Can not find SplitDipole distance parameter\n"); |
116 |
painCave.severity = OOPSE_ERROR; |
117 |
painCave.isFatal = 1; |
118 |
simError(); |
119 |
} |
120 |
} |
121 |
|
122 |
//setup quadrupole atom type in fortran side |
123 |
if (isQuadrupole()) { |
124 |
data = getPropertyByName("QuadrupoleMoments"); |
125 |
if (data != NULL) { |
126 |
Vector3dGenericData* vector3dData= dynamic_cast<Vector3dGenericData*>(data); |
127 |
|
128 |
// Quadrupoles in OOPSE are set as the diagonal elements |
129 |
// of the diagonalized traceless quadrupole moment tensor. |
130 |
// The column vectors of the unitary matrix that diagonalizes |
131 |
// the quadrupole moment tensor become the eFrame (or the |
132 |
// electrostatic version of the body-fixed frame. |
133 |
|
134 |
if (vector3dData != NULL) { |
135 |
Vector3d diagElem= vector3dData->getData(); |
136 |
|
137 |
setQuadrupoleMoments(&atp.ident, diagElem.getArrayPointer(), |
138 |
&isError); |
139 |
if (isError != 0) { |
140 |
sprintf( painCave.errMsg, |
141 |
"Fortran rejected setQuadrupoleMoments\n"); |
142 |
painCave.severity = OOPSE_ERROR; |
143 |
painCave.isFatal = 1; |
144 |
simError(); |
145 |
} |
146 |
|
147 |
} else { |
148 |
sprintf( painCave.errMsg, |
149 |
"Can not cast GenericData to Vector3dGenericData\n"); |
150 |
painCave.severity = OOPSE_ERROR; |
151 |
painCave.isFatal = 1; |
152 |
simError(); |
153 |
} |
154 |
} else { |
155 |
sprintf( painCave.errMsg, "Can not find QuadrupoleMoments\n"); |
156 |
painCave.severity = OOPSE_ERROR; |
157 |
painCave.isFatal = 1; |
158 |
simError(); |
159 |
} |
160 |
|
161 |
} |
162 |
|
163 |
//setup sticky atom type in fortran side |
164 |
if (isSticky() || isStickyPower()) { |
165 |
data = getPropertyByName("Sticky"); |
166 |
if (data != NULL) { |
167 |
StickyParamGenericData* stickyData = dynamic_cast<StickyParamGenericData*>(data); |
168 |
|
169 |
if (stickyData != NULL) { |
170 |
StickyParam stickyParam = stickyData->getData(); |
171 |
|
172 |
newStickyType(&atp.ident,&stickyParam.w0, &stickyParam.v0, |
173 |
&stickyParam.v0p, &stickyParam.rl, &stickyParam.ru, |
174 |
&stickyParam.rlp, &stickyParam.rup, &isError); |
175 |
if (isError != 0) { |
176 |
sprintf( painCave.errMsg, |
177 |
"Fortran rejected newLJtype\n"); |
178 |
painCave.severity = OOPSE_ERROR; |
179 |
painCave.isFatal = 1; |
180 |
simError(); |
181 |
} |
182 |
|
183 |
} else { |
184 |
sprintf( painCave.errMsg, |
185 |
"Can not cast GenericData to StickyParam\n"); |
186 |
painCave.severity = OOPSE_ERROR; |
187 |
painCave.isFatal = 1; |
188 |
simError(); |
189 |
} |
190 |
} else { |
191 |
sprintf( painCave.errMsg, "Can not find Parameters for Sticky\n"); |
192 |
painCave.severity = OOPSE_ERROR; |
193 |
painCave.isFatal = 1; |
194 |
simError(); |
195 |
} |
196 |
} |
197 |
|
198 |
//setup GayBerne type in fortran side |
199 |
if (isGayBerne()) { |
200 |
data = getPropertyByName("GayBerne"); |
201 |
if (data != NULL) { |
202 |
GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data); |
203 |
|
204 |
if (gayBerneData != NULL) { |
205 |
GayBerneParam gayBerneParam = gayBerneData->getData(); |
206 |
|
207 |
/**@todo change fortran interface */ |
208 |
//makeGayBerneType(&atp.ident, &gayBerneParam.w0, &gayBerneParam.v0, &gayBerneParam.v0p, &gayBerneParam.rl, |
209 |
// &gayBerneParam.ru, &gayBerneParam.rlp, &gayBerneParam.rup); |
210 |
newGayBerneType(&gayBerneParam.GB_sigma, &gayBerneParam.GB_12b_ratio, &gayBerneParam.GB_eps, |
211 |
&gayBerneParam.GB_eps_ratio, &gayBerneParam.GB_mu, &gayBerneParam.GB_nu); |
212 |
if (isError != 0) { |
213 |
sprintf( painCave.errMsg, |
214 |
"Fortran rejected newGayBernetype\n"); |
215 |
painCave.severity = OOPSE_ERROR; |
216 |
painCave.isFatal = 1; |
217 |
simError(); |
218 |
} |
219 |
|
220 |
} |
221 |
|
222 |
else { |
223 |
sprintf( painCave.errMsg, |
224 |
"Can not cast GenericData to GayBerneParam\n"); |
225 |
painCave.severity = OOPSE_ERROR; |
226 |
painCave.isFatal = 1; |
227 |
simError(); |
228 |
} |
229 |
} |
230 |
else { |
231 |
sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); |
232 |
painCave.severity = OOPSE_ERROR; |
233 |
painCave.isFatal = 1; |
234 |
simError(); |
235 |
} |
236 |
} |
237 |
} |
238 |
|
239 |
|
240 |
|
241 |
} //end namespace oopse |