11 |
|
#include "simError.h" |
12 |
|
|
13 |
|
|
14 |
< |
Integrator::Integrator( SimInfo *theInfo, ForceFields* the_ff ){ |
15 |
< |
|
14 |
> |
template<typename T> Integrator<T>::Integrator(SimInfo* theInfo, |
15 |
> |
ForceFields* the_ff){ |
16 |
|
info = theInfo; |
17 |
|
myFF = the_ff; |
18 |
|
isFirst = 1; |
21 |
|
nMols = info->n_mol; |
22 |
|
|
23 |
|
// give a little love back to the SimInfo object |
24 |
< |
|
25 |
< |
if( info->the_integrator != NULL ) delete info->the_integrator; |
24 |
> |
|
25 |
> |
if (info->the_integrator != NULL){ |
26 |
> |
delete info->the_integrator; |
27 |
> |
} |
28 |
|
info->the_integrator = this; |
29 |
|
|
30 |
|
nAtoms = info->n_atoms; |
31 |
|
|
32 |
|
// check for constraints |
33 |
< |
|
34 |
< |
constrainedA = NULL; |
35 |
< |
constrainedB = NULL; |
33 |
> |
|
34 |
> |
constrainedA = NULL; |
35 |
> |
constrainedB = NULL; |
36 |
|
constrainedDsqr = NULL; |
37 |
< |
moving = NULL; |
38 |
< |
moved = NULL; |
39 |
< |
oldPos = NULL; |
40 |
< |
|
37 |
> |
moving = NULL; |
38 |
> |
moved = NULL; |
39 |
> |
oldPos = NULL; |
40 |
> |
|
41 |
|
nConstrained = 0; |
42 |
|
|
43 |
|
checkConstraints(); |
44 |
|
} |
45 |
|
|
46 |
< |
Integrator::~Integrator() { |
47 |
< |
|
46 |
< |
if( nConstrained ){ |
46 |
> |
template<typename T> Integrator<T>::~Integrator(){ |
47 |
> |
if (nConstrained){ |
48 |
|
delete[] constrainedA; |
49 |
|
delete[] constrainedB; |
50 |
|
delete[] constrainedDsqr; |
52 |
|
delete[] moved; |
53 |
|
delete[] oldPos; |
54 |
|
} |
54 |
– |
|
55 |
|
} |
56 |
|
|
57 |
< |
void Integrator::checkConstraints( void ){ |
58 |
< |
|
59 |
< |
|
57 |
> |
template<typename T> void Integrator<T>::checkConstraints(void){ |
58 |
|
isConstrained = 0; |
59 |
|
|
60 |
< |
Constraint *temp_con; |
61 |
< |
Constraint *dummy_plug; |
60 |
> |
Constraint* temp_con; |
61 |
> |
Constraint* dummy_plug; |
62 |
|
temp_con = new Constraint[info->n_SRI]; |
63 |
|
nConstrained = 0; |
64 |
|
int constrained = 0; |
65 |
< |
|
65 |
> |
|
66 |
|
SRI** theArray; |
67 |
< |
for(int i = 0; i < nMols; i++){ |
68 |
< |
|
69 |
< |
theArray = (SRI**) molecules[i].getMyBonds(); |
72 |
< |
for(int j=0; j<molecules[i].getNBonds(); j++){ |
73 |
< |
|
67 |
> |
for (int i = 0; i < nMols; i++){ |
68 |
> |
theArray = (SRI * *) molecules[i].getMyBonds(); |
69 |
> |
for (int j = 0; j < molecules[i].getNBonds(); j++){ |
70 |
|
constrained = theArray[j]->is_constrained(); |
71 |
< |
|
72 |
< |
if(constrained){ |
73 |
< |
|
74 |
< |
dummy_plug = theArray[j]->get_constraint(); |
75 |
< |
temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
76 |
< |
temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
77 |
< |
temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
78 |
< |
|
79 |
< |
nConstrained++; |
84 |
< |
constrained = 0; |
71 |
> |
|
72 |
> |
if (constrained){ |
73 |
> |
dummy_plug = theArray[j]->get_constraint(); |
74 |
> |
temp_con[nConstrained].set_a(dummy_plug->get_a()); |
75 |
> |
temp_con[nConstrained].set_b(dummy_plug->get_b()); |
76 |
> |
temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
77 |
> |
|
78 |
> |
nConstrained++; |
79 |
> |
constrained = 0; |
80 |
|
} |
81 |
|
} |
82 |
|
|
83 |
< |
theArray = (SRI**) molecules[i].getMyBends(); |
84 |
< |
for(int j=0; j<molecules[i].getNBends(); j++){ |
90 |
< |
|
83 |
> |
theArray = (SRI * *) molecules[i].getMyBends(); |
84 |
> |
for (int j = 0; j < molecules[i].getNBends(); j++){ |
85 |
|
constrained = theArray[j]->is_constrained(); |
86 |
< |
|
87 |
< |
if(constrained){ |
88 |
< |
|
89 |
< |
dummy_plug = theArray[j]->get_constraint(); |
90 |
< |
temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
91 |
< |
temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
92 |
< |
temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
93 |
< |
|
94 |
< |
nConstrained++; |
101 |
< |
constrained = 0; |
86 |
> |
|
87 |
> |
if (constrained){ |
88 |
> |
dummy_plug = theArray[j]->get_constraint(); |
89 |
> |
temp_con[nConstrained].set_a(dummy_plug->get_a()); |
90 |
> |
temp_con[nConstrained].set_b(dummy_plug->get_b()); |
91 |
> |
temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
92 |
> |
|
93 |
> |
nConstrained++; |
94 |
> |
constrained = 0; |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
< |
theArray = (SRI**) molecules[i].getMyTorsions(); |
99 |
< |
for(int j=0; j<molecules[i].getNTorsions(); j++){ |
107 |
< |
|
98 |
> |
theArray = (SRI * *) molecules[i].getMyTorsions(); |
99 |
> |
for (int j = 0; j < molecules[i].getNTorsions(); j++){ |
100 |
|
constrained = theArray[j]->is_constrained(); |
101 |
< |
|
102 |
< |
if(constrained){ |
103 |
< |
|
104 |
< |
dummy_plug = theArray[j]->get_constraint(); |
105 |
< |
temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
106 |
< |
temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
107 |
< |
temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
108 |
< |
|
109 |
< |
nConstrained++; |
118 |
< |
constrained = 0; |
101 |
> |
|
102 |
> |
if (constrained){ |
103 |
> |
dummy_plug = theArray[j]->get_constraint(); |
104 |
> |
temp_con[nConstrained].set_a(dummy_plug->get_a()); |
105 |
> |
temp_con[nConstrained].set_b(dummy_plug->get_b()); |
106 |
> |
temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
107 |
> |
|
108 |
> |
nConstrained++; |
109 |
> |
constrained = 0; |
110 |
|
} |
111 |
|
} |
112 |
|
} |
113 |
|
|
114 |
< |
if(nConstrained > 0){ |
124 |
< |
|
114 |
> |
if (nConstrained > 0){ |
115 |
|
isConstrained = 1; |
116 |
|
|
117 |
< |
if(constrainedA != NULL ) delete[] constrainedA; |
118 |
< |
if(constrainedB != NULL ) delete[] constrainedB; |
119 |
< |
if(constrainedDsqr != NULL ) delete[] constrainedDsqr; |
117 |
> |
if (constrainedA != NULL) |
118 |
> |
delete[] constrainedA; |
119 |
> |
if (constrainedB != NULL) |
120 |
> |
delete[] constrainedB; |
121 |
> |
if (constrainedDsqr != NULL) |
122 |
> |
delete[] constrainedDsqr; |
123 |
|
|
124 |
< |
constrainedA = new int[nConstrained]; |
125 |
< |
constrainedB = new int[nConstrained]; |
124 |
> |
constrainedA = new int[nConstrained]; |
125 |
> |
constrainedB = new int[nConstrained]; |
126 |
|
constrainedDsqr = new double[nConstrained]; |
127 |
< |
|
128 |
< |
for( int i = 0; i < nConstrained; i++){ |
136 |
< |
|
127 |
> |
|
128 |
> |
for (int i = 0; i < nConstrained; i++){ |
129 |
|
constrainedA[i] = temp_con[i].get_a(); |
130 |
|
constrainedB[i] = temp_con[i].get_b(); |
131 |
|
constrainedDsqr[i] = temp_con[i].get_dsqr(); |
140 |
– |
|
132 |
|
} |
133 |
|
|
134 |
< |
|
134 |
> |
|
135 |
|
// save oldAtoms to check for lode balanceing later on. |
136 |
< |
|
136 |
> |
|
137 |
|
oldAtoms = nAtoms; |
138 |
< |
|
138 |
> |
|
139 |
|
moving = new int[nAtoms]; |
140 |
< |
moved = new int[nAtoms]; |
140 |
> |
moved = new int[nAtoms]; |
141 |
|
|
142 |
< |
oldPos = new double[nAtoms*3]; |
142 |
> |
oldPos = new double[nAtoms * 3]; |
143 |
|
} |
144 |
< |
|
144 |
> |
|
145 |
|
delete[] temp_con; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
< |
void Integrator::integrate( void ){ |
159 |
< |
|
149 |
> |
template<typename T> void Integrator<T>::integrate(void){ |
150 |
|
int i, j; // loop counters |
151 |
|
|
152 |
< |
double runTime = info->run_time; |
153 |
< |
double sampleTime = info->sampleTime; |
154 |
< |
double statusTime = info->statusTime; |
152 |
> |
double runTime = info->run_time; |
153 |
> |
double sampleTime = info->sampleTime; |
154 |
> |
double statusTime = info->statusTime; |
155 |
|
double thermalTime = info->thermalTime; |
156 |
|
|
157 |
|
double currSample; |
158 |
|
double currThermal; |
159 |
|
double currStatus; |
170 |
– |
double currTime; |
160 |
|
|
161 |
|
int calcPot, calcStress; |
162 |
|
int isError; |
163 |
|
|
164 |
+ |
tStats = new Thermo(info); |
165 |
+ |
statOut = new StatWriter(info); |
166 |
+ |
dumpOut = new DumpWriter(info); |
167 |
|
|
176 |
– |
|
177 |
– |
tStats = new Thermo( info ); |
178 |
– |
statOut = new StatWriter( info ); |
179 |
– |
dumpOut = new DumpWriter( info ); |
180 |
– |
|
168 |
|
atoms = info->atoms; |
169 |
|
DirectionalAtom* dAtom; |
170 |
|
|
173 |
|
|
174 |
|
// initialize the forces before the first step |
175 |
|
|
176 |
< |
myFF->doForces(1,1); |
176 |
> |
calcForce(1, 1); |
177 |
|
|
178 |
< |
if( info->setTemp ){ |
179 |
< |
|
193 |
< |
tStats->velocitize(); |
178 |
> |
if (info->setTemp){ |
179 |
> |
thermalize(); |
180 |
|
} |
181 |
+ |
|
182 |
+ |
calcPot = 0; |
183 |
+ |
calcStress = 0; |
184 |
+ |
currSample = sampleTime; |
185 |
+ |
currThermal = thermalTime; |
186 |
+ |
currStatus = statusTime; |
187 |
|
|
196 |
– |
dumpOut->writeDump( 0.0 ); |
197 |
– |
statOut->writeStat( 0.0 ); |
198 |
– |
|
188 |
|
calcPot = 0; |
189 |
|
calcStress = 0; |
190 |
< |
currSample = sampleTime; |
191 |
< |
currThermal = thermalTime; |
192 |
< |
currStatus = statusTime; |
204 |
< |
currTime = 0.0;; |
190 |
> |
currSample = sampleTime + info->getTime(); |
191 |
> |
currThermal = thermalTime+ info->getTime(); |
192 |
> |
currStatus = statusTime + info->getTime(); |
193 |
|
|
194 |
+ |
dumpOut->writeDump(info->getTime()); |
195 |
+ |
statOut->writeStat(info->getTime()); |
196 |
|
|
197 |
|
readyCheck(); |
198 |
|
|
199 |
|
#ifdef IS_MPI |
200 |
< |
strcpy( checkPointMsg, |
211 |
< |
"The integrator is ready to go." ); |
200 |
> |
strcpy(checkPointMsg, "The integrator is ready to go."); |
201 |
|
MPIcheckPoint(); |
202 |
|
#endif // is_mpi |
203 |
|
|
204 |
< |
|
205 |
< |
pos = Atom::getPosArray(); |
217 |
< |
vel = Atom::getVelArray(); |
218 |
< |
frc = Atom::getFrcArray(); |
219 |
< |
trq = Atom::getTrqArray(); |
220 |
< |
Amat = Atom::getAmatArray(); |
221 |
< |
|
222 |
< |
while( currTime < runTime ){ |
223 |
< |
|
224 |
< |
if( (currTime+dt) >= currStatus ){ |
204 |
> |
while (info->getTime() < runTime){ |
205 |
> |
if ((info->getTime() + dt) >= currStatus){ |
206 |
|
calcPot = 1; |
207 |
|
calcStress = 1; |
208 |
|
} |
209 |
|
|
210 |
< |
integrateStep( calcPot, calcStress ); |
230 |
< |
|
231 |
< |
currTime += dt; |
210 |
> |
integrateStep(calcPot, calcStress); |
211 |
|
|
212 |
< |
if( info->setTemp ){ |
213 |
< |
if( currTime >= currThermal ){ |
214 |
< |
tStats->velocitize(); |
215 |
< |
currThermal += thermalTime; |
212 |
> |
info->incrTime(dt); |
213 |
> |
|
214 |
> |
if (info->setTemp){ |
215 |
> |
if (info->getTime() >= currThermal){ |
216 |
> |
thermalize(); |
217 |
> |
currThermal += thermalTime; |
218 |
|
} |
219 |
|
} |
220 |
|
|
221 |
< |
if( currTime >= currSample ){ |
222 |
< |
dumpOut->writeDump( currTime ); |
221 |
> |
if (info->getTime() >= currSample){ |
222 |
> |
dumpOut->writeDump(info->getTime()); |
223 |
|
currSample += sampleTime; |
224 |
|
} |
225 |
|
|
226 |
< |
if( currTime >= currStatus ){ |
227 |
< |
statOut->writeStat( currTime ); |
226 |
> |
if (info->getTime() >= currStatus){ |
227 |
> |
statOut->writeStat(info->getTime()); |
228 |
|
calcPot = 0; |
229 |
|
calcStress = 0; |
230 |
|
currStatus += statusTime; |
231 |
|
} |
232 |
|
|
233 |
|
#ifdef IS_MPI |
234 |
< |
strcpy( checkPointMsg, |
254 |
< |
"successfully took a time step." ); |
234 |
> |
strcpy(checkPointMsg, "successfully took a time step."); |
235 |
|
MPIcheckPoint(); |
236 |
|
#endif // is_mpi |
257 |
– |
|
237 |
|
} |
238 |
|
|
239 |
< |
dumpOut->writeFinal(); |
239 |
> |
dumpOut->writeFinal(info->getTime()); |
240 |
|
|
241 |
|
delete dumpOut; |
242 |
|
delete statOut; |
243 |
|
} |
244 |
|
|
245 |
< |
void Integrator::integrateStep( int calcPot, int calcStress ){ |
246 |
< |
|
268 |
< |
|
269 |
< |
|
245 |
> |
template<typename T> void Integrator<T>::integrateStep(int calcPot, |
246 |
> |
int calcStress){ |
247 |
|
// Position full step, and velocity half step |
271 |
– |
|
248 |
|
preMove(); |
249 |
+ |
|
250 |
|
moveA(); |
274 |
– |
if( nConstrained ) constrainA(); |
251 |
|
|
252 |
+ |
if (nConstrained){ |
253 |
+ |
constrainA(); |
254 |
+ |
} |
255 |
+ |
|
256 |
+ |
|
257 |
+ |
#ifdef IS_MPI |
258 |
+ |
strcpy(checkPointMsg, "Succesful moveA\n"); |
259 |
+ |
MPIcheckPoint(); |
260 |
+ |
#endif // is_mpi |
261 |
+ |
|
262 |
+ |
|
263 |
|
// calc forces |
264 |
|
|
265 |
< |
myFF->doForces(calcPot,calcStress); |
265 |
> |
calcForce(calcPot, calcStress); |
266 |
|
|
267 |
+ |
#ifdef IS_MPI |
268 |
+ |
strcpy(checkPointMsg, "Succesful doForces\n"); |
269 |
+ |
MPIcheckPoint(); |
270 |
+ |
#endif // is_mpi |
271 |
+ |
|
272 |
+ |
|
273 |
|
// finish the velocity half step |
274 |
< |
|
274 |
> |
|
275 |
|
moveB(); |
276 |
< |
if( nConstrained ) constrainB(); |
277 |
< |
|
276 |
> |
|
277 |
> |
if (nConstrained){ |
278 |
> |
constrainB(); |
279 |
> |
} |
280 |
> |
|
281 |
> |
#ifdef IS_MPI |
282 |
> |
strcpy(checkPointMsg, "Succesful moveB\n"); |
283 |
> |
MPIcheckPoint(); |
284 |
> |
#endif // is_mpi |
285 |
|
} |
286 |
|
|
287 |
|
|
288 |
< |
void Integrator::moveA( void ){ |
289 |
< |
|
290 |
< |
int i,j,k; |
291 |
< |
int atomIndex, aMatIndex; |
288 |
> |
template<typename T> void Integrator<T>::moveA(void){ |
289 |
> |
int i, j; |
290 |
|
DirectionalAtom* dAtom; |
291 |
< |
double Tb[3]; |
292 |
< |
double ji[3]; |
291 |
> |
double Tb[3], ji[3]; |
292 |
> |
double A[3][3], I[3][3]; |
293 |
|
double angle; |
294 |
+ |
double vel[3], pos[3], frc[3]; |
295 |
+ |
double mass; |
296 |
|
|
297 |
+ |
for (i = 0; i < nAtoms; i++){ |
298 |
+ |
atoms[i]->getVel(vel); |
299 |
+ |
atoms[i]->getPos(pos); |
300 |
+ |
atoms[i]->getFrc(frc); |
301 |
|
|
302 |
+ |
mass = atoms[i]->getMass(); |
303 |
|
|
304 |
< |
for( i=0; i<nAtoms; i++ ){ |
305 |
< |
atomIndex = i * 3; |
306 |
< |
aMatIndex = i * 9; |
304 |
> |
for (j = 0; j < 3; j++){ |
305 |
> |
// velocity half step |
306 |
> |
vel[j] += (dt2 * frc[j] / mass) * eConvert; |
307 |
> |
// position whole step |
308 |
> |
pos[j] += dt * vel[j]; |
309 |
> |
} |
310 |
|
|
311 |
< |
// velocity half step |
312 |
< |
for( j=atomIndex; j<(atomIndex+3); j++ ) |
305 |
< |
vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert; |
311 |
> |
atoms[i]->setVel(vel); |
312 |
> |
atoms[i]->setPos(pos); |
313 |
|
|
314 |
< |
// position whole step |
315 |
< |
for( j=atomIndex; j<(atomIndex+3); j++ ) pos[j] += dt * vel[j]; |
309 |
< |
|
310 |
< |
if( atoms[i]->isDirectional() ){ |
314 |
> |
if (atoms[i]->isDirectional()){ |
315 |
> |
dAtom = (DirectionalAtom *) atoms[i]; |
316 |
|
|
312 |
– |
dAtom = (DirectionalAtom *)atoms[i]; |
313 |
– |
|
317 |
|
// get and convert the torque to body frame |
318 |
< |
|
319 |
< |
Tb[0] = dAtom->getTx(); |
320 |
< |
Tb[1] = dAtom->getTy(); |
321 |
< |
Tb[2] = dAtom->getTz(); |
319 |
< |
|
320 |
< |
dAtom->lab2Body( Tb ); |
321 |
< |
|
318 |
> |
|
319 |
> |
dAtom->getTrq(Tb); |
320 |
> |
dAtom->lab2Body(Tb); |
321 |
> |
|
322 |
|
// get the angular momentum, and propagate a half step |
323 |
< |
|
324 |
< |
ji[0] = dAtom->getJx() + ( dt2 * Tb[0] ) * eConvert; |
325 |
< |
ji[1] = dAtom->getJy() + ( dt2 * Tb[1] ) * eConvert; |
326 |
< |
ji[2] = dAtom->getJz() + ( dt2 * Tb[2] ) * eConvert; |
327 |
< |
|
323 |
> |
|
324 |
> |
dAtom->getJ(ji); |
325 |
> |
|
326 |
> |
for (j = 0; j < 3; j++) |
327 |
> |
ji[j] += (dt2 * Tb[j]) * eConvert; |
328 |
> |
|
329 |
|
// use the angular velocities to propagate the rotation matrix a |
330 |
|
// full time step |
331 |
< |
|
331 |
> |
|
332 |
> |
dAtom->getA(A); |
333 |
> |
dAtom->getI(I); |
334 |
> |
|
335 |
|
// rotate about the x-axis |
336 |
< |
angle = dt2 * ji[0] / dAtom->getIxx(); |
337 |
< |
this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] ); |
338 |
< |
|
336 |
> |
angle = dt2 * ji[0] / I[0][0]; |
337 |
> |
this->rotate(1, 2, angle, ji, A); |
338 |
> |
|
339 |
|
// rotate about the y-axis |
340 |
< |
angle = dt2 * ji[1] / dAtom->getIyy(); |
341 |
< |
this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] ); |
342 |
< |
|
340 |
> |
angle = dt2 * ji[1] / I[1][1]; |
341 |
> |
this->rotate(2, 0, angle, ji, A); |
342 |
> |
|
343 |
|
// rotate about the z-axis |
344 |
< |
angle = dt * ji[2] / dAtom->getIzz(); |
345 |
< |
this->rotate( 0, 1, angle, ji, &Amat[aMatIndex] ); |
346 |
< |
|
344 |
> |
angle = dt * ji[2] / I[2][2]; |
345 |
> |
this->rotate(0, 1, angle, ji, A); |
346 |
> |
|
347 |
|
// rotate about the y-axis |
348 |
< |
angle = dt2 * ji[1] / dAtom->getIyy(); |
349 |
< |
this->rotate( 2, 0, angle, ji, &Amat[aMatIndex] ); |
350 |
< |
|
351 |
< |
// rotate about the x-axis |
352 |
< |
angle = dt2 * ji[0] / dAtom->getIxx(); |
353 |
< |
this->rotate( 1, 2, angle, ji, &Amat[aMatIndex] ); |
354 |
< |
|
355 |
< |
dAtom->setJx( ji[0] ); |
356 |
< |
dAtom->setJy( ji[1] ); |
357 |
< |
dAtom->setJz( ji[2] ); |
348 |
> |
angle = dt2 * ji[1] / I[1][1]; |
349 |
> |
this->rotate(2, 0, angle, ji, A); |
350 |
> |
|
351 |
> |
// rotate about the x-axis |
352 |
> |
angle = dt2 * ji[0] / I[0][0]; |
353 |
> |
this->rotate(1, 2, angle, ji, A); |
354 |
> |
|
355 |
> |
|
356 |
> |
dAtom->setJ(ji); |
357 |
> |
dAtom->setA(A); |
358 |
|
} |
355 |
– |
|
359 |
|
} |
360 |
|
} |
361 |
|
|
362 |
|
|
363 |
< |
void Integrator::moveB( void ){ |
364 |
< |
int i,j,k; |
362 |
< |
int atomIndex; |
363 |
> |
template<typename T> void Integrator<T>::moveB(void){ |
364 |
> |
int i, j; |
365 |
|
DirectionalAtom* dAtom; |
366 |
< |
double Tb[3]; |
367 |
< |
double ji[3]; |
366 |
> |
double Tb[3], ji[3]; |
367 |
> |
double vel[3], frc[3]; |
368 |
> |
double mass; |
369 |
|
|
370 |
< |
for( i=0; i<nAtoms; i++ ){ |
371 |
< |
atomIndex = i * 3; |
370 |
> |
for (i = 0; i < nAtoms; i++){ |
371 |
> |
atoms[i]->getVel(vel); |
372 |
> |
atoms[i]->getFrc(frc); |
373 |
|
|
374 |
+ |
mass = atoms[i]->getMass(); |
375 |
+ |
|
376 |
|
// velocity half step |
377 |
< |
for( j=atomIndex; j<(atomIndex+3); j++ ) |
378 |
< |
vel[j] += ( dt2 * frc[j] / atoms[i]->getMass() ) * eConvert; |
377 |
> |
for (j = 0; j < 3; j++) |
378 |
> |
vel[j] += (dt2 * frc[j] / mass) * eConvert; |
379 |
|
|
380 |
< |
if( atoms[i]->isDirectional() ){ |
375 |
< |
|
376 |
< |
dAtom = (DirectionalAtom *)atoms[i]; |
377 |
< |
|
378 |
< |
// get and convert the torque to body frame |
379 |
< |
|
380 |
< |
Tb[0] = dAtom->getTx(); |
381 |
< |
Tb[1] = dAtom->getTy(); |
382 |
< |
Tb[2] = dAtom->getTz(); |
383 |
< |
|
384 |
< |
dAtom->lab2Body( Tb ); |
385 |
< |
|
386 |
< |
// get the angular momentum, and complete the angular momentum |
387 |
< |
// half step |
388 |
< |
|
389 |
< |
ji[0] = dAtom->getJx() + ( dt2 * Tb[0] ) * eConvert; |
390 |
< |
ji[1] = dAtom->getJy() + ( dt2 * Tb[1] ) * eConvert; |
391 |
< |
ji[2] = dAtom->getJz() + ( dt2 * Tb[2] ) * eConvert; |
392 |
< |
|
393 |
< |
dAtom->setJx( ji[0] ); |
394 |
< |
dAtom->setJy( ji[1] ); |
395 |
< |
dAtom->setJz( ji[2] ); |
396 |
< |
} |
397 |
< |
} |
380 |
> |
atoms[i]->setVel(vel); |
381 |
|
|
382 |
< |
} |
382 |
> |
if (atoms[i]->isDirectional()){ |
383 |
> |
dAtom = (DirectionalAtom *) atoms[i]; |
384 |
|
|
385 |
< |
void Integrator::preMove( void ){ |
402 |
< |
int i; |
385 |
> |
// get and convert the torque to body frame |
386 |
|
|
387 |
< |
if( nConstrained ){ |
387 |
> |
dAtom->getTrq(Tb); |
388 |
> |
dAtom->lab2Body(Tb); |
389 |
|
|
390 |
< |
for(i=0; i<(nAtoms*3); i++) oldPos[i] = pos[i]; |
407 |
< |
} |
408 |
< |
} |
390 |
> |
// get the angular momentum, and propagate a half step |
391 |
|
|
392 |
< |
void Integrator::constrainA(){ |
392 |
> |
dAtom->getJ(ji); |
393 |
|
|
394 |
< |
int i,j,k; |
394 |
> |
for (j = 0; j < 3; j++) |
395 |
> |
ji[j] += (dt2 * Tb[j]) * eConvert; |
396 |
> |
|
397 |
> |
|
398 |
> |
dAtom->setJ(ji); |
399 |
> |
} |
400 |
> |
} |
401 |
> |
} |
402 |
> |
|
403 |
> |
template<typename T> void Integrator<T>::preMove(void){ |
404 |
> |
int i, j; |
405 |
> |
double pos[3]; |
406 |
> |
|
407 |
> |
if (nConstrained){ |
408 |
> |
for (i = 0; i < nAtoms; i++){ |
409 |
> |
atoms[i]->getPos(pos); |
410 |
> |
|
411 |
> |
for (j = 0; j < 3; j++){ |
412 |
> |
oldPos[3 * i + j] = pos[j]; |
413 |
> |
} |
414 |
> |
} |
415 |
> |
} |
416 |
> |
} |
417 |
> |
|
418 |
> |
template<typename T> void Integrator<T>::constrainA(){ |
419 |
> |
int i, j, k; |
420 |
|
int done; |
421 |
< |
double pxab, pyab, pzab; |
422 |
< |
double rxab, ryab, rzab; |
421 |
> |
double posA[3], posB[3]; |
422 |
> |
double velA[3], velB[3]; |
423 |
> |
double pab[3]; |
424 |
> |
double rab[3]; |
425 |
|
int a, b, ax, ay, az, bx, by, bz; |
426 |
|
double rma, rmb; |
427 |
|
double dx, dy, dz; |
431 |
|
double gab; |
432 |
|
int iteration; |
433 |
|
|
434 |
< |
|
426 |
< |
|
427 |
< |
for( i=0; i<nAtoms; i++){ |
428 |
< |
|
434 |
> |
for (i = 0; i < nAtoms; i++){ |
435 |
|
moving[i] = 0; |
436 |
< |
moved[i] = 1; |
436 |
> |
moved[i] = 1; |
437 |
|
} |
438 |
|
|
439 |
|
iteration = 0; |
440 |
|
done = 0; |
441 |
< |
while( !done && (iteration < maxIteration )){ |
436 |
< |
|
441 |
> |
while (!done && (iteration < maxIteration)){ |
442 |
|
done = 1; |
443 |
< |
for(i=0; i<nConstrained; i++){ |
439 |
< |
|
443 |
> |
for (i = 0; i < nConstrained; i++){ |
444 |
|
a = constrainedA[i]; |
445 |
|
b = constrainedB[i]; |
442 |
– |
|
443 |
– |
ax = (a*3) + 0; |
444 |
– |
ay = (a*3) + 1; |
445 |
– |
az = (a*3) + 2; |
446 |
|
|
447 |
< |
bx = (b*3) + 0; |
448 |
< |
by = (b*3) + 1; |
449 |
< |
bz = (b*3) + 2; |
447 |
> |
ax = (a * 3) + 0; |
448 |
> |
ay = (a * 3) + 1; |
449 |
> |
az = (a * 3) + 2; |
450 |
|
|
451 |
< |
if( moved[a] || moved[b] ){ |
452 |
< |
|
453 |
< |
pxab = pos[ax] - pos[bx]; |
454 |
< |
pyab = pos[ay] - pos[by]; |
455 |
< |
pzab = pos[az] - pos[bz]; |
451 |
> |
bx = (b * 3) + 0; |
452 |
> |
by = (b * 3) + 1; |
453 |
> |
bz = (b * 3) + 2; |
454 |
|
|
455 |
< |
//periodic boundary condition |
456 |
< |
pxab = pxab - info->box_x * copysign(1, pxab) |
457 |
< |
* (int)( fabs(pxab / info->box_x) + 0.5); |
460 |
< |
pyab = pyab - info->box_y * copysign(1, pyab) |
461 |
< |
* (int)( fabs(pyab / info->box_y) + 0.5); |
462 |
< |
pzab = pzab - info->box_z * copysign(1, pzab) |
463 |
< |
* (int)( fabs(pzab / info->box_z) + 0.5); |
455 |
> |
if (moved[a] || moved[b]){ |
456 |
> |
atoms[a]->getPos(posA); |
457 |
> |
atoms[b]->getPos(posB); |
458 |
|
|
459 |
< |
pabsq = pxab * pxab + pyab * pyab + pzab * pzab; |
459 |
> |
for (j = 0; j < 3; j++) |
460 |
> |
pab[j] = posA[j] - posB[j]; |
461 |
|
|
462 |
< |
rabsq = constrainedDsqr[i]; |
468 |
< |
diffsq = rabsq - pabsq; |
462 |
> |
//periodic boundary condition |
463 |
|
|
464 |
< |
// the original rattle code from alan tidesley |
471 |
< |
if (fabs(diffsq) > (tol*rabsq*2)) { |
472 |
< |
rxab = oldPos[ax] - oldPos[bx]; |
473 |
< |
ryab = oldPos[ay] - oldPos[by]; |
474 |
< |
rzab = oldPos[az] - oldPos[bz]; |
464 |
> |
info->wrapVector(pab); |
465 |
|
|
466 |
< |
rxab = rxab - info->box_x * copysign(1, rxab) |
477 |
< |
* (int)( fabs(rxab / info->box_x) + 0.5); |
478 |
< |
ryab = ryab - info->box_y * copysign(1, ryab) |
479 |
< |
* (int)( fabs(ryab / info->box_y) + 0.5); |
480 |
< |
rzab = rzab - info->box_z * copysign(1, rzab) |
481 |
< |
* (int)( fabs(rzab / info->box_z) + 0.5); |
466 |
> |
pabsq = pab[0] * pab[0] + pab[1] * pab[1] + pab[2] * pab[2]; |
467 |
|
|
468 |
< |
rpab = rxab * pxab + ryab * pyab + rzab * pzab; |
468 |
> |
rabsq = constrainedDsqr[i]; |
469 |
> |
diffsq = rabsq - pabsq; |
470 |
|
|
471 |
< |
rpabsq = rpab * rpab; |
471 |
> |
// the original rattle code from alan tidesley |
472 |
> |
if (fabs(diffsq) > (tol * rabsq * 2)){ |
473 |
> |
rab[0] = oldPos[ax] - oldPos[bx]; |
474 |
> |
rab[1] = oldPos[ay] - oldPos[by]; |
475 |
> |
rab[2] = oldPos[az] - oldPos[bz]; |
476 |
|
|
477 |
+ |
info->wrapVector(rab); |
478 |
|
|
479 |
< |
if (rpabsq < (rabsq * -diffsq)){ |
479 |
> |
rpab = rab[0] * pab[0] + rab[1] * pab[1] + rab[2] * pab[2]; |
480 |
|
|
481 |
+ |
rpabsq = rpab * rpab; |
482 |
+ |
|
483 |
+ |
|
484 |
+ |
if (rpabsq < (rabsq * -diffsq)){ |
485 |
|
#ifdef IS_MPI |
486 |
< |
a = atoms[a]->getGlobalIndex(); |
487 |
< |
b = atoms[b]->getGlobalIndex(); |
486 |
> |
a = atoms[a]->getGlobalIndex(); |
487 |
> |
b = atoms[b]->getGlobalIndex(); |
488 |
|
#endif //is_mpi |
489 |
< |
sprintf( painCave.errMsg, |
490 |
< |
"Constraint failure in constrainA at atom %d and %d.\n", |
491 |
< |
a, b ); |
492 |
< |
painCave.isFatal = 1; |
493 |
< |
simError(); |
494 |
< |
} |
489 |
> |
sprintf(painCave.errMsg, |
490 |
> |
"Constraint failure in constrainA at atom %d and %d.\n", a, |
491 |
> |
b); |
492 |
> |
painCave.isFatal = 1; |
493 |
> |
simError(); |
494 |
> |
} |
495 |
|
|
496 |
< |
rma = 1.0 / atoms[a]->getMass(); |
497 |
< |
rmb = 1.0 / atoms[b]->getMass(); |
496 |
> |
rma = 1.0 / atoms[a]->getMass(); |
497 |
> |
rmb = 1.0 / atoms[b]->getMass(); |
498 |
|
|
499 |
< |
gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab ); |
499 |
> |
gab = diffsq / (2.0 * (rma + rmb) * rpab); |
500 |
|
|
501 |
< |
dx = rxab * gab; |
502 |
< |
dy = ryab * gab; |
503 |
< |
dz = rzab * gab; |
501 |
> |
dx = rab[0] * gab; |
502 |
> |
dy = rab[1] * gab; |
503 |
> |
dz = rab[2] * gab; |
504 |
|
|
505 |
< |
pos[ax] += rma * dx; |
506 |
< |
pos[ay] += rma * dy; |
507 |
< |
pos[az] += rma * dz; |
505 |
> |
posA[0] += rma * dx; |
506 |
> |
posA[1] += rma * dy; |
507 |
> |
posA[2] += rma * dz; |
508 |
|
|
509 |
< |
pos[bx] -= rmb * dx; |
515 |
< |
pos[by] -= rmb * dy; |
516 |
< |
pos[bz] -= rmb * dz; |
509 |
> |
atoms[a]->setPos(posA); |
510 |
|
|
511 |
+ |
posB[0] -= rmb * dx; |
512 |
+ |
posB[1] -= rmb * dy; |
513 |
+ |
posB[2] -= rmb * dz; |
514 |
+ |
|
515 |
+ |
atoms[b]->setPos(posB); |
516 |
+ |
|
517 |
|
dx = dx / dt; |
518 |
|
dy = dy / dt; |
519 |
|
dz = dz / dt; |
520 |
|
|
521 |
< |
vel[ax] += rma * dx; |
523 |
< |
vel[ay] += rma * dy; |
524 |
< |
vel[az] += rma * dz; |
521 |
> |
atoms[a]->getVel(velA); |
522 |
|
|
523 |
< |
vel[bx] -= rmb * dx; |
524 |
< |
vel[by] -= rmb * dy; |
525 |
< |
vel[bz] -= rmb * dz; |
523 |
> |
velA[0] += rma * dx; |
524 |
> |
velA[1] += rma * dy; |
525 |
> |
velA[2] += rma * dz; |
526 |
|
|
527 |
< |
moving[a] = 1; |
528 |
< |
moving[b] = 1; |
529 |
< |
done = 0; |
530 |
< |
} |
527 |
> |
atoms[a]->setVel(velA); |
528 |
> |
|
529 |
> |
atoms[b]->getVel(velB); |
530 |
> |
|
531 |
> |
velB[0] -= rmb * dx; |
532 |
> |
velB[1] -= rmb * dy; |
533 |
> |
velB[2] -= rmb * dz; |
534 |
> |
|
535 |
> |
atoms[b]->setVel(velB); |
536 |
> |
|
537 |
> |
moving[a] = 1; |
538 |
> |
moving[b] = 1; |
539 |
> |
done = 0; |
540 |
> |
} |
541 |
|
} |
542 |
|
} |
543 |
< |
|
544 |
< |
for(i=0; i<nAtoms; i++){ |
538 |
< |
|
543 |
> |
|
544 |
> |
for (i = 0; i < nAtoms; i++){ |
545 |
|
moved[i] = moving[i]; |
546 |
|
moving[i] = 0; |
547 |
|
} |
549 |
|
iteration++; |
550 |
|
} |
551 |
|
|
552 |
< |
if( !done ){ |
553 |
< |
|
554 |
< |
sprintf( painCave.errMsg, |
555 |
< |
"Constraint failure in constrainA, too many iterations: %d\n", |
550 |
< |
iteration ); |
552 |
> |
if (!done){ |
553 |
> |
sprintf(painCave.errMsg, |
554 |
> |
"Constraint failure in constrainA, too many iterations: %d\n", |
555 |
> |
iteration); |
556 |
|
painCave.isFatal = 1; |
557 |
|
simError(); |
558 |
|
} |
554 |
– |
|
559 |
|
} |
560 |
|
|
561 |
< |
void Integrator::constrainB( void ){ |
562 |
< |
|
559 |
< |
int i,j,k; |
561 |
> |
template<typename T> void Integrator<T>::constrainB(void){ |
562 |
> |
int i, j, k; |
563 |
|
int done; |
564 |
+ |
double posA[3], posB[3]; |
565 |
+ |
double velA[3], velB[3]; |
566 |
|
double vxab, vyab, vzab; |
567 |
< |
double rxab, ryab, rzab; |
567 |
> |
double rab[3]; |
568 |
|
int a, b, ax, ay, az, bx, by, bz; |
569 |
|
double rma, rmb; |
570 |
|
double dx, dy, dz; |
573 |
|
double gab; |
574 |
|
int iteration; |
575 |
|
|
576 |
< |
for(i=0; i<nAtoms; i++){ |
576 |
> |
for (i = 0; i < nAtoms; i++){ |
577 |
|
moving[i] = 0; |
578 |
|
moved[i] = 1; |
579 |
|
} |
580 |
|
|
581 |
|
done = 0; |
582 |
|
iteration = 0; |
583 |
< |
while( !done && (iteration < maxIteration ) ){ |
579 |
< |
|
583 |
> |
while (!done && (iteration < maxIteration)){ |
584 |
|
done = 1; |
585 |
|
|
586 |
< |
for(i=0; i<nConstrained; i++){ |
583 |
< |
|
586 |
> |
for (i = 0; i < nConstrained; i++){ |
587 |
|
a = constrainedA[i]; |
588 |
|
b = constrainedB[i]; |
589 |
|
|
590 |
< |
ax = (a*3) + 0; |
591 |
< |
ay = (a*3) + 1; |
592 |
< |
az = (a*3) + 2; |
590 |
> |
ax = (a * 3) + 0; |
591 |
> |
ay = (a * 3) + 1; |
592 |
> |
az = (a * 3) + 2; |
593 |
|
|
594 |
< |
bx = (b*3) + 0; |
595 |
< |
by = (b*3) + 1; |
596 |
< |
bz = (b*3) + 2; |
594 |
> |
bx = (b * 3) + 0; |
595 |
> |
by = (b * 3) + 1; |
596 |
> |
bz = (b * 3) + 2; |
597 |
|
|
598 |
< |
if( moved[a] || moved[b] ){ |
599 |
< |
|
600 |
< |
vxab = vel[ax] - vel[bx]; |
598 |
< |
vyab = vel[ay] - vel[by]; |
599 |
< |
vzab = vel[az] - vel[bz]; |
598 |
> |
if (moved[a] || moved[b]){ |
599 |
> |
atoms[a]->getVel(velA); |
600 |
> |
atoms[b]->getVel(velB); |
601 |
|
|
602 |
< |
rxab = pos[ax] - pos[bx]; |
603 |
< |
ryab = pos[ay] - pos[by]; |
604 |
< |
rzab = pos[az] - pos[bz]; |
604 |
< |
|
602 |
> |
vxab = velA[0] - velB[0]; |
603 |
> |
vyab = velA[1] - velB[1]; |
604 |
> |
vzab = velA[2] - velB[2]; |
605 |
|
|
606 |
< |
rxab = rxab - info->box_x * copysign(1, rxab) |
607 |
< |
* (int)( fabs(rxab / info->box_x) + 0.5); |
608 |
< |
ryab = ryab - info->box_y * copysign(1, ryab) |
609 |
< |
* (int)( fabs(ryab / info->box_y) + 0.5); |
610 |
< |
rzab = rzab - info->box_z * copysign(1, rzab) |
611 |
< |
* (int)( fabs(rzab / info->box_z) + 0.5); |
612 |
< |
|
613 |
< |
rma = 1.0 / atoms[a]->getMass(); |
614 |
< |
rmb = 1.0 / atoms[b]->getMass(); |
606 |
> |
atoms[a]->getPos(posA); |
607 |
> |
atoms[b]->getPos(posB); |
608 |
|
|
609 |
< |
rvab = rxab * vxab + ryab * vyab + rzab * vzab; |
610 |
< |
|
618 |
< |
gab = -rvab / ( ( rma + rmb ) * constrainedDsqr[i] ); |
609 |
> |
for (j = 0; j < 3; j++) |
610 |
> |
rab[j] = posA[j] - posB[j]; |
611 |
|
|
612 |
< |
if (fabs(gab) > tol) { |
621 |
< |
|
622 |
< |
dx = rxab * gab; |
623 |
< |
dy = ryab * gab; |
624 |
< |
dz = rzab * gab; |
625 |
< |
|
626 |
< |
vel[ax] += rma * dx; |
627 |
< |
vel[ay] += rma * dy; |
628 |
< |
vel[az] += rma * dz; |
612 |
> |
info->wrapVector(rab); |
613 |
|
|
614 |
< |
vel[bx] -= rmb * dx; |
615 |
< |
vel[by] -= rmb * dy; |
616 |
< |
vel[bz] -= rmb * dz; |
617 |
< |
|
618 |
< |
moving[a] = 1; |
619 |
< |
moving[b] = 1; |
620 |
< |
done = 0; |
621 |
< |
} |
614 |
> |
rma = 1.0 / atoms[a]->getMass(); |
615 |
> |
rmb = 1.0 / atoms[b]->getMass(); |
616 |
> |
|
617 |
> |
rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab; |
618 |
> |
|
619 |
> |
gab = -rvab / ((rma + rmb) * constrainedDsqr[i]); |
620 |
> |
|
621 |
> |
if (fabs(gab) > tol){ |
622 |
> |
dx = rab[0] * gab; |
623 |
> |
dy = rab[1] * gab; |
624 |
> |
dz = rab[2] * gab; |
625 |
> |
|
626 |
> |
velA[0] += rma * dx; |
627 |
> |
velA[1] += rma * dy; |
628 |
> |
velA[2] += rma * dz; |
629 |
> |
|
630 |
> |
atoms[a]->setVel(velA); |
631 |
> |
|
632 |
> |
velB[0] -= rmb * dx; |
633 |
> |
velB[1] -= rmb * dy; |
634 |
> |
velB[2] -= rmb * dz; |
635 |
> |
|
636 |
> |
atoms[b]->setVel(velB); |
637 |
> |
|
638 |
> |
moving[a] = 1; |
639 |
> |
moving[b] = 1; |
640 |
> |
done = 0; |
641 |
> |
} |
642 |
|
} |
643 |
|
} |
644 |
|
|
645 |
< |
for(i=0; i<nAtoms; i++){ |
645 |
> |
for (i = 0; i < nAtoms; i++){ |
646 |
|
moved[i] = moving[i]; |
647 |
|
moving[i] = 0; |
648 |
|
} |
649 |
< |
|
649 |
> |
|
650 |
|
iteration++; |
651 |
|
} |
652 |
|
|
653 |
< |
if( !done ){ |
654 |
< |
|
655 |
< |
|
656 |
< |
sprintf( painCave.errMsg, |
653 |
< |
"Constraint failure in constrainB, too many iterations: %d\n", |
654 |
< |
iteration ); |
653 |
> |
if (!done){ |
654 |
> |
sprintf(painCave.errMsg, |
655 |
> |
"Constraint failure in constrainB, too many iterations: %d\n", |
656 |
> |
iteration); |
657 |
|
painCave.isFatal = 1; |
658 |
|
simError(); |
659 |
< |
} |
658 |
< |
|
659 |
> |
} |
660 |
|
} |
661 |
|
|
662 |
< |
|
663 |
< |
|
664 |
< |
|
665 |
< |
|
665 |
< |
|
666 |
< |
|
667 |
< |
void Integrator::rotate( int axes1, int axes2, double angle, double ji[3], |
668 |
< |
double A[9] ){ |
669 |
< |
|
670 |
< |
int i,j,k; |
662 |
> |
template<typename T> void Integrator<T>::rotate(int axes1, int axes2, |
663 |
> |
double angle, double ji[3], |
664 |
> |
double A[3][3]){ |
665 |
> |
int i, j, k; |
666 |
|
double sinAngle; |
667 |
|
double cosAngle; |
668 |
|
double angleSqr; |
674 |
|
|
675 |
|
// initialize the tempA |
676 |
|
|
677 |
< |
for(i=0; i<3; i++){ |
678 |
< |
for(j=0; j<3; j++){ |
679 |
< |
tempA[j][i] = A[3*i + j]; |
677 |
> |
for (i = 0; i < 3; i++){ |
678 |
> |
for (j = 0; j < 3; j++){ |
679 |
> |
tempA[j][i] = A[i][j]; |
680 |
|
} |
681 |
|
} |
682 |
|
|
683 |
|
// initialize the tempJ |
684 |
|
|
685 |
< |
for( i=0; i<3; i++) tempJ[i] = ji[i]; |
686 |
< |
|
685 |
> |
for (i = 0; i < 3; i++) |
686 |
> |
tempJ[i] = ji[i]; |
687 |
> |
|
688 |
|
// initalize rot as a unit matrix |
689 |
|
|
690 |
|
rot[0][0] = 1.0; |
694 |
|
rot[1][0] = 0.0; |
695 |
|
rot[1][1] = 1.0; |
696 |
|
rot[1][2] = 0.0; |
697 |
< |
|
697 |
> |
|
698 |
|
rot[2][0] = 0.0; |
699 |
|
rot[2][1] = 0.0; |
700 |
|
rot[2][2] = 1.0; |
701 |
< |
|
701 |
> |
|
702 |
|
// use a small angle aproximation for sin and cosine |
703 |
|
|
704 |
< |
angleSqr = angle * angle; |
704 |
> |
angleSqr = angle * angle; |
705 |
|
angleSqrOver4 = angleSqr / 4.0; |
706 |
|
top = 1.0 - angleSqrOver4; |
707 |
|
bottom = 1.0 + angleSqrOver4; |
714 |
|
|
715 |
|
rot[axes1][axes2] = sinAngle; |
716 |
|
rot[axes2][axes1] = -sinAngle; |
717 |
< |
|
717 |
> |
|
718 |
|
// rotate the momentum acoording to: ji[] = rot[][] * ji[] |
719 |
< |
|
720 |
< |
for(i=0; i<3; i++){ |
719 |
> |
|
720 |
> |
for (i = 0; i < 3; i++){ |
721 |
|
ji[i] = 0.0; |
722 |
< |
for(k=0; k<3; k++){ |
722 |
> |
for (k = 0; k < 3; k++){ |
723 |
|
ji[i] += rot[i][k] * tempJ[k]; |
724 |
|
} |
725 |
|
} |
732 |
|
// calculation as: |
733 |
|
// transpose(A[][]) = transpose(A[][]) * transpose(rot[][]) |
734 |
|
|
735 |
< |
for(i=0; i<3; i++){ |
736 |
< |
for(j=0; j<3; j++){ |
737 |
< |
A[3*j + i] = 0.0; |
738 |
< |
for(k=0; k<3; k++){ |
739 |
< |
A[3*j + i] += tempA[i][k] * rot[j][k]; |
735 |
> |
for (i = 0; i < 3; i++){ |
736 |
> |
for (j = 0; j < 3; j++){ |
737 |
> |
A[j][i] = 0.0; |
738 |
> |
for (k = 0; k < 3; k++){ |
739 |
> |
A[j][i] += tempA[i][k] * rot[j][k]; |
740 |
|
} |
741 |
|
} |
742 |
|
} |
743 |
|
} |
744 |
+ |
|
745 |
+ |
template<typename T> void Integrator<T>::calcForce(int calcPot, int calcStress){ |
746 |
+ |
myFF->doForces(calcPot, calcStress); |
747 |
+ |
} |
748 |
+ |
|
749 |
+ |
template<typename T> void Integrator<T>::thermalize(){ |
750 |
+ |
tStats->velocitize(); |
751 |
+ |
} |