ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/Thermo.cpp
(Generate patch)

Comparing trunk/mdtools/md_code/Thermo.cpp (file contents):
Revision 218 by chuckv, Sun Dec 29 19:11:05 2002 UTC vs.
Revision 221 by chuckv, Thu Jan 2 20:14:08 2003 UTC

# Line 159 | Line 159 | void Thermo::velocitize() {
159      
160      // picks random velocities from a gaussian distribution
161      // centered on vbar
162 <    
162 > #ifndef USE_SPRNG
163 >    /* If we are using mpi, we need to use the SPRNG random
164 >       generator. The non drand48 generator will just repeat
165 >       the same numbers for every node creating a non-gaussian
166 >       distribution for the simulation. drand48 is fine for the
167 >       single processor version of the code, but SPRNG should
168 >       still be preferred for consistency.
169 >    */
170 > #ifdef IS_MPI
171 > #error "SPRNG random number generator must be used for MPI"
172 > #else
173 > #warning "Using drand48 for random number generation"
174 > #endif  
175      x = drand48();
176      y = drand48();
177      vx = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
# Line 171 | Line 183 | void Thermo::velocitize() {
183      x = drand48();
184      y = drand48();
185      vz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
186 <    
186 > #endif
187 >
188 > #ifdef USE_SPRNG
189 >    vx = vbar * entry_plug->gaussStream->getGaussian();
190 >    vy = vbar * entry_plug->gaussStream->getGaussian();
191 >    vz = vbar * entry_plug->gaussStream->getGaussian();
192 > #endif
193 >
194      atoms[vr]->set_vx( vx );
195      atoms[vr]->set_vy( vy );
196      atoms[vr]->set_vz( vz );
# Line 219 | Line 238 | void Thermo::velocitize() {
238        if( atoms[i]->isDirectional() ){
239          
240          dAtom = (DirectionalAtom *)atoms[i];
241 + #ifdef IS_MPI
242 + #error "SPRNG random number generator must be used for MPI"
243 + #else
244 + #warning "Using drand48 for random number generation"
245 + #endif  
246          
247          vbar = sqrt( 2.0 * kebar * dAtom->getIxx() );
248          x = drand48();
# Line 234 | Line 258 | void Thermo::velocitize() {
258          x = drand48();
259          y = drand48();
260          jz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
261 + #endif
262 + #ifdef USE_SPRNG
263 +        vbar = sqrt( 2.0 * kebar * dAtom->getIxx() );
264 +        jx = vbar * entry_plug->gaussStream->getGaussian();
265 +
266 +        vbar = sqrt( 2.0 * kebar * dAtom->getIyy() );
267 +        jy = vbar * entry_plug->gaussStream->getGaussian();
268 +
269 +        vbar = sqrt( 2.0 * kebar * dAtom->getIzz() );
270 +        jz = vbar * entry_plug->gaussStream->getGaussian();
271 + #endif
272          
273          dAtom->setJx( jx );
274          dAtom->setJy( jy );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines