Changeset 47d041 for src/Tesselation/ellipsoid.cpp
- Timestamp:
- Nov 3, 2011, 7:44:01 PM (13 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 41a467
- Parents:
- 50e4e5
- git-author:
- Frederik Heber <heber@…> (10/27/11 11:53:58)
- git-committer:
- Frederik Heber <heber@…> (11/03/11 19:44:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tesselation/ellipsoid.cpp
r50e4e5 r47d041 55 55 double psi,theta,phi; // euler angles in ZX'Z'' convention 56 56 57 //L og() << Verbose(3) << "Begin of SquaredDistanceToEllipsoid" << endl;57 //LOG(3, "Begin of SquaredDistanceToEllipsoid"); 58 58 59 59 for(int i=0;i<3;i++) … … 62 62 // 1. translate coordinate system so that ellipsoid center is in origin 63 63 RefPoint = helper = x - EllipsoidCenter; 64 //L og() << Verbose(4) << "Translated given point is at " << RefPoint << "." << endl;64 //LOG(4, "Translated given point is at " << RefPoint << "."); 65 65 66 66 // 2. transform coordinate system by inverse of rotation matrix and of diagonal matrix … … 79 79 helper *= Matrix; 80 80 helper.ScaleAll(InverseLength); 81 //L og() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;81 //LOG(4, "Transformed RefPoint is at " << helper << "."); 82 82 83 83 // 3. construct intersection point with unit sphere and ray between origin and x 84 84 helper.Normalize(); // is simply normalizes vector in distance direction 85 //L og() << Verbose(4) << "Transformed intersection is at " << helper << "." << endl;85 //LOG(4, "Transformed intersection is at " << helper << "."); 86 86 87 87 // 4. transform back the constructed intersection point … … 100 100 Matrix.set(2,2, cos(theta)); 101 101 helper *= Matrix; 102 //L og() << Verbose(4) << "Intersection is at " << helper << "." << endl;102 //LOG(4, "Intersection is at " << helper << "."); 103 103 104 104 // 5. determine distance between backtransformed point and x 105 105 distance = RefPoint.DistanceSquared(helper); 106 //L og() << Verbose(4) << "Squared distance between intersection and RefPoint is " << distance << "." << endl;106 //LOG(4, "Squared distance between intersection and RefPoint is " << distance << "."); 107 107 108 108 return distance; 109 //L og() << Verbose(3) << "End of SquaredDistanceToEllipsoid" << endl;109 //LOG(3, "End of SquaredDistanceToEllipsoid"); 110 110 }; 111 111 … … 149 149 } 150 150 151 //L og() << Verbose(0) << "Current summed distance is " << SumDistance << "." << endl;151 //LOG(0, "Current summed distance is " << SumDistance << "."); 152 152 return SumDistance; 153 153 }; … … 163 163 { 164 164 int status = GSL_SUCCESS; 165 DoLog(2) && (Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl);165 LOG(2, "Begin of FitPointSetToEllipsoid "); 166 166 if (N >= 3) { // check that enough points are given (9 d.o.f.) 167 167 struct EllipsoidMinimisation par; … … 216 216 EllipsoidAngle[i] = gsl_vector_get (s->x, i+6); 217 217 } 218 DoLog(4) && (Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl);218 LOG(4, setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "."); 219 219 } 220 220 … … 226 226 227 227 } else { 228 DoLog(3) && (Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl);228 LOG(3, "Not enough points provided for fit to ellipsoid."); 229 229 return false; 230 230 } 231 DoLog(2) && (Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl);231 LOG(2, "End of FitPointSetToEllipsoid"); 232 232 if (status == GSL_SUCCESS) 233 233 return true; … … 252 252 int index; 253 253 TesselPoint *Candidate = NULL; 254 DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);254 LOG(2, "Begin of PickRandomPointSet"); 255 255 256 256 // allocate array … … 258 258 x = new Vector[PointsToPick]; 259 259 } else { 260 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);260 ELOG(2, "Given pointer to vector array seems already allocated."); 261 261 } 262 262 … … 282 282 for(int i=0;i<NDIM;i++) // pick three random indices 283 283 LC->n[i] = ((int)random() % LC->N[i]); 284 DoLog(2) && (Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ...");284 LOG(2, "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << "."); 285 285 // get random cell 286 286 const TesselPointSTLList *List = LC->GetCurrentCell(); … … 288 288 continue; 289 289 } 290 DoLog(2) && (Log() << Verbose(2) << "with No. " << LC->index << "." << endl); 291 292 DoLog(2) && (Log() << Verbose(2) << "LC Intervals:"); 290 LOG(2, "INFO: Cell index is No. " << LC->index << "."); 291 292 if (DoLog(2)) { 293 std::stringstream output; 294 output << "LC Intervals:"; 295 for (int i=0;i<NDIM;i++) 296 output << " [" << Nlower[i] << "," << Nupper[i] << "] "; 297 LOG(2, output.str()); 298 } 299 293 300 for (int i=0;i<NDIM;i++) { 294 301 Nlower[i] = ((LC->n[i]-1) >= 0) ? LC->n[i]-1 : 0; 295 302 Nupper[i] = ((LC->n[i]+1) < LC->N[i]) ? LC->n[i]+1 : LC->N[i]-1; 296 DoLog(0) && (Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "); 297 } 298 DoLog(0) && (Log() << Verbose(0) << endl); 303 } 299 304 300 305 // count whether there are sufficient atoms in this cell+neighbors … … 306 311 PointsLeft += List->size(); 307 312 } 308 DoLog(2) && (Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl);313 LOG(2, "There are " << PointsLeft << " atoms in this neighbourhood."); 309 314 if (PointsLeft < PointsToPick) { // ensure that we can pick enough points in its neighbourhood at all. 310 315 continue; … … 317 322 current = PickedAtomNrs.find(index); // not present? 318 323 if (current == PickedAtomNrs.end()) { 319 //L og() << Verbose(2) << "Picking atom Nr. " << index << "." << endl;324 //LOG(2, "Picking atom Nr. " << index << "."); 320 325 PickedAtomNrs.insert(index); 321 326 } … … 329 334 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 330 335 const TesselPointSTLList *List = LC->GetCurrentCell(); 331 // L og() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;336 // LOG(2, "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points."); 332 337 if (List != NULL) { 333 338 // if (List->begin() != List->end()) 334 // L og() << Verbose(2) << "Going through candidates ... " << endl;339 // LOG(2, "Going through candidates ... "); 335 340 // else 336 // L og() << Verbose(2) << "Cell is empty ... " << endl;341 // LOG(2, "Cell is empty ... "); 337 342 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 338 343 if ((current != PickedAtomNrs.end()) && (*current == index)) { 339 344 Candidate = (*Runner); 340 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << (*Runner)->getName() << " with index " << index << "." << endl);345 LOG(2, "Current picked node is " << (*Runner)->getName() << " with index " << index << "."); 341 346 x[PointsPicked++] = Candidate->getPosition(); // we have one more atom picked 342 347 current++; // next pre-picked atom … … 345 350 } 346 351 // } else { 347 // L og() << Verbose(2) << "List for this index not allocated!" << endl;352 // LOG(2, "List for this index not allocated!"); 348 353 } 349 354 } 350 DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);355 LOG(2, "The following points were picked: "); 351 356 for (size_t i=0;i<PointsPicked;i++) 352 DoLog(2) && (Log() << Verbose(2) << x[i] << endl);357 LOG(2, x[i]); 353 358 if (PointsPicked == PointsToPick) // break out of loop if we have all 354 359 break; 355 360 } while(1); 356 361 357 DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);362 LOG(2, "End of PickRandomPointSet"); 358 363 }; 359 364 … … 370 375 double value, threshold; 371 376 PointMap *List = &T->PointsOnBoundary; 372 DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);377 LOG(2, "Begin of PickRandomPointSet"); 373 378 374 379 // allocate array … … 376 381 x = new Vector[PointsToPick]; 377 382 } else { 378 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);383 ELOG(2, "Given pointer to vector array seems already allocated."); 379 384 } 380 385 … … 386 391 threshold = 1. - (double)(PointsToPick - PointsPicked)/(double)PointsLeft; 387 392 value = (double)random()/(double)(rng_max-rng_min); 388 //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";389 393 if (value > threshold) { 390 394 x[PointsPicked] = (Runner->second->node->getPosition()); 391 395 PointsPicked++; 392 //L og() << Verbose(0) << "IN." << endl;396 //LOG(3, "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": IN."); 393 397 } else { 394 //L og() << Verbose(0) << "OUT." << endl;398 //LOG(3, "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": OUT."); 395 399 } 396 400 PointsLeft--; 397 401 } 398 DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);402 LOG(2, "The following points were picked: "); 399 403 for (size_t i=0;i<PointsPicked;i++) 400 DoLog(3) && (Log() << Verbose(3) << x[i] << endl);401 402 DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);404 LOG(3, x[i]); 405 406 LOG(2, "End of PickRandomPointSet"); 403 407 }; 404 408 … … 420 424 double EllipsoidAngle[3]; 421 425 double distance, MaxDistance, MinDistance; 422 DoLog(0) && (Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl);426 LOG(0, "Begin of FindDistributionOfEllipsoids"); 423 427 424 428 // construct center of gravity of boundary point set for initial ellipsoid center … … 427 431 Center += (Runner->second->node->getPosition()); 428 432 Center.Scale(1./T->PointsOnBoundaryCount); 429 DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl);433 LOG(1, "Center is at " << Center << "."); 430 434 431 435 // Output header … … 435 439 // loop over desired number of parameter sets 436 440 for (;number >0;number--) { 437 DoLog(1) && (Log() << Verbose(1) << "Determining data set " << number << " ... " << endl);441 LOG(1, "Determining data set " << number << " ... "); 438 442 // pick the point set 439 443 x = NULL; … … 451 455 MinDistance = distance; 452 456 } 453 //L og() << Verbose(2) << "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "." << endl;457 //LOG(2, "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "."); 454 458 EllipsoidCenter = Center; // use Center of Gravity as initial center of ellipsoid 455 459 for (int i=0;i<3;i++) … … 461 465 // fit the parameters 462 466 if (FitPointSetToEllipsoid(x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) { 463 DoLog(1) && (Log() << Verbose(1) << "Picking succeeded!" << endl);467 LOG(1, "Picking succeeded!"); 464 468 // output obtained parameter set 465 469 output << number << "\t"; … … 472 476 output << endl; 473 477 } else { // increase N to pick one more 474 DoLog(1) && (Log() << Verbose(1) << "Picking failed!" << endl);478 LOG(1, "Picking failed!"); 475 479 number++; 476 480 } … … 480 484 output.close(); 481 485 482 DoLog(0) && (Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl);483 }; 486 LOG(0, "End of FindDistributionOfEllipsoids"); 487 };
Note:
See TracChangeset
for help on using the changeset viewer.