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

Comparing trunk/OOPSE/libmdtools/Thermo.cpp (file contents):
Revision 402 by mmeineke, Wed Mar 26 14:55:50 2003 UTC vs.
Revision 403 by chuckv, Wed Mar 26 15:37:05 2003 UTC

# Line 152 | Line 152 | void Thermo::velocitize() {
152    double vx, vy, vz;
153    double jx, jy, jz;
154    int i, vr, vd; // velocity randomizer loop counters
155 <  double *vdrift;
155 >  double vdrift[3];
156    double vbar;
157    const double kb = 8.31451e-7; // kb in amu, angstroms, fs, etc.
158    double av2;
159    double kebar;
160 <  int ndf; // number of degrees of freedom
161 <  int ndfRaw; // the raw number of degrees of freedom
160 >  int ndf, ndf_local; // number of degrees of freedom
161 >  int ndfRaw, ndfRaw_local; // the raw number of degrees of freedom
162    int n_atoms;
163    Atom** atoms;
164    DirectionalAtom* dAtom;
# Line 172 | Line 172 | void Thermo::velocitize() {
172    n_oriented    = entry_plug->n_oriented;
173    n_constraints = entry_plug->n_constraints;
174    
175 +  // Raw degrees of freedom that we have to set
176 +  ndfRaw_local = 3 * entry_plug->n_atoms + 3 * entry_plug->n_oriented;
177  
178 <  ndfRaw = 3 * n_atoms + 3 * n_oriented;
179 <  ndf = ndfRaw - n_constraints - 3;
178 >  // Degrees of freedom that can contain kinetic energy
179 >  ndf_local = 3 * entry_plug->n_atoms + 3 * entry_plug->n_oriented
180 >    - entry_plug->n_constraints;
181 >  
182 > #ifdef IS_MPI
183 >  MPI::COMM_WORLD.Allreduce(&ndf_local,&ndf,1,MPI_INT,MPI_SUM);
184 >  MPI::COMM_WORLD.Allreduce(&ndfRaw_local,&ndfRaw,1,MPI_INT,MPI_SUM);
185 > #else
186 >  ndfRaw = ndfRaw_local;
187 >  ndf = ndf_local;
188 > #endif
189 >  ndf = ndf - 3;
190 >
191    kebar = kb * temperature * (double)ndf / ( 2.0 * (double)ndfRaw );
192    
193    for(vr = 0; vr < n_atoms; vr++){
# Line 200 | Line 213 | void Thermo::velocitize() {
213  
214    // Get the Center of Mass drift velocity.
215  
216 <  vdrift = getCOMVel();
216 >  getCOMVel(vdrift);
217    
218    //  Corrects for the center of mass drift.
219    // sums all the momentum and divides by total mass.
# Line 244 | Line 257 | double* Thermo::getCOMVel(){
257    }
258   }
259  
260 < double* Thermo::getCOMVel(){
260 > void Thermo::getCOMVel(double vdrift[3]){
261  
262    double mtot, mtot_local;
250  double* vdrift;
263    double vdrift_local[3];
264    int vd, n_atoms;
265    Atom** atoms;
266  
255  vdrift = new double[3];
267    // We are very careless here with the distinction between n_atoms and n_local
268    // We should really fix this before someone pokes an eye out.
269  
# Line 275 | Line 286 | double* Thermo::getCOMVel(){
286  
287   #ifdef IS_MPI
288    MPI::COMM_WORLD.Allreduce(&mtot_local,&mtot,1,MPI_DOUBLE,MPI_SUM);
289 <  MPI::COMM_WORLD.Allreduce(&vdrift_local,&vdrift,3,MPI_DOUBLE,MPI_SUM);
289 >  MPI::COMM_WORLD.Allreduce(vdrift_local,vdrift,3,MPI_DOUBLE,MPI_SUM);
290   #else
291    mtot = mtot_local;
292    for(vd = 0; vd < 3; vd++) {
# Line 287 | Line 298 | double* Thermo::getCOMVel(){
298      vdrift[vd] = vdrift[vd] / mtot;
299    }
300    
290  return vdrift;
301   }
302  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines