Changes in src/molecule_geometry.cpp [e138de:a67d19]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
re138de ra67d19 15 15 #include "memoryallocator.hpp" 16 16 #include "molecule.hpp" 17 #include "World.hpp" 17 18 18 19 /************************************* Functions for class molecule *********************************/ … … 26 27 bool status = true; 27 28 const Vector *Center = DetermineCenterOfAll(); 29 double * const cell_size = World::get()->cell_size; 28 30 double *M = ReturnFullMatrixforSymmetric(cell_size); 29 31 double *Minv = InverseMatrix(M); … … 33 35 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 34 36 35 delete(M);36 delete(Minv);37 Free(&M); 38 Free(&Minv); 37 39 delete(Center); 38 40 return status; … … 46 48 { 47 49 bool status = true; 50 double * const cell_size = World::get()->cell_size; 48 51 double *M = ReturnFullMatrixforSymmetric(cell_size); 49 52 double *Minv = InverseMatrix(M); … … 52 55 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 53 56 54 delete(M);55 delete(Minv);57 Free(&M); 58 Free(&Minv); 56 59 return status; 57 60 }; … … 101 104 { 102 105 int Num = 0; 103 atom *ptr = start ->next; // start at first in list106 atom *ptr = start; // start at first in list 104 107 105 108 Center.Zero(); 106 109 107 if (ptr != end) { //list not empty?110 if (ptr->next != end) { //list not empty? 108 111 while (ptr->next != end) { // continue with second if present 109 112 ptr = ptr->next; … … 226 229 void molecule::TranslatePeriodically(const Vector *trans) 227 230 { 231 double * const cell_size = World::get()->cell_size; 228 232 double *M = ReturnFullMatrixforSymmetric(cell_size); 229 233 double *Minv = InverseMatrix(M); … … 233 237 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 234 238 235 delete(M);236 delete(Minv);239 Free(&M); 240 Free(&Minv); 237 241 }; 238 242 … … 252 256 { 253 257 atom *Walker = start; 258 double * const cell_size = World::get()->cell_size; 254 259 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 260 double *inversematrix = InverseMatrix(cell_size); 255 261 double tmp; 256 262 bool flag; … … 266 272 #endif 267 273 Testvector.CopyVector(&Walker->x); 268 Testvector. InverseMatrixMultiplication(matrix);274 Testvector.MatrixMultiplication(inversematrix); 269 275 Translationvector.Zero(); 270 276 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { … … 274 280 if ((fabs(tmp)) > BondDistance) { 275 281 flag = false; 276 Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;282 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl); 277 283 if (tmp > 0) 278 284 Translationvector.x[j] -= 1.; … … 285 291 Testvector.MatrixMultiplication(matrix); 286 292 Center.AddVector(&Testvector); 287 Log() << Verbose(1) << "vector is: ";293 DoLog(1) && (Log() << Verbose(1) << "vector is: "); 288 294 Testvector.Output(); 289 Log() << Verbose(0) << endl;295 DoLog(0) && (Log() << Verbose(0) << endl); 290 296 #ifdef ADDHYDROGEN 291 297 // now also change all hydrogens … … 293 299 if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) { 294 300 Testvector.CopyVector(&(*Runner)->GetOtherAtom(Walker)->x); 295 Testvector. InverseMatrixMultiplication(matrix);301 Testvector.MatrixMultiplication(inversematrix); 296 302 Testvector.AddVector(&Translationvector); 297 303 Testvector.MatrixMultiplication(matrix); 298 304 Center.AddVector(&Testvector); 299 Log() << Verbose(1) << "Hydrogen vector is: ";305 DoLog(1) && (Log() << Verbose(1) << "Hydrogen vector is: "); 300 306 Testvector.Output(); 301 Log() << Verbose(0) << endl;307 DoLog(0) && (Log() << Verbose(0) << endl); 302 308 } 303 309 } … … 307 313 } while (!flag); 308 314 Free(&matrix); 315 Free(&inversematrix); 316 309 317 Center.Scale(1./(double)AtomCount); 310 318 }; … … 344 352 } 345 353 // print InertiaTensor for debugging 346 Log() << Verbose(0) << "The inertia tensor is:" << endl;354 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl); 347 355 for(int i=0;i<NDIM;i++) { 348 356 for(int j=0;j<NDIM;j++) 349 Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";350 Log() << Verbose(0) << endl;351 } 352 Log() << Verbose(0) << endl;357 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " "); 358 DoLog(0) && (Log() << Verbose(0) << endl); 359 } 360 DoLog(0) && (Log() << Verbose(0) << endl); 353 361 354 362 // diagonalize to determine principal axis system … … 362 370 363 371 for(int i=0;i<NDIM;i++) { 364 Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);365 Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl;372 DoLog(1) && (Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i)); 373 DoLog(0) && (Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl); 366 374 } 367 375 368 376 // check whether we rotate or not 369 377 if (DoRotate) { 370 Log() << Verbose(1) << "Transforming molecule into PAS ... ";378 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 371 379 // the eigenvectors specify the transformation matrix 372 380 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 373 Log() << Verbose(0) << "done." << endl;381 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 374 382 375 383 // summing anew for debugging (resulting matrix has to be diagonal!) … … 396 404 } 397 405 // print InertiaTensor for debugging 398 Log() << Verbose(0) << "The inertia tensor is:" << endl;406 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl); 399 407 for(int i=0;i<NDIM;i++) { 400 408 for(int j=0;j<NDIM;j++) 401 Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";402 Log() << Verbose(0) << endl;403 } 404 Log() << Verbose(0) << endl;409 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " "); 410 DoLog(0) && (Log() << Verbose(0) << endl); 411 } 412 DoLog(0) && (Log() << Verbose(0) << endl); 405 413 } 406 414 … … 425 433 426 434 // rotate on z-x plane 427 Log() << Verbose(0) << "Begin of Aligning all atoms." << endl;435 DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl); 428 436 alpha = atan(-n->x[0]/n->x[2]); 429 Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";437 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 430 438 while (ptr->next != end) { 431 439 ptr = ptr->next; … … 443 451 n->x[0] = cos(alpha) * tmp + sin(alpha) * n->x[2]; 444 452 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 445 Log() << Verbose(1) << "alignment vector after first rotation: ";453 DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: "); 446 454 n->Output(); 447 Log() << Verbose(0) << endl;455 DoLog(0) && (Log() << Verbose(0) << endl); 448 456 449 457 // rotate on z-y plane 450 458 ptr = start; 451 459 alpha = atan(-n->x[1]/n->x[2]); 452 Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";460 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 453 461 while (ptr->next != end) { 454 462 ptr = ptr->next; … … 467 475 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 468 476 469 Log() << Verbose(1) << "alignment vector after second rotation: ";477 DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: "); 470 478 n->Output(); 471 Log() << Verbose(1) << endl;472 Log() << Verbose(0) << "End of Aligning all atoms." << endl;479 DoLog(1) && (Log() << Verbose(1) << endl); 480 DoLog(0) && (Log() << Verbose(0) << "End of Aligning all atoms." << endl); 473 481 }; 474 482
Note:
See TracChangeset
for help on using the changeset viewer.