Changes in src/analysis_correlation.cpp [790807:58ed4a]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
r790807 r58ed4a 15 15 #include "tesselation.hpp" 16 16 #include "tesselationhelpers.hpp" 17 #include "triangleintersectionlist.hpp" 17 18 #include "vector.hpp" 18 19 #include "verbose.hpp" 20 #include "World.hpp" 19 21 20 22 … … 34 36 35 37 if (molecules->ListOfMolecules.empty()) { 36 eLog() << Verbose(1) <<"No molecule given." << endl;38 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 37 39 return outmap; 38 40 } … … 40 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 41 43 if ((*MolWalker)->ActiveFlag) { 42 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;44 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 43 45 atom *Walker = (*MolWalker)->start; 44 46 while (Walker->next != (*MolWalker)->end) { … … 55 57 if (Walker->nr < OtherWalker->nr) 56 58 if ((type2 == NULL) || (OtherWalker->type == type2)) { 57 distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);59 distance = Walker->node->PeriodicDistance(OtherWalker->node, World::get()->cell_size); 58 60 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl; 59 61 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) ); … … 90 92 91 93 if (molecules->ListOfMolecules.empty()) { 92 eLog() << Verbose(1) <<"No molecule given." << endl;94 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 93 95 return outmap; 94 96 } … … 96 98 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 97 99 if ((*MolWalker)->ActiveFlag) { 98 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);100 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 99 101 double * FullInverseMatrix = InverseMatrix(FullMatrix); 100 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;102 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 101 103 atom *Walker = (*MolWalker)->start; 102 104 while (Walker->next != (*MolWalker)->end) { … … 174 176 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 175 177 if ((type == NULL) || (Walker->type == type)) { 176 distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);178 distance = Walker->node->PeriodicDistance(point, World::get()->cell_size); 177 179 Log() << Verbose(4) << "Current distance is " << distance << "." << endl; 178 180 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); … … 208 210 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 209 211 if ((*MolWalker)->ActiveFlag) { 210 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);212 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 211 213 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 214 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; … … 255 257 256 258 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 257 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;259 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 258 260 return outmap; 259 261 } … … 261 263 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 262 264 if ((*MolWalker)->ActiveFlag) { 263 Log() << Verbose( 2) << "Current molecule is " << *MolWalker<< "." << endl;264 atom *Walker = (*MolWalker)->start; 265 while (Walker->next != (*MolWalker)->end) { 266 Walker = Walker->next; 267 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;265 Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl; 266 atom *Walker = (*MolWalker)->start; 267 while (Walker->next != (*MolWalker)->end) { 268 Walker = Walker->next; 269 //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl; 268 270 if ((type == NULL) || (Walker->type == type)) { 269 triangle = Surface->FindClosestTriangleToVector(Walker->node, LC ); 270 if (triangle != NULL) { 271 distance = DistanceToTrianglePlane(Walker->node, triangle); 272 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 273 } 274 } 275 } 276 } 271 TriangleIntersectionList Intersections(Walker->node,Surface,LC); 272 distance = Intersections.GetSmallestDistance(); 273 triangle = Intersections.GetClosestTriangle(); 274 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 275 } 276 } 277 } else 278 Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl; 279 277 280 278 281 return outmap; … … 312 315 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 313 316 if ((*MolWalker)->ActiveFlag) { 314 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);317 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 315 318 double * FullInverseMatrix = InverseMatrix(FullMatrix); 316 319 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; … … 330 333 checkX.AddVector(&periodicX); 331 334 checkX.MatrixMultiplication(FullMatrix); 332 triangle = Surface->FindClosestTriangleToVector(&checkX, LC); 333 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle); 335 TriangleIntersectionList Intersections(&checkX,Surface,LC); 336 distance = Intersections.GetSmallestDistance(); 337 triangle = Intersections.GetClosestTriangle(); 334 338 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 335 339 ShortestDistance = distance; … … 338 342 } 339 343 // insert 340 ShortestDistance = sqrt(ShortestDistance);341 344 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 342 345 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; … … 350 353 }; 351 354 352 /** Returns the startof the bin for a given value.355 /** Returns the index of the bin for a given value. 353 356 * \param value value whose bin to look for 354 357 * \param BinWidth width of bin 355 358 * \param BinStart first bin 356 359 */ 357 doubleGetBin ( const double value, const double BinWidth, const double BinStart )358 { 359 Info FunctionInfo(__func__); 360 double bin =(double) (floor((value - BinStart)/BinWidth));361 return (bin *BinWidth+BinStart);360 int GetBin ( const double value, const double BinWidth, const double BinStart ) 361 { 362 Info FunctionInfo(__func__); 363 int bin =(int) (floor((value - BinStart)/BinWidth)); 364 return (bin); 362 365 }; 363 366 … … 372 375 *file << "BinStart\tCount" << endl; 373 376 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 374 *file << runner->first << "\t" << runner->second << endl;377 *file << setprecision(8) << runner->first << "\t" << runner->second << endl; 375 378 } 376 379 }; … … 385 388 *file << "BinStart\tAtom1\tAtom2" << endl; 386 389 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 387 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;390 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 388 391 } 389 392 }; … … 400 403 *file << runner->first; 401 404 for (int i=0;i<NDIM;i++) 402 *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);405 *file << "\t" << setprecision(8) << (runner->second.first->node->x[i] - runner->second.second->x[i]); 403 406 *file << endl; 404 407 } … … 413 416 Info FunctionInfo(__func__); 414 417 *file << "BinStart\tTriangle" << endl; 415 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 416 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 417 } 418 }; 419 418 if (!map->empty()) 419 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 420 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 421 } 422 }; 423
Note:
See TracChangeset
for help on using the changeset viewer.