86 |
|
double potential_local; |
87 |
|
double potential; |
88 |
|
int el, nSRI; |
89 |
< |
SRI** sris; |
89 |
> |
Molecule* molecules; |
90 |
|
|
91 |
< |
sris = entry_plug->sr_interactions; |
91 |
> |
molecules = entry_plug->molecules; |
92 |
|
nSRI = entry_plug->n_SRI; |
93 |
|
|
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 += molecules[el].getPotential(); |
99 |
|
} |
100 |
|
|
101 |
|
// Get total potential for entire system from MPI. |
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; |
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++){ |
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. |
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 |
|
|
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++) { |
298 |
|
vdrift[vd] = vdrift[vd] / mtot; |
299 |
|
} |
300 |
|
|
290 |
– |
return vdrift; |
301 |
|
} |
302 |
|
|