Changes in src/molecule_geometry.cpp [bdc91e:aafd77]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
rbdc91e raafd77 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #endif 7 11 8 12 #include "Helpers/MemDebug.hpp" … … 14 18 #include "helpers.hpp" 15 19 #include "leastsquaremin.hpp" 20 #include "verbose.hpp" 16 21 #include "log.hpp" 17 #include "memoryallocator.hpp"18 22 #include "molecule.hpp" 19 23 #include "World.hpp" 20 24 #include "Plane.hpp" 25 #include "Matrix.hpp" 26 #include "Box.hpp" 21 27 #include <boost/foreach.hpp> 28 29 #include <gsl/gsl_eigen.h> 30 #include <gsl/gsl_multimin.h> 22 31 23 32 … … 33 42 const Vector *Center = DetermineCenterOfAll(); 34 43 const Vector *CenterBox = DetermineCenterOfBox(); 35 double * const cell_size = World::getInstance().getDomain(); 36 double *M = ReturnFullMatrixforSymmetric(cell_size); 37 double *Minv = InverseMatrix(M); 44 Box &domain = World::getInstance().getDomain(); 38 45 39 46 // go through all atoms 40 47 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 48 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);43 44 delete[](M);45 delete[](Minv); 49 BOOST_FOREACH(atom* iter, atoms){ 50 *iter->node = domain.WrapPeriodically(*iter->node); 51 } 52 46 53 delete(Center); 47 54 delete(CenterBox); … … 56 63 { 57 64 bool status = true; 58 double * const cell_size = World::getInstance().getDomain(); 59 double *M = ReturnFullMatrixforSymmetric(cell_size); 60 double *Minv = InverseMatrix(M); 65 Box &domain = World::getInstance().getDomain(); 61 66 62 67 // go through all atoms 63 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);64 65 delete[](M);66 delete[](Minv); 68 BOOST_FOREACH(atom* iter, atoms){ 69 *iter->node = domain.WrapPeriodically(*iter->node); 70 } 71 67 72 return status; 68 73 }; … … 120 125 Center += (*iter)->x; 121 126 } 122 Center.Scale(-1./ (double)Num); // divide through total number (and sign for direction)127 Center.Scale(-1./Num); // divide through total number (and sign for direction) 123 128 Translate(&Center); 124 129 Center.Zero(); … … 142 147 (*a) += (*iter)->x; 143 148 } 144 a->Scale(1./ (double)Num); // divide through total mass (and sign for direction)149 a->Scale(1./Num); // divide through total mass (and sign for direction) 145 150 } 146 151 return a; … … 153 158 { 154 159 Vector *a = new Vector(0.5,0.5,0.5); 155 156 const double *cell_size = World::getInstance().getDomain(); 157 double *M = ReturnFullMatrixforSymmetric(cell_size); 158 a->MatrixMultiplication(M); 159 delete[](M); 160 160 const Matrix &M = World::getInstance().getDomain().getM(); 161 (*a) *= M; 161 162 return a; 162 163 }; … … 181 182 (*a) += tmp; 182 183 } 183 a->Scale(1./Num); // divide through total mass 184 a->Scale(1./Num); // divide through total mass (and sign for direction) 184 185 } 185 186 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 244 245 void molecule::TranslatePeriodically(const Vector *trans) 245 246 { 246 double * const cell_size = World::getInstance().getDomain(); 247 double *M = ReturnFullMatrixforSymmetric(cell_size); 248 double *Minv = InverseMatrix(M); 247 Box &domain = World::getInstance().getDomain(); 249 248 250 249 // go through all atoms 251 250 ActOnAllVectors( &Vector::AddVector, *trans); 252 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);253 254 delete[](M);255 delete[](Minv); 251 BOOST_FOREACH(atom* iter, atoms){ 252 *iter->node = domain.WrapPeriodically(*iter->node); 253 } 254 256 255 }; 257 256 … … 264 263 OBSERVE; 265 264 Plane p(*n,0); 266 BOOST_FOREACH( 265 BOOST_FOREACH(atom* iter, atoms ){ 267 266 (*iter->node) = p.mirrorVector(*iter->node); 268 267 } … … 274 273 void molecule::DeterminePeriodicCenter(Vector ¢er) 275 274 { 276 double * const cell_size = World::getInstance().getDomain(); 277 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 278 double *inversematrix = InverseMatrix(matrix); 275 const Matrix &matrix = World::getInstance().getDomain().getM(); 276 const Matrix &inversematrix = World::getInstance().getDomain().getM(); 279 277 double tmp; 280 278 bool flag; … … 288 286 if ((*iter)->type->Z != 1) { 289 287 #endif 290 Testvector = (*iter)->x; 291 Testvector.MatrixMultiplication(inversematrix); 288 Testvector = inversematrix * (*iter)->x; 292 289 Translationvector.Zero(); 293 290 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 306 303 } 307 304 Testvector += Translationvector; 308 Testvector .MatrixMultiplication(matrix);305 Testvector *= matrix; 309 306 Center += Testvector; 310 307 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 313 310 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 314 311 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 315 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 316 Testvector.MatrixMultiplication(inversematrix); 312 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 317 313 Testvector += Translationvector; 318 Testvector .MatrixMultiplication(matrix);314 Testvector *= matrix; 319 315 Center += Testvector; 320 316 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 325 321 } 326 322 } while (!flag); 327 delete[](matrix);328 delete[](inversematrix);329 323 330 324 Center.Scale(1./static_cast<double>(getAtomCount())); … … 388 382 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 389 383 // the eigenvectors specify the transformation matrix 390 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 384 Matrix M = Matrix(evec->data); 385 BOOST_FOREACH(atom* iter, atoms){ 386 (*iter->node) *= M; 387 } 391 388 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 392 389
Note:
See TracChangeset
for help on using the changeset viewer.