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 248 by chuckv, Fri Jan 3 22:04:50 2003 UTC vs.
Revision 249 by chuckv, Mon Jan 27 21:28:19 2003 UTC

# Line 1 | Line 1
1   #include <cmath>
2 +
3 + #ifdef IS_MPI
4   #include <mpi++.h>
5 + #endif //is_mpi
6  
7   #include "Thermo.hpp"
8   #include "SRI.hpp"
# Line 10 | Line 13 | Thermo::Thermo( SimInfo* the_entry_plug ) {
13  
14   Thermo::Thermo( SimInfo* the_entry_plug ) {
15    entry_plug = the_entry_plug;
16 <  baseSeed = BASE_SEED;
16 >  int baseSeed = BASE_SEED;
17    gaussStream = new gaussianSPRNG( baseSeed );
18   }
19  
# Line 62 | Line 65 | double Thermo::getKinetic(){
65   #ifdef IS_MPI
66    MPI_COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM);
67    kinetic = kinetic_global;
68 < #endif
68 > #endif //is_mpi
69  
70    kinetic = kinetic * 0.5 / e_convert;
71  
# Line 81 | Line 84 | double Thermo::getPotential(){
84  
85    potential = 0.0;
86    potential_global = 0.0;
87 <  potential += entry_plug->longRange->get_potential();;
87 >  potential += entry_plug->lrPot;
88  
89    // std::cerr << "long range potential: " << potential << "\n";
90    for( el=0; el<nSRI; el++ ){
# Line 93 | Line 96 | double Thermo::getPotential(){
96   #ifdef IS_MPI
97    MPI_COMM_WORLD.Allreduce(&potential,&potential_global,1,MPI_DOUBLE,MPI_SUM);
98    potential = potential_global;
99 < #endif
99 > #endif // is_mpi
100  
101    return potential;
102   }
# Line 178 | Line 181 | void Thermo::velocitize() {
181         single processor version of the code, but SPRNG should
182         still be preferred for consistency.
183      */
184 +
185   #ifdef IS_MPI
186   #error "SPRNG random number generator must be used for MPI"
187   #else
188   #warning "Using drand48 for random number generation"
189 < #endif  
189 > #endif  // is_mpi
190 >
191      x = drand48();
192      y = drand48();
193      vx = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
# Line 194 | Line 199 | void Thermo::velocitize() {
199      x = drand48();
200      y = drand48();
201      vz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
202 < #endif
202 > #endif // use_spring
203  
204   #ifdef USE_SPRNG
205      vx = vbar * gaussStream->getGaussian();
206      vy = vbar * gaussStream->getGaussian();
207      vz = vbar * gaussStream->getGaussian();
208 < #endif
208 > #endif // use_spring
209  
210      atoms[vr]->set_vx( vx );
211      atoms[vr]->set_vy( vy );
# Line 249 | Line 254 | void Thermo::velocitize() {
254        if( atoms[i]->isDirectional() ){
255          
256          dAtom = (DirectionalAtom *)atoms[i];
257 +
258 + #ifndef USE_SPRNG
259 +
260   #ifdef IS_MPI
261   #error "SPRNG random number generator must be used for MPI"
262 < #else
262 > #else  // is_mpi
263   #warning "Using drand48 for random number generation"
264 < #endif  
264 > #endif   // is_MPI
265          
266          vbar = sqrt( 2.0 * kebar * dAtom->getIxx() );
267          x = drand48();
# Line 269 | Line 277 | void Thermo::velocitize() {
277          x = drand48();
278          y = drand48();
279          jz = vbar * sqrt( -2.0 * log(x)) * cos(2 * M_PI * y);
280 < #endif
281 < #ifdef USE_SPRNG
280 >
281 > #else //use_sprng
282 >
283          vbar = sqrt( 2.0 * kebar * dAtom->getIxx() );
284          jx = vbar * gaussStream->getGaussian();
285  
# Line 279 | Line 288 | void Thermo::velocitize() {
288  
289          vbar = sqrt( 2.0 * kebar * dAtom->getIzz() );
290          jz = vbar * gaussStream->getGaussian();
291 < #endif
291 > #endif //use_sprng
292          
293          dAtom->setJx( jx );
294          dAtom->setJy( jy );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines