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 401 by chuckv, Tue Mar 25 22:54:16 2003 UTC vs.
Revision 423 by mmeineke, Thu Mar 27 20:12:15 2003 UTC

# Line 10 | Line 10 | using namespace std;
10   #include "Thermo.hpp"
11   #include "SRI.hpp"
12   #include "Integrator.hpp"
13 +
14 + #ifdef IS_MPI
15   #define __C
16 < //#include "mpiSimulation.hpp"
16 > #include "mpiSimulation.hpp"
17 > #endif // is_mpi
18  
19 +
20   #define BASE_SEED 123456789
21  
22   Thermo::Thermo( SimInfo* the_entry_plug ) {
# Line 90 | Line 94 | double Thermo::getPotential(){
94    potential_local = 0.0;
95    potential_local += entry_plug->lrPot;
96  
97 <  for( el=0; el<nSRI; el++ ){    
98 <    potential_local += sris[el]->get_potential();
97 >  for( el=0; el<entry_plug->n_mol; el++ ){    
98 >    potential_local += entry_plug->molecules[el]->get_potential();
99    }
100  
101    // Get total potential for entire system from MPI.
# Line 148 | 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 168 | 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 196 | 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 240 | 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;
246  double* vdrift;
263    double vdrift_local[3];
264    int vd, n_atoms;
265    Atom** atoms;
266  
251  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 271 | 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 283 | Line 298 | double* Thermo::getCOMVel(){
298      vdrift[vd] = vdrift[vd] / mtot;
299    }
300    
286  return vdrift;
301   }
302  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines