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