1 |
|
#include <iostream> |
2 |
< |
#include <cstdlib> |
3 |
< |
#include <cmath> |
2 |
> |
#include <stdlib.h> |
3 |
> |
#include <math.h> |
4 |
|
|
5 |
|
#ifdef IS_MPI |
6 |
|
#include "mpiSimulation.hpp" |
25 |
|
if (info->the_integrator != NULL){ |
26 |
|
delete info->the_integrator; |
27 |
|
} |
28 |
< |
|
28 |
> |
|
29 |
|
nAtoms = info->n_atoms; |
30 |
|
|
31 |
|
// check for constraints |
146 |
|
|
147 |
|
|
148 |
|
template<typename T> void Integrator<T>::integrate(void){ |
149 |
– |
int i, j; // loop counters |
149 |
|
|
150 |
|
double runTime = info->run_time; |
151 |
|
double sampleTime = info->sampleTime; |
158 |
|
double currThermal; |
159 |
|
double currStatus; |
160 |
|
double currReset; |
161 |
< |
|
161 |
> |
|
162 |
|
int calcPot, calcStress; |
164 |
– |
int isError; |
163 |
|
|
164 |
|
tStats = new Thermo(info); |
165 |
|
statOut = new StatWriter(info); |
166 |
|
dumpOut = new DumpWriter(info); |
167 |
|
|
168 |
|
atoms = info->atoms; |
171 |
– |
DirectionalAtom* dAtom; |
169 |
|
|
170 |
|
dt = info->dt; |
171 |
|
dt2 = 0.5 * dt; |
172 |
|
|
173 |
+ |
readyCheck(); |
174 |
+ |
|
175 |
|
// initialize the forces before the first step |
176 |
|
|
177 |
+ |
std::cerr << "Before initial Force calc\n"; |
178 |
+ |
|
179 |
|
calcForce(1, 1); |
180 |
|
|
181 |
|
if (nConstrained){ |
182 |
|
preMove(); |
183 |
|
constrainA(); |
184 |
< |
calcForce(1, 1); |
184 |
> |
calcForce(1, 1); |
185 |
|
constrainB(); |
186 |
+ |
std::cerr << "premove done\n"; |
187 |
|
} |
188 |
< |
|
188 |
> |
|
189 |
> |
|
190 |
> |
|
191 |
|
if (info->setTemp){ |
192 |
|
thermalize(); |
193 |
|
} |
202 |
|
dumpOut->writeDump(info->getTime()); |
203 |
|
statOut->writeStat(info->getTime()); |
204 |
|
|
201 |
– |
readyCheck(); |
205 |
|
|
206 |
+ |
|
207 |
|
#ifdef IS_MPI |
208 |
|
strcpy(checkPointMsg, "The integrator is ready to go."); |
209 |
|
MPIcheckPoint(); |
232 |
|
} |
233 |
|
|
234 |
|
if (info->getTime() >= currStatus){ |
235 |
< |
statOut->writeStat(info->getTime()); |
236 |
< |
calcPot = 0; |
235 |
> |
statOut->writeStat(info->getTime()); |
236 |
> |
calcPot = 0; |
237 |
|
calcStress = 0; |
238 |
|
currStatus += statusTime; |
239 |
< |
} |
239 |
> |
} |
240 |
|
|
241 |
|
if (info->resetIntegrator){ |
242 |
|
if (info->getTime() >= currReset){ |
245 |
|
} |
246 |
|
} |
247 |
|
|
248 |
+ |
std::cerr << "done with time = " << info->getTime() << "\n"; |
249 |
+ |
|
250 |
|
#ifdef IS_MPI |
251 |
|
strcpy(checkPointMsg, "successfully took a time step."); |
252 |
|
MPIcheckPoint(); |
253 |
|
#endif // is_mpi |
254 |
|
} |
255 |
|
|
250 |
– |
dumpOut->writeFinal(info->getTime()); |
256 |
|
|
257 |
+ |
// write the last frame |
258 |
+ |
dumpOut->writeDump(info->getTime()); |
259 |
+ |
|
260 |
|
delete dumpOut; |
261 |
|
delete statOut; |
262 |
|
} |
373 |
|
if (atoms[i]->isDirectional()){ |
374 |
|
dAtom = (DirectionalAtom *) atoms[i]; |
375 |
|
|
376 |
< |
// get and convert the torque to body frame |
376 |
> |
// get and convert the torque to body frame |
377 |
|
|
378 |
|
dAtom->getTrq(Tb); |
379 |
|
dAtom->lab2Body(Tb); |
411 |
|
} |
412 |
|
|
413 |
|
template<typename T> void Integrator<T>::constrainA(){ |
414 |
< |
int i, j, k; |
414 |
> |
int i, j; |
415 |
|
int done; |
416 |
|
double posA[3], posB[3]; |
417 |
|
double velA[3], velB[3]; |
555 |
|
} |
556 |
|
|
557 |
|
template<typename T> void Integrator<T>::constrainB(void){ |
558 |
< |
int i, j, k; |
558 |
> |
int i, j; |
559 |
|
int done; |
560 |
|
double posA[3], posB[3]; |
561 |
|
double velA[3], velB[3]; |
564 |
|
int a, b, ax, ay, az, bx, by, bz; |
565 |
|
double rma, rmb; |
566 |
|
double dx, dy, dz; |
567 |
< |
double rabsq, pabsq, rvab; |
560 |
< |
double diffsq; |
567 |
> |
double rvab; |
568 |
|
double gab; |
569 |
|
int iteration; |
570 |
|
|
665 |
|
|
666 |
|
dAtom->getA(A); |
667 |
|
dAtom->getI(I); |
668 |
< |
|
669 |
< |
// rotate about the x-axis |
668 |
> |
|
669 |
> |
// rotate about the x-axis |
670 |
|
angle = dt2 * ji[0] / I[0][0]; |
671 |
< |
this->rotate( 1, 2, angle, ji, A ); |
672 |
< |
|
671 |
> |
this->rotate( 1, 2, angle, ji, A ); |
672 |
> |
|
673 |
|
// rotate about the y-axis |
674 |
|
angle = dt2 * ji[1] / I[1][1]; |
675 |
|
this->rotate( 2, 0, angle, ji, A ); |
676 |
< |
|
676 |
> |
|
677 |
|
// rotate about the z-axis |
678 |
|
angle = dt * ji[2] / I[2][2]; |
679 |
|
this->rotate( 0, 1, angle, ji, A); |
680 |
< |
|
680 |
> |
|
681 |
|
// rotate about the y-axis |
682 |
|
angle = dt2 * ji[1] / I[1][1]; |
683 |
|
this->rotate( 2, 0, angle, ji, A ); |
684 |
< |
|
684 |
> |
|
685 |
|
// rotate about the x-axis |
686 |
|
angle = dt2 * ji[0] / I[0][0]; |
687 |
|
this->rotate( 1, 2, angle, ji, A ); |
688 |
< |
|
689 |
< |
dAtom->setA( A ); |
688 |
> |
|
689 |
> |
dAtom->setA( A ); |
690 |
|
} |
691 |
|
|
692 |
|
template<typename T> void Integrator<T>::rotate(int axes1, int axes2, |
754 |
|
} |
755 |
|
} |
756 |
|
|
757 |
< |
// rotate the Rotation matrix acording to: |
757 |
> |
// rotate the Rotation matrix acording to: |
758 |
|
// A[][] = A[][] * transpose(rot[][]) |
759 |
|
|
760 |
|
|
783 |
|
template<typename T> double Integrator<T>::getConservedQuantity(void){ |
784 |
|
return tStats->getTotalE(); |
785 |
|
} |
786 |
+ |
template<typename T> string Integrator<T>::getAdditionalParameters(void){ |
787 |
+ |
//By default, return a null string |
788 |
+ |
//The reason we use string instead of char* is that if we use char*, we will |
789 |
+ |
//return a pointer point to local variable which might cause problem |
790 |
+ |
return string(); |
791 |
+ |
} |