Changes in src/molecule_geometry.cpp [112b09:0632c5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
r112b09 r0632c5 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 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 50 46 51 delete(Center); 52 delete(CenterBox); 47 53 return status; 48 54 }; … … 55 61 { 56 62 bool status = true; 57 double * const cell_size = World::getInstance().getDomain(); 58 double *M = ReturnFullMatrixforSymmetric(cell_size); 59 double *Minv = InverseMatrix(M); 60 61 // go through all atoms 62 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 63 64 delete[](M); 65 delete[](Minv); 63 Box &domain = World::getInstance().getDomain(); 64 65 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 66 66 67 return status; 67 68 }; … … 119 120 Center += (*iter)->x; 120 121 } 121 Center.Scale(-1./ Num); // divide through total number (and sign for direction)122 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 122 123 Translate(&Center); 123 124 Center.Zero(); … … 141 142 (*a) += (*iter)->x; 142 143 } 143 a->Scale(1./ Num); // divide through total mass (and sign for direction)144 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) 144 145 } 145 146 return a; … … 152 153 { 153 154 Vector *a = new Vector(0.5,0.5,0.5); 154 155 const double *cell_size = World::getInstance().getDomain(); 156 double *M = ReturnFullMatrixforSymmetric(cell_size); 157 a->MatrixMultiplication(M); 158 delete[](M); 159 155 const Matrix &M = World::getInstance().getDomain().getM(); 156 (*a) *= M; 160 157 return a; 161 158 }; … … 180 177 (*a) += tmp; 181 178 } 182 a->Scale(1./Num); // divide through total mass (and sign for direction)179 a->Scale(1./Num); // divide through total mass 183 180 } 184 181 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 243 240 void molecule::TranslatePeriodically(const Vector *trans) 244 241 { 245 double * const cell_size = World::getInstance().getDomain(); 246 double *M = ReturnFullMatrixforSymmetric(cell_size); 247 double *Minv = InverseMatrix(M); 242 Box &domain = World::getInstance().getDomain(); 248 243 249 244 // go through all atoms 250 245 ActOnAllVectors( &Vector::AddVector, *trans); 251 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 252 253 delete[](M); 254 delete[](Minv); 246 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 247 255 248 }; 256 249 … … 263 256 OBSERVE; 264 257 Plane p(*n,0); 265 BOOST_FOREACH( atom* iter, atoms ){ 266 (*iter->node) = p.mirrorVector(*iter->node); 267 } 258 atoms.transformNodes(boost::bind(&Plane::mirrorVector,p,_1)); 268 259 }; 269 260 … … 273 264 void molecule::DeterminePeriodicCenter(Vector ¢er) 274 265 { 275 double * const cell_size = World::getInstance().getDomain(); 276 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 277 double *inversematrix = InverseMatrix(matrix); 266 const Matrix &matrix = World::getInstance().getDomain().getM(); 267 const Matrix &inversematrix = World::getInstance().getDomain().getM(); 278 268 double tmp; 279 269 bool flag; … … 287 277 if ((*iter)->type->Z != 1) { 288 278 #endif 289 Testvector = (*iter)->x; 290 Testvector.MatrixMultiplication(inversematrix); 279 Testvector = inversematrix * (*iter)->x; 291 280 Translationvector.Zero(); 292 281 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 305 294 } 306 295 Testvector += Translationvector; 307 Testvector .MatrixMultiplication(matrix);296 Testvector *= matrix; 308 297 Center += Testvector; 309 298 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 312 301 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 313 302 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 314 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 315 Testvector.MatrixMultiplication(inversematrix); 303 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 316 304 Testvector += Translationvector; 317 Testvector .MatrixMultiplication(matrix);305 Testvector *= matrix; 318 306 Center += Testvector; 319 307 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 324 312 } 325 313 } while (!flag); 326 delete[](matrix);327 delete[](inversematrix);328 314 329 315 Center.Scale(1./static_cast<double>(getAtomCount())); … … 387 373 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 388 374 // the eigenvectors specify the transformation matrix 389 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 375 Matrix M = Matrix(evec->data); 376 377 BOOST_FOREACH(atom* iter, atoms){ 378 (*iter->node) *= M; 379 } 390 380 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 391 381
Note:
See TracChangeset
for help on using the changeset viewer.