Changes in src/analysis_correlation.cpp [a67d19:bd61b41]
- File:
-
- 1 edited
-
src/analysis_correlation.cpp (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
ra67d19 rbd61b41 15 15 #include "tesselation.hpp" 16 16 #include "tesselationhelpers.hpp" 17 #include "triangleintersectionlist.hpp"18 17 #include "vector.hpp" 19 18 #include "verbose.hpp" 20 #include "World.hpp"21 19 22 20 … … 36 34 37 35 if (molecules->ListOfMolecules.empty()) { 38 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);36 eLog() << Verbose(1) <<"No molecule given." << endl; 39 37 return outmap; 40 38 } … … 42 40 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 43 41 if ((*MolWalker)->ActiveFlag) { 44 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);45 atom *Walker = (*MolWalker)->start; 46 while (Walker->next != (*MolWalker)->end) { 47 Walker = Walker->next; 48 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);42 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 43 atom *Walker = (*MolWalker)->start; 44 while (Walker->next != (*MolWalker)->end) { 45 Walker = Walker->next; 46 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 49 47 if ((type1 == NULL) || (Walker->type == type1)) { 50 48 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 51 49 if ((*MolOtherWalker)->ActiveFlag) { 52 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);50 Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl; 53 51 atom *OtherWalker = (*MolOtherWalker)->start; 54 52 while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker 55 53 OtherWalker = OtherWalker->next; 56 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);54 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl; 57 55 if (Walker->nr < OtherWalker->nr) 58 56 if ((type2 == NULL) || (OtherWalker->type == type2)) { 59 distance = Walker->node->PeriodicDistance(OtherWalker->node, World::get()->cell_size);57 distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size); 60 58 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl; 61 59 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) ); … … 92 90 93 91 if (molecules->ListOfMolecules.empty()) { 94 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);92 eLog() << Verbose(1) <<"No molecule given." << endl; 95 93 return outmap; 96 94 } … … 98 96 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 99 97 if ((*MolWalker)->ActiveFlag) { 100 double * FullMatrix = ReturnFullMatrixforSymmetric( World::get()->cell_size);98 double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size); 101 99 double * FullInverseMatrix = InverseMatrix(FullMatrix); 102 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);103 atom *Walker = (*MolWalker)->start; 104 while (Walker->next != (*MolWalker)->end) { 105 Walker = Walker->next; 106 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);100 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 101 atom *Walker = (*MolWalker)->start; 102 while (Walker->next != (*MolWalker)->end) { 103 Walker = Walker->next; 104 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 107 105 if ((type1 == NULL) || (Walker->type == type1)) { 108 106 periodicX.CopyVector(Walker->node); … … 117 115 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 118 116 if ((*MolOtherWalker)->ActiveFlag) { 119 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);117 Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl; 120 118 atom *OtherWalker = (*MolOtherWalker)->start; 121 119 while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker 122 120 OtherWalker = OtherWalker->next; 123 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);121 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl; 124 122 if (Walker->nr < OtherWalker->nr) 125 123 if ((type2 == NULL) || (OtherWalker->type == type2)) { … … 164 162 165 163 if (molecules->ListOfMolecules.empty()) { 166 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);164 Log() << Verbose(1) <<"No molecule given." << endl; 167 165 return outmap; 168 166 } … … 170 168 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 171 169 if ((*MolWalker)->ActiveFlag) { 172 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);173 atom *Walker = (*MolWalker)->start; 174 while (Walker->next != (*MolWalker)->end) { 175 Walker = Walker->next; 176 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);170 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 171 atom *Walker = (*MolWalker)->start; 172 while (Walker->next != (*MolWalker)->end) { 173 Walker = Walker->next; 174 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 177 175 if ((type == NULL) || (Walker->type == type)) { 178 distance = Walker->node->PeriodicDistance(point, World::get()->cell_size);179 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);176 distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size); 177 Log() << Verbose(4) << "Current distance is " << distance << "." << endl; 180 178 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); 181 179 } … … 204 202 205 203 if (molecules->ListOfMolecules.empty()) { 206 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);204 Log() << Verbose(1) <<"No molecule given." << endl; 207 205 return outmap; 208 206 } … … 210 208 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 211 209 if ((*MolWalker)->ActiveFlag) { 212 double * FullMatrix = ReturnFullMatrixforSymmetric( World::get()->cell_size);210 double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size); 213 211 double * FullInverseMatrix = InverseMatrix(FullMatrix); 214 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);215 atom *Walker = (*MolWalker)->start; 216 while (Walker->next != (*MolWalker)->end) { 217 Walker = Walker->next; 218 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);212 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 213 atom *Walker = (*MolWalker)->start; 214 while (Walker->next != (*MolWalker)->end) { 215 Walker = Walker->next; 216 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 219 217 if ((type == NULL) || (Walker->type == type)) { 220 218 periodicX.CopyVector(Walker->node); … … 228 226 checkX.MatrixMultiplication(FullMatrix); 229 227 distance = checkX.Distance(point); 230 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);228 Log() << Verbose(4) << "Current distance is " << distance << "." << endl; 231 229 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); 232 230 } … … 257 255 258 256 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 259 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);257 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl; 260 258 return outmap; 261 259 } … … 263 261 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 264 262 if ((*MolWalker)->ActiveFlag) { 265 DoLog(1) && (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;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; 270 268 if ((type == NULL) || (Walker->type == type)) { 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 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 279 269 triangle = Surface->FindClosestTriangleToPoint(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 } 280 277 281 278 return outmap; … … 307 304 308 305 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 309 DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);306 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl; 310 307 return outmap; 311 308 } 312 309 outmap = new CorrelationToSurfaceMap; 313 double ShortestDistance = 0.; 314 BoundaryTriangleSet *ShortestTriangle = NULL; 315 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 316 if ((*MolWalker)->ActiveFlag) { 317 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 310 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 311 if ((*MolWalker)->ActiveFlag) { 312 double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size); 318 313 double * FullInverseMatrix = InverseMatrix(FullMatrix); 319 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);320 atom *Walker = (*MolWalker)->start; 321 while (Walker->next != (*MolWalker)->end) { 322 Walker = Walker->next; 323 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);314 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 315 atom *Walker = (*MolWalker)->start; 316 while (Walker->next != (*MolWalker)->end) { 317 Walker = Walker->next; 318 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl; 324 319 if ((type == NULL) || (Walker->type == type)) { 325 320 periodicX.CopyVector(Walker->node); 326 321 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 327 322 // go through every range in xyz and get distance 328 ShortestDistance = -1.;329 323 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 330 324 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) … … 333 327 checkX.AddVector(&periodicX); 334 328 checkX.MatrixMultiplication(FullMatrix); 335 TriangleIntersectionList Intersections(&checkX,Surface,LC); 336 distance = Intersections.GetSmallestDistance(); 337 triangle = Intersections.GetClosestTriangle(); 338 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 339 ShortestDistance = distance; 340 ShortestTriangle = triangle; 329 triangle = Surface->FindClosestTriangleToPoint(&checkX, LC ); 330 if (triangle != NULL) { 331 distance = DistanceToTrianglePlane(&checkX, triangle); 332 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 341 333 } 342 } 343 // insert 344 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 345 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 334 } 346 335 } 347 336 } … … 373 362 { 374 363 Info FunctionInfo(__func__); 375 *file << " BinStart\tCount" << endl;364 *file << "# BinStart\tCount" << endl; 376 365 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 377 *file << setprecision(8) <<runner->first << "\t" << runner->second << endl;366 *file << runner->first << "\t" << runner->second << endl; 378 367 } 379 368 }; … … 386 375 { 387 376 Info FunctionInfo(__func__); 388 *file << " BinStart\tAtom1\tAtom2" << endl;377 *file << "# BinStart\tAtom1\tAtom2" << endl; 389 378 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 390 *file << setprecision(8) <<runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;379 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 391 380 } 392 381 }; … … 399 388 { 400 389 Info FunctionInfo(__func__); 401 *file << " BinStart\tAtom::x[i]-point.x[i]" << endl;390 *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl; 402 391 for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 403 392 *file << runner->first; 404 393 for (int i=0;i<NDIM;i++) 405 *file << "\t" << setprecision(8) <<(runner->second.first->node->x[i] - runner->second.second->x[i]);394 *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]); 406 395 *file << endl; 407 396 } … … 415 404 { 416 405 Info FunctionInfo(__func__); 417 *file << "BinStart\tTriangle" << endl; 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 406 *file << "# BinStart\tTriangle" << endl; 407 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 408 *file << runner->first << "\t" << *(runner->second.second) << endl; 409 } 410 }; 411
Note:
See TracChangeset
for help on using the changeset viewer.
