Changeset f58e56
- Timestamp:
- Oct 17, 2013, 7:24:06 AM (11 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:
- 47cee7
- Parents:
- 0588e9
- git-author:
- Frederik Heber <heber@…> (09/29/13 09:45:35)
- git-committer:
- Frederik Heber <heber@…> (10/17/13 07:24:06)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp
r0588e9 rf58e56 374 374 } 375 375 376 377 /** Determines the largest cycle in the container and returns its size. 378 * 379 * \param cycles set of cycles 380 * \return size if largest cycle 381 */ 382 size_t getMaxCycleSize(const KeySetsContainer &cycles) 383 { 384 // gather cycle sizes 385 std::vector<size_t> cyclesizes(cycles.KeySets.size()); 386 std::transform( 387 cycles.KeySets.begin(), cycles.KeySets.end(), 388 cyclesizes.begin(), 389 boost::bind(&KeySetsContainer::IntVector::size, boost::lambda::_1) 390 ); 391 // get maximum 392 std::vector<size_t>::const_iterator maximum_size = 393 std::max_element(cyclesizes.begin(), cyclesizes.end()); 394 if (maximum_size != cyclesizes.end()) 395 return *maximum_size; 396 else 397 return 0; 398 } 399 400 void calculateCycleFullContribution( 401 const std::map<JobId_t, MPQCData> &shortrangedata, 402 const KeySetsContainer &keysets, 403 const KeySetsContainer &forcekeysets, 404 const KeySetsContainer &cycles, 405 const FragmentationShortRangeResults &shortrangeresults) 406 { 407 // copy the shortrangeresults such that private MaxLevel is set in 408 // FragmentationShortRangeResults 409 FragmentationShortRangeResults cycleresults(shortrangeresults); 410 // get largest size 411 const size_t maximum_size = getMaxCycleSize(cycles); 412 413 /// The idea here is that (Orthogonal)Summation will place a result 414 /// consisting of level 1,2, and 3 fragment and a level 6 ring nonetheless 415 /// in level 6. If we want to have this result already at level 3, we 416 /// have to specifically inhibit all fragments from later levels but the 417 /// cycles and then pick the result from the last level and placing it at 418 /// the desired one 419 420 // loop from level 1 to max ring size and gather contributions 421 for (size_t level = 1; level <= maximum_size; ++level) { 422 // create ValueMask for this level by stepping through each keyset and checking size 423 std::vector<bool> localValueMask(shortrangedata.size(), false); 424 size_t index=0; 425 // TODO: if only KeySetsContainer was usable as a compliant STL container, might be able to use set_difference or alike. 426 KeySetsContainer::ArrayOfIntVectors::const_iterator keysetsiter = keysets.KeySets.begin(); 427 KeySetsContainer::ArrayOfIntVectors::const_iterator cyclesiter = cycles.KeySets.begin(); 428 for (; (keysetsiter != keysets.KeySets.end()) && (cyclesiter != cycles.KeySets.end());) { 429 if (cyclesiter->size() > keysetsiter->size()) { 430 // add if not greater than level in size 431 if ((*keysetsiter).size() <= level) 432 localValueMask[index] = true; 433 ++keysetsiter; 434 ++index; 435 } else if (cyclesiter->size() < keysetsiter->size()) { 436 ++cyclesiter; 437 } else { // both sets have same size 438 if (*cyclesiter > *keysetsiter) { 439 // add if not greater than level in size 440 if ((*keysetsiter).size() <= level) 441 localValueMask[index] = true; 442 ++keysetsiter; 443 ++index; 444 } else if (*cyclesiter < *keysetsiter) { 445 ++cyclesiter; 446 } else { 447 // also always add all cycles 448 localValueMask[index] = true; 449 ++cyclesiter; 450 ++keysetsiter; 451 ++index; 452 } 453 } 454 } 455 // activate rest if desired by level 456 for (; keysetsiter != keysets.KeySets.end(); ++keysetsiter) { 457 if ((*keysetsiter).size() <= level) 458 localValueMask[index] = true; 459 ++index; 460 } 461 LOG(2, "DEBUG: ValueMask for cycle correction at level " << level << " is " 462 << localValueMask << "."); 463 // create FragmentationShortRangeResults 464 FragmentationShortRangeResults localresults(shortrangedata, keysets, forcekeysets, localValueMask); 465 // and perform summation 466 localresults(shortrangedata); 467 // finally, extract the corrections from last level 468 cycleresults.Result_Energy_fused[level-1] = 469 localresults.Result_Energy_fused.back(); 470 cycleresults.Result_Time_fused[level-1] = 471 localresults.Result_Time_fused.back(); 472 cycleresults.Result_Force_fused[level-1] = 473 localresults.Result_Force_fused.back(); 474 } 475 printReceivedCycleResults(cycleresults); 476 } 376 477 377 478 ActionState::ptr FragmentationAnalyseFragmentationResultsAction::performCall() { … … 444 545 } 445 546 446 // copy the shortrangeresults such that private MaxLevel is set in447 // FragmentationShortRangeResults448 FragmentationShortRangeResults cycleresults(shortrangeresults);449 547 // calculate energy if cycles are calculated fully at each level already 450 548 if (!cycles.KeySets.empty()) { 451 // gather cycle sizes 452 std::vector<size_t> cyclesizes(cycles.KeySets.size()); 453 std::transform( 454 cycles.KeySets.begin(), cycles.KeySets.end(), 455 cyclesizes.begin(), 456 boost::bind(&KeySetsContainer::IntVector::size, boost::lambda::_1) 457 ); 458 // get maximum 459 std::vector<size_t>::const_iterator maximum_size = 460 std::max_element(cyclesizes.begin(), cyclesizes.end()); 461 462 // loop from level 1 to max ring size and gather corrections 463 for (size_t level = 1; level <= *maximum_size; ++level) { 464 // create ValueMask for this level by stepping through each keyset and checking size 465 std::vector<bool> localValueMask(shortrangedata.size(), false); 466 size_t index=0; 467 KeySetsContainer::ArrayOfIntVectors::const_iterator keysetsiter = keysets.KeySets.begin(); 468 KeySetsContainer::ArrayOfIntVectors::const_iterator cyclesiter = cycles.KeySets.begin(); 469 for (; (keysetsiter != keysets.KeySets.end()) && (cyclesiter != cycles.KeySets.end());) { 470 if (cyclesiter->size() > keysetsiter->size()) { 471 // add if not greater than level in size 472 if ((*keysetsiter).size() <= level) 473 localValueMask[index] = true; 474 ++keysetsiter; 475 ++index; 476 } else if (cyclesiter->size() < keysetsiter->size()) { 477 ++cyclesiter; 478 } else { // both sets have same size 479 if (*cyclesiter > *keysetsiter) { 480 // add if not greater than level in size 481 if ((*keysetsiter).size() <= level) 482 localValueMask[index] = true; 483 ++keysetsiter; 484 ++index; 485 } else if (*cyclesiter < *keysetsiter) { 486 ++cyclesiter; 487 } else { 488 // also always add all cycles 489 localValueMask[index] = true; 490 ++cyclesiter; 491 ++keysetsiter; 492 ++index; 493 } 494 } 495 } 496 // activate rest if desired by level 497 for (; keysetsiter != keysets.KeySets.end(); ++keysetsiter) { 498 if ((*keysetsiter).size() <= level) 499 localValueMask[index] = true; 500 ++index; 501 } 502 LOG(2, "DEBUG: ValueMask for cycle correction at level " << level << " is " 503 << localValueMask << "."); 504 // create FragmentationShortRangeResults 505 FragmentationShortRangeResults localresults(shortrangedata, keysets, forcekeysets, localValueMask); 506 // and perform summation 507 localresults(shortrangedata); 508 // finally, extract the corrections 509 cycleresults.Result_Energy_fused[level-1] = 510 localresults.Result_Energy_fused.back(); 511 cycleresults.Result_Time_fused[level-1] = 512 localresults.Result_Time_fused.back(); 513 cycleresults.Result_Force_fused[level-1] = 514 localresults.Result_Force_fused.back(); 515 } 516 printReceivedCycleResults(cycleresults); 549 calculateCycleFullContribution( 550 shortrangedata, 551 keysets, 552 forcekeysets, 553 cycles, 554 shortrangeresults); 517 555 } 518 556
Note:
See TracChangeset
for help on using the changeset viewer.