1 |
|
#include <cmath> |
2 |
+ |
#include <iostream> |
3 |
+ |
using namespace std; |
4 |
+ |
|
5 |
+ |
#ifdef IS_MPI |
6 |
+ |
#include <mpi.h> |
7 |
|
#include <mpi++.h> |
8 |
+ |
#endif //is_mpi |
9 |
|
|
10 |
|
#include "Thermo.hpp" |
11 |
|
#include "SRI.hpp" |
12 |
|
#include "LRI.hpp" |
13 |
|
#include "Integrator.hpp" |
14 |
|
|
15 |
+ |
#define BASE_SEED 123456789 |
16 |
|
|
17 |
+ |
Thermo::Thermo( SimInfo* the_entry_plug ) { |
18 |
+ |
entry_plug = the_entry_plug; |
19 |
+ |
int baseSeed = BASE_SEED; |
20 |
+ |
|
21 |
+ |
gaussStream = new gaussianSPRNG( baseSeed ); |
22 |
+ |
} |
23 |
+ |
|
24 |
+ |
Thermo::~Thermo(){ |
25 |
+ |
delete gaussStream; |
26 |
+ |
} |
27 |
+ |
|
28 |
|
double Thermo::getKinetic(){ |
29 |
|
|
30 |
|
const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 |
67 |
|
} |
68 |
|
} |
69 |
|
#ifdef IS_MPI |
70 |
< |
MPI_COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); |
70 |
> |
MPI::COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); |
71 |
|
kinetic = kinetic_global; |
72 |
< |
#endif |
72 |
> |
#endif //is_mpi |
73 |
|
|
74 |
|
kinetic = kinetic * 0.5 / e_convert; |
75 |
|
|
88 |
|
|
89 |
|
potential = 0.0; |
90 |
|
potential_global = 0.0; |
91 |
< |
potential += entry_plug->longRange->get_potential();; |
91 |
> |
potential += entry_plug->lrPot; |
92 |
|
|
93 |
|
// std::cerr << "long range potential: " << potential << "\n"; |
94 |
|
for( el=0; el<nSRI; el++ ){ |
98 |
|
|
99 |
|
// Get total potential for entire system from MPI. |
100 |
|
#ifdef IS_MPI |
101 |
< |
MPI_COMM_WORLD.Allreduce(&potential,&potential_global,1,MPI_DOUBLE,MPI_SUM); |
101 |
> |
MPI::COMM_WORLD.Allreduce(&potential,&potential_global,1,MPI_DOUBLE,MPI_SUM); |
102 |
|
potential = potential_global; |
103 |
< |
#endif |
103 |
> |
|
104 |
> |
#endif // is_mpi |
105 |
|
|
106 |
|
return potential; |
107 |
|
} |
186 |
|
single processor version of the code, but SPRNG should |
187 |
|
still be preferred for consistency. |
188 |
|
*/ |
189 |
+ |
|
190 |
|
#ifdef IS_MPI |
191 |
|
#error "SPRNG random number generator must be used for MPI" |
192 |
|
#else |
193 |
< |
#warning "Using drand48 for random number generation" |
194 |
< |
#endif |
193 |
> |
// warning "Using drand48 for random number generation" |
194 |
> |
#endif // is_mpi |
195 |
> |
|
196 |
|
x = drand48(); |
197 |
|
y = drand48(); |
198 |
|
vx = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
204 |
|
x = drand48(); |
205 |
|
y = drand48(); |
206 |
|
vz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
186 |
– |
#endif |
207 |
|
|
208 |
+ |
#endif // use_spring |
209 |
+ |
|
210 |
|
#ifdef USE_SPRNG |
211 |
< |
vx = vbar * entry_plug->gaussStream->getGaussian(); |
212 |
< |
vy = vbar * entry_plug->gaussStream->getGaussian(); |
213 |
< |
vz = vbar * entry_plug->gaussStream->getGaussian(); |
214 |
< |
#endif |
211 |
> |
vx = vbar * gaussStream->getGaussian(); |
212 |
> |
vy = vbar * gaussStream->getGaussian(); |
213 |
> |
vz = vbar * gaussStream->getGaussian(); |
214 |
> |
#endif // use_spring |
215 |
|
|
216 |
|
atoms[vr]->set_vx( vx ); |
217 |
|
atoms[vr]->set_vy( vy ); |
260 |
|
if( atoms[i]->isDirectional() ){ |
261 |
|
|
262 |
|
dAtom = (DirectionalAtom *)atoms[i]; |
263 |
+ |
|
264 |
+ |
#ifndef USE_SPRNG |
265 |
+ |
|
266 |
|
#ifdef IS_MPI |
267 |
|
#error "SPRNG random number generator must be used for MPI" |
268 |
< |
#else |
269 |
< |
#warning "Using drand48 for random number generation" |
270 |
< |
#endif |
268 |
> |
#else // is_mpi |
269 |
> |
//warning "Using drand48 for random number generation" |
270 |
> |
#endif // is_MPI |
271 |
|
|
272 |
|
vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); |
273 |
|
x = drand48(); |
283 |
|
x = drand48(); |
284 |
|
y = drand48(); |
285 |
|
jz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
286 |
< |
#endif |
287 |
< |
#ifdef USE_SPRNG |
286 |
> |
|
287 |
> |
#else //use_sprng |
288 |
> |
|
289 |
|
vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); |
290 |
< |
jx = vbar * entry_plug->gaussStream->getGaussian(); |
290 |
> |
jx = vbar * gaussStream->getGaussian(); |
291 |
|
|
292 |
|
vbar = sqrt( 2.0 * kebar * dAtom->getIyy() ); |
293 |
< |
jy = vbar * entry_plug->gaussStream->getGaussian(); |
293 |
> |
jy = vbar * gaussStream->getGaussian(); |
294 |
|
|
295 |
|
vbar = sqrt( 2.0 * kebar * dAtom->getIzz() ); |
296 |
< |
jz = vbar * entry_plug->gaussStream->getGaussian(); |
297 |
< |
#endif |
296 |
> |
jz = vbar * gaussStream->getGaussian(); |
297 |
> |
#endif //use_sprng |
298 |
|
|
299 |
|
dAtom->setJx( jx ); |
300 |
|
dAtom->setJy( jy ); |