6 |
|
#include "LRI.hpp" |
7 |
|
#include "Integrator.hpp" |
8 |
|
|
9 |
+ |
#define BASE_SEED 123456789 |
10 |
|
|
11 |
+ |
Thermo::Thermo( SimInfo* the_entry_plug ) { |
12 |
+ |
entry_plug = the_entry_plug; |
13 |
+ |
baseSeed = BASE_SEED; |
14 |
+ |
gaussStream = new gaussianSPRNG( baseSeed ); |
15 |
+ |
} |
16 |
+ |
|
17 |
+ |
Thermo::~Thermo(){ |
18 |
+ |
delete gaussStream; |
19 |
+ |
} |
20 |
+ |
|
21 |
|
double Thermo::getKinetic(){ |
22 |
|
|
23 |
|
const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 |
170 |
|
|
171 |
|
// picks random velocities from a gaussian distribution |
172 |
|
// centered on vbar |
173 |
< |
|
173 |
> |
#ifndef USE_SPRNG |
174 |
> |
/* If we are using mpi, we need to use the SPRNG random |
175 |
> |
generator. The non drand48 generator will just repeat |
176 |
> |
the same numbers for every node creating a non-gaussian |
177 |
> |
distribution for the simulation. drand48 is fine for the |
178 |
> |
single processor version of the code, but SPRNG should |
179 |
> |
still be preferred for consistency. |
180 |
> |
*/ |
181 |
> |
#ifdef IS_MPI |
182 |
> |
#error "SPRNG random number generator must be used for MPI" |
183 |
> |
#else |
184 |
> |
#warning "Using drand48 for random number generation" |
185 |
> |
#endif |
186 |
|
x = drand48(); |
187 |
|
y = drand48(); |
188 |
|
vx = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
194 |
|
x = drand48(); |
195 |
|
y = drand48(); |
196 |
|
vz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
197 |
< |
|
197 |
> |
#endif |
198 |
> |
|
199 |
> |
#ifdef USE_SPRNG |
200 |
> |
vx = vbar * gaussStream->getGaussian(); |
201 |
> |
vy = vbar * gaussStream->getGaussian(); |
202 |
> |
vz = vbar * gaussStream->getGaussian(); |
203 |
> |
#endif |
204 |
> |
|
205 |
|
atoms[vr]->set_vx( vx ); |
206 |
|
atoms[vr]->set_vy( vy ); |
207 |
|
atoms[vr]->set_vz( vz ); |
249 |
|
if( atoms[i]->isDirectional() ){ |
250 |
|
|
251 |
|
dAtom = (DirectionalAtom *)atoms[i]; |
252 |
+ |
#ifdef IS_MPI |
253 |
+ |
#error "SPRNG random number generator must be used for MPI" |
254 |
+ |
#else |
255 |
+ |
#warning "Using drand48 for random number generation" |
256 |
+ |
#endif |
257 |
|
|
258 |
|
vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); |
259 |
|
x = drand48(); |
269 |
|
x = drand48(); |
270 |
|
y = drand48(); |
271 |
|
jz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y); |
272 |
+ |
#endif |
273 |
+ |
#ifdef USE_SPRNG |
274 |
+ |
vbar = sqrt( 2.0 * kebar * dAtom->getIxx() ); |
275 |
+ |
jx = vbar * gaussStream->getGaussian(); |
276 |
+ |
|
277 |
+ |
vbar = sqrt( 2.0 * kebar * dAtom->getIyy() ); |
278 |
+ |
jy = vbar * gaussStream->getGaussian(); |
279 |
+ |
|
280 |
+ |
vbar = sqrt( 2.0 * kebar * dAtom->getIzz() ); |
281 |
+ |
jz = vbar * gaussStream->getGaussian(); |
282 |
+ |
#endif |
283 |
|
|
284 |
|
dAtom->setJx( jx ); |
285 |
|
dAtom->setJy( jy ); |