Changes in src/molecule_geometry.cpp [f429d7:52d777]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
rf429d7 r52d777 19 19 #include "World.hpp" 20 20 #include "Plane.hpp" 21 #include "Matrix.hpp"22 #include "Box.hpp"23 21 #include <boost/foreach.hpp> 24 22 … … 35 33 const Vector *Center = DetermineCenterOfAll(); 36 34 const Vector *CenterBox = DetermineCenterOfBox(); 37 Box &domain = World::getInstance().getDomain(); 35 double * const cell_size = World::getInstance().getDomain(); 36 double *M = ReturnFullMatrixforSymmetric(cell_size); 37 double *Minv = InverseMatrix(M); 38 38 39 39 // go through all atoms 40 40 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 41 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 42 BOOST_FOREACH(atom* iter, atoms){43 *iter->node = domain.WrapPeriodically(*iter->node); 44 }45 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 43 44 delete[](M); 45 delete[](Minv); 46 46 delete(Center); 47 delete(CenterBox); 47 48 return status; 48 49 }; … … 55 56 { 56 57 bool status = true; 57 Box &domain = World::getInstance().getDomain(); 58 double * const cell_size = World::getInstance().getDomain(); 59 double *M = ReturnFullMatrixforSymmetric(cell_size); 60 double *Minv = InverseMatrix(M); 58 61 59 62 // go through all atoms 60 BOOST_FOREACH(atom* iter, atoms){61 *iter->node = domain.WrapPeriodically(*iter->node); 62 }63 63 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 64 65 delete[](M); 66 delete[](Minv); 64 67 return status; 65 68 }; … … 150 153 { 151 154 Vector *a = new Vector(0.5,0.5,0.5); 152 const Matrix &M = World::getInstance().getDomain().getM(); 153 (*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 154 161 return a; 155 162 }; … … 237 244 void molecule::TranslatePeriodically(const Vector *trans) 238 245 { 239 Box &domain = World::getInstance().getDomain(); 246 double * const cell_size = World::getInstance().getDomain(); 247 double *M = ReturnFullMatrixforSymmetric(cell_size); 248 double *Minv = InverseMatrix(M); 240 249 241 250 // go through all atoms 242 251 ActOnAllVectors( &Vector::AddVector, *trans); 243 BOOST_FOREACH(atom* iter, atoms){244 *iter->node = domain.WrapPeriodically(*iter->node); 245 }246 252 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 253 254 delete[](M); 255 delete[](Minv); 247 256 }; 248 257 … … 255 264 OBSERVE; 256 265 Plane p(*n,0); 257 BOOST_FOREACH( atom* iter, atoms ){266 BOOST_FOREACH( atom* iter, atoms ){ 258 267 (*iter->node) = p.mirrorVector(*iter->node); 259 268 } … … 265 274 void molecule::DeterminePeriodicCenter(Vector ¢er) 266 275 { 267 const Matrix &matrix = World::getInstance().getDomain().getM(); 268 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); 269 279 double tmp; 270 280 bool flag; … … 278 288 if ((*iter)->type->Z != 1) { 279 289 #endif 280 Testvector = inversematrix * (*iter)->x; 290 Testvector = (*iter)->x; 291 Testvector.MatrixMultiplication(inversematrix); 281 292 Translationvector.Zero(); 282 293 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 295 306 } 296 307 Testvector += Translationvector; 297 Testvector *= matrix;308 Testvector.MatrixMultiplication(matrix); 298 309 Center += Testvector; 299 310 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 302 313 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 303 314 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 304 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 315 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 316 Testvector.MatrixMultiplication(inversematrix); 305 317 Testvector += Translationvector; 306 Testvector *= matrix;318 Testvector.MatrixMultiplication(matrix); 307 319 Center += Testvector; 308 320 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 313 325 } 314 326 } while (!flag); 327 delete[](matrix); 328 delete[](inversematrix); 315 329 316 330 Center.Scale(1./static_cast<double>(getAtomCount())); … … 374 388 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 375 389 // the eigenvectors specify the transformation matrix 376 Matrix M = Matrix(evec->data); 377 BOOST_FOREACH(atom* iter, atoms){ 378 (*iter->node) *= M; 379 } 390 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 380 391 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 381 392
Note:
See TracChangeset
for help on using the changeset viewer.