| 248 |
|
void Thermo::velocitize() { |
| 249 |
|
|
| 250 |
|
double aVel[3], aJ[3], I[3][3]; |
| 251 |
< |
int i, j, vr, vd; // velocity randomizer loop counters |
| 251 |
> |
int i, j, l, m, n, vr, vd; // velocity randomizer loop counters |
| 252 |
|
double vdrift[3]; |
| 253 |
|
double vbar; |
| 254 |
|
const double kb = 8.31451e-7; // kb in amu, angstroms, fs, etc. |
| 255 |
|
double av2; |
| 256 |
|
double kebar; |
| 257 |
– |
int n_atoms; |
| 258 |
– |
Atom** atoms; |
| 259 |
– |
DirectionalAtom* dAtom; |
| 257 |
|
double temperature; |
| 258 |
< |
int n_oriented; |
| 262 |
< |
int n_constraints; |
| 258 |
> |
int nobj; |
| 259 |
|
|
| 260 |
< |
atoms = info->atoms; |
| 261 |
< |
n_atoms = info->n_atoms; |
| 260 |
> |
nobj = info->integrableObjects.size(); |
| 261 |
> |
|
| 262 |
|
temperature = info->target_temp; |
| 267 |
– |
n_oriented = info->n_oriented; |
| 268 |
– |
n_constraints = info->n_constraints; |
| 263 |
|
|
| 264 |
|
kebar = kb * temperature * (double)info->ndfRaw / |
| 265 |
|
( 2.0 * (double)info->ndf ); |
| 266 |
|
|
| 267 |
< |
for(vr = 0; vr < n_atoms; vr++){ |
| 267 |
> |
for(vr = 0; vr < nobj; vr++){ |
| 268 |
|
|
| 269 |
|
// uses equipartition theory to solve for vbar in angstrom/fs |
| 270 |
|
|
| 271 |
< |
av2 = 2.0 * kebar / atoms[vr]->getMass(); |
| 271 |
> |
av2 = 2.0 * kebar / info->integrableObjects[vr]->getMass(); |
| 272 |
|
vbar = sqrt( av2 ); |
| 273 |
|
|
| 274 |
|
// picks random velocities from a gaussian distribution |
| 277 |
|
for (j=0; j<3; j++) |
| 278 |
|
aVel[j] = vbar * gaussStream->getGaussian(); |
| 279 |
|
|
| 280 |
< |
atoms[vr]->setVel( aVel ); |
| 280 |
> |
info->integrableObjects[vr]->setVel( aVel ); |
| 281 |
> |
|
| 282 |
> |
if(info->integrableObjects[vr]->isDirectional()){ |
| 283 |
|
|
| 284 |
+ |
info->integrableObjects[vr]->getI( I ); |
| 285 |
+ |
|
| 286 |
+ |
if (info->integrableObjects[vr]->isLinear()) { |
| 287 |
+ |
|
| 288 |
+ |
l= info->integrableObjects[vr]->linearAxis(); |
| 289 |
+ |
m = (l+1)%3; |
| 290 |
+ |
n = (l+2)%3; |
| 291 |
+ |
|
| 292 |
+ |
aJ[l] = 0.0; |
| 293 |
+ |
vbar = sqrt( 2.0 * kebar * I[m][m] ); |
| 294 |
+ |
aJ[m] = vbar * gaussStream->getGaussian(); |
| 295 |
+ |
vbar = sqrt( 2.0 * kebar * I[n][n] ); |
| 296 |
+ |
aJ[n] = vbar * gaussStream->getGaussian(); |
| 297 |
+ |
|
| 298 |
+ |
} else { |
| 299 |
+ |
for (j = 0 ; j < 3; j++) { |
| 300 |
+ |
vbar = sqrt( 2.0 * kebar * I[j][j] ); |
| 301 |
+ |
aJ[j] = vbar * gaussStream->getGaussian(); |
| 302 |
+ |
} |
| 303 |
+ |
} // else isLinear |
| 304 |
+ |
|
| 305 |
+ |
info->integrableObjects[vr]->setJ( aJ ); |
| 306 |
+ |
|
| 307 |
+ |
}//isDirectional |
| 308 |
+ |
|
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
// Get the Center of Mass drift velocity. |
| 315 |
|
// Corrects for the center of mass drift. |
| 316 |
|
// sums all the momentum and divides by total mass. |
| 317 |
|
|
| 318 |
< |
for(vd = 0; vd < n_atoms; vd++){ |
| 318 |
> |
for(vd = 0; vd < nobj; vd++){ |
| 319 |
|
|
| 320 |
< |
atoms[vd]->getVel(aVel); |
| 320 |
> |
info->integrableObjects[vd]->getVel(aVel); |
| 321 |
|
|
| 322 |
|
for (j=0; j < 3; j++) |
| 323 |
|
aVel[j] -= vdrift[j]; |
| 324 |
|
|
| 325 |
< |
atoms[vd]->setVel( aVel ); |
| 325 |
> |
info->integrableObjects[vd]->setVel( aVel ); |
| 326 |
|
} |
| 306 |
– |
if( n_oriented ){ |
| 307 |
– |
|
| 308 |
– |
for( i=0; i<n_atoms; i++ ){ |
| 309 |
– |
|
| 310 |
– |
if( atoms[i]->isDirectional() ){ |
| 311 |
– |
|
| 312 |
– |
dAtom = (DirectionalAtom *)atoms[i]; |
| 313 |
– |
dAtom->getI( I ); |
| 314 |
– |
|
| 315 |
– |
for (j = 0 ; j < 3; j++) { |
| 316 |
– |
|
| 317 |
– |
vbar = sqrt( 2.0 * kebar * I[j][j] ); |
| 318 |
– |
aJ[j] = vbar * gaussStream->getGaussian(); |
| 319 |
– |
|
| 320 |
– |
} |
| 321 |
– |
|
| 322 |
– |
dAtom->setJ( aJ ); |
| 327 |
|
|
| 324 |
– |
} |
| 325 |
– |
} |
| 326 |
– |
} |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
void Thermo::getCOMVel(double vdrift[3]){ |
| 332 |
|
double mtot, mtot_local; |
| 333 |
|
double aVel[3], amass; |
| 334 |
|
double vdrift_local[3]; |
| 335 |
< |
int vd, n_atoms, j; |
| 336 |
< |
Atom** atoms; |
| 335 |
> |
int vd, j; |
| 336 |
> |
int nobj; |
| 337 |
|
|
| 338 |
< |
// We are very careless here with the distinction between n_atoms and n_local |
| 338 |
< |
// We should really fix this before someone pokes an eye out. |
| 338 |
> |
nobj = info->integrableObjects.size(); |
| 339 |
|
|
| 340 |
– |
n_atoms = info->n_atoms; |
| 341 |
– |
atoms = info->atoms; |
| 342 |
– |
|
| 340 |
|
mtot_local = 0.0; |
| 341 |
|
vdrift_local[0] = 0.0; |
| 342 |
|
vdrift_local[1] = 0.0; |
| 343 |
|
vdrift_local[2] = 0.0; |
| 344 |
|
|
| 345 |
< |
for(vd = 0; vd < n_atoms; vd++){ |
| 345 |
> |
for(vd = 0; vd < nobj; vd++){ |
| 346 |
|
|
| 347 |
< |
amass = atoms[vd]->getMass(); |
| 348 |
< |
atoms[vd]->getVel( aVel ); |
| 347 |
> |
amass = info->integrableObjects[vd]->getMass(); |
| 348 |
> |
info->integrableObjects[vd]->getVel( aVel ); |
| 349 |
|
|
| 350 |
|
for(j = 0; j < 3; j++) |
| 351 |
|
vdrift_local[j] += aVel[j] * amass; |
| 374 |
|
double mtot, mtot_local; |
| 375 |
|
double aPos[3], amass; |
| 376 |
|
double COM_local[3]; |
| 377 |
< |
int i, n_atoms, j; |
| 378 |
< |
Atom** atoms; |
| 377 |
> |
int i, j; |
| 378 |
> |
int nobj; |
| 379 |
|
|
| 383 |
– |
// We are very careless here with the distinction between n_atoms and n_local |
| 384 |
– |
// We should really fix this before someone pokes an eye out. |
| 385 |
– |
|
| 386 |
– |
n_atoms = info->n_atoms; |
| 387 |
– |
atoms = info->atoms; |
| 388 |
– |
|
| 380 |
|
mtot_local = 0.0; |
| 381 |
|
COM_local[0] = 0.0; |
| 382 |
|
COM_local[1] = 0.0; |
| 383 |
|
COM_local[2] = 0.0; |
| 384 |
< |
|
| 385 |
< |
for(i = 0; i < n_atoms; i++){ |
| 384 |
> |
|
| 385 |
> |
nobj = info->integrableObjects.size(); |
| 386 |
> |
for(i = 0; i < nobj; i++){ |
| 387 |
|
|
| 388 |
< |
amass = atoms[i]->getMass(); |
| 389 |
< |
atoms[i]->getPos( aPos ); |
| 388 |
> |
amass = info->integrableObjects[i]->getMass(); |
| 389 |
> |
info->integrableObjects[i]->getPos( aPos ); |
| 390 |
|
|
| 391 |
|
for(j = 0; j < 3; j++) |
| 392 |
|
COM_local[j] += aPos[j] * amass; |
| 408 |
|
COM[i] = COM[i] / mtot; |
| 409 |
|
} |
| 410 |
|
} |
| 411 |
+ |
|
| 412 |
+ |
void Thermo::removeCOMdrift() { |
| 413 |
+ |
double vdrift[3], aVel[3]; |
| 414 |
+ |
int vd, j, nobj; |
| 415 |
+ |
|
| 416 |
+ |
nobj = info->integrableObjects.size(); |
| 417 |
+ |
|
| 418 |
+ |
// Get the Center of Mass drift velocity. |
| 419 |
+ |
|
| 420 |
+ |
getCOMVel(vdrift); |
| 421 |
+ |
|
| 422 |
+ |
// Corrects for the center of mass drift. |
| 423 |
+ |
// sums all the momentum and divides by total mass. |
| 424 |
+ |
|
| 425 |
+ |
for(vd = 0; vd < nobj; vd++){ |
| 426 |
+ |
|
| 427 |
+ |
info->integrableObjects[vd]->getVel(aVel); |
| 428 |
+ |
|
| 429 |
+ |
for (j=0; j < 3; j++) |
| 430 |
+ |
aVel[j] -= vdrift[j]; |
| 431 |
+ |
|
| 432 |
+ |
info->integrableObjects[vd]->setVel( aVel ); |
| 433 |
+ |
} |
| 434 |
+ |
} |