- Timestamp:
- Nov 21, 2012, 12:46:30 PM (12 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:
- 06865e
- Parents:
- a0f8d3
- git-author:
- Frederik Heber <heber@…> (08/08/12 16:56:24)
- git-committer:
- Frederik Heber <heber@…> (11/21/12 12:46:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
ra0f8d3 r358ddb 60 60 #include "Fragmentation/Summation/AllLevelOrthogonalSummator.hpp" 61 61 #include "Fragmentation/Summation/AllLevelSummator.hpp" 62 #include "Fragmentation/Summation/OrthogonalFullSummator.hpp" 63 #include "Fragmentation/Summation/OrthogonalSummation.hpp" 62 64 #include "Fragmentation/Summation/writeTable.hpp" 63 65 #include "Graph/DepthFirstSearchAnalysis.hpp" … … 70 72 #ifdef HAVE_VMG 71 73 #include "Jobs/VMGJob.hpp" 74 #include "Jobs/VMGData.hpp" 75 #include "Jobs/VMGDataFused.hpp" 76 #include "Jobs/VMGDataMap.hpp" 77 #include "Jobs/VMGData_printKeyNames.hpp" 72 78 #endif 73 79 #include "molecule.hpp" … … 336 342 } 337 343 344 template <> 345 void convertDataTo<VMGData, VMGDataMap_t>( 346 const std::vector<VMGData> &longrangeData, 347 std::vector<VMGDataMap_t> &VMGData_fused) 348 { 349 // energy_t 350 VMGData_fused.clear(); 351 VMGData_fused.reserve(longrangeData.size()); 352 for(std::vector<VMGData>::const_iterator dataiter = longrangeData.begin(); 353 dataiter != longrangeData.end(); ++dataiter) { 354 const VMGData &extractedData = *dataiter; 355 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 356 VMGDataMap_t instance; 357 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential; 358 boost::fusion::at_key<VMGDataFused::energy_long>(instance) = extractedData.e_long; 359 VMGData_fused.push_back(instance); 360 } 361 } 338 362 339 363 void convertMPQCDatatoForceMap( … … 432 456 // instantiate summator 433 457 std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel()); 458 AllLevelSummator<TypeMap> Summer( 459 subsetmap, 460 MPQCData_fused, 461 jobids, 462 container->getContainer(), 463 MatrixNrLookup, 464 Result_fused); 465 // sum up for each type key in TypeVector 466 boost::mpl::for_each<TypeVector>(boost::ref(Summer)); 467 return Result_fused; 468 } 469 470 template <typename TypeMap, typename TypeVector> 471 std::vector<TypeMap> OrthogonalSumUpPerLevel( 472 const std::vector<MPQCData> &fragmentData, 473 const std::vector<JobId_t> &jobids, 474 std::map< JobId_t, size_t > &MatrixNrLookup, 475 const IndexSetContainer::ptr &container, 476 SubsetMap::ptr &subsetmap 477 ) 478 { 479 // place data into boost::fusion::map instance 480 std::vector<TypeMap> MPQCData_fused; 481 convertDataTo<MPQCData, TypeMap>(fragmentData, MPQCData_fused); 482 // instantiate summator 483 std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel()); 434 484 AllLevelOrthogonalSummator<TypeMap> Summer( 435 485 subsetmap, … … 489 539 /// convert all MPQCData to MPQCDataMap_t 490 540 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 491 SumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(541 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 492 542 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 493 543 std::vector<MPQCDataFragmentMap_t> Result_Fragment_fused( 494 SumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>(544 OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>( 495 545 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 496 546 // obtain full grid … … 567 617 "FragmentationAutomationAction::performCall() - ForceKeySet's KeySets and fragmentData differ in size."); 568 618 619 typedef boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type MPQCDataEnergyVector_noeigenvalues_t; 569 620 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused( 570 SumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>(621 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>( 571 622 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 572 623 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 573 SumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(624 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 574 625 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 575 626 std::vector<MPQCDataTimeMap_t> Result_Time_fused( … … 595 646 // print tables (without eigenvalues, they go extra) 596 647 const size_t MaxLevel = subsetmap->getMaximumSubsetLevel(); 597 typedef boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type MPQCDataEnergyVector_noeigenvalues_t;598 648 const std::string energyresult = 599 649 writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( … … 648 698 } 649 699 LOG(1, "INFO: Resulting forces are " << std::endl << output.str()); 700 701 return true; 702 } 703 704 /** Print MPQCData from received results. 705 * 706 * @param fragmentresults results with short-range job ids to associate with fragment number 707 * @param longrangeresults results with long-range job ids to associate with fragment number 708 * @param fragmentData MPQCData resulting from the jobs 709 * @param longrangeData VMGData resulting from long-range jobs 710 * @param KeySetFilename filename with keysets to associate forces correctly 711 * @param NoAtoms total number of atoms 712 * @param full_sample summed up charge from fragments on return 713 */ 714 bool printReceivedFullResults( 715 const std::vector<FragmentResult::ptr> &fragmentresults, 716 const std::vector<FragmentResult::ptr> &longrangeresults, 717 const std::vector<MPQCData> &fragmentData, 718 const std::vector<VMGData> &longrangeData, 719 const std::string &KeySetFilename, 720 size_t NoAtoms, 721 SamplingGrid &full_sample) 722 { 723 // create lookup from job nr to fragment number 724 std::map< JobId_t, size_t > MatrixNrLookup; 725 size_t FragmentCounter = 0; 726 createMatrixNrLookup(fragmentresults, MatrixNrLookup, FragmentCounter); 727 std::map< JobId_t, size_t > extraMatrixNrLookup; 728 size_t extraFragmentCounter = 0; 729 createMatrixNrLookup(longrangeresults, extraMatrixNrLookup, extraFragmentCounter); 730 731 // initialise keysets 732 KeySetsContainer KeySet; 733 KeySetsContainer ForceKeySet; 734 { 735 // else needs keysets without hydrogens 736 std::stringstream filename; 737 filename << FRAGMENTPREFIX << KEYSETFILE; 738 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false; 739 } 740 741 { 742 // forces need keysets including hydrogens 743 std::stringstream filename; 744 filename << FRAGMENTPREFIX << FORCESFILE; 745 if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false; 746 } 747 748 /// prepare for OrthogonalSummation 749 750 // convert KeySetContainer to IndexSetContainer 751 IndexSetContainer::ptr container(new IndexSetContainer(KeySet)); 752 // create the map of all keysets 753 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 754 755 // create a vector of all job ids from short-range 756 std::vector<JobId_t> jobids(fragmentresults.size(), JobId::IllegalJob); 757 std::transform(fragmentresults.begin(), fragmentresults.end(), jobids.begin(), 758 boost::bind(&FragmentResult::getId, 759 boost::bind(&FragmentResult::ptr::operator->, _1))); 760 // create a vector of all job ids from long-range 761 std::vector<JobId_t> extrajobids(longrangeresults.size(), JobId::IllegalJob); 762 std::transform(longrangeresults.begin(), longrangeresults.end(), extrajobids.begin(), 763 boost::bind(&FragmentResult::getId, 764 boost::bind(&FragmentResult::ptr::operator->, _1))); 765 766 /// convert all MPQCData to MPQCDataMap_t 767 { 768 typedef boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type MPQCDataEnergyVector_noeigenvalues_t; 769 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused( 770 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>( 771 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 772 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 773 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 774 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 775 std::vector<MPQCDataTimeMap_t> Result_Time_fused( 776 SumUpPerLevel<MPQCDataTimeMap_t, MPQCDataTimeVector_t>( 777 fragmentData, jobids, MatrixNrLookup, container, subsetmap)); 778 779 // force has extra converter 780 std::vector<MPQCDataForceMap_t> MPQCData_Force_fused; 781 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused); 782 std::vector<MPQCDataForceMap_t> Result_Force_fused(subsetmap->getMaximumSubsetLevel()); 783 AllLevelOrthogonalSummator<MPQCDataForceMap_t> forceSummer( 784 subsetmap, 785 MPQCData_Force_fused, 786 jobids, 787 container->getContainer(), 788 MatrixNrLookup, 789 Result_Force_fused); 790 boost::mpl::for_each<MPQCDataForceVector_t>(boost::ref(forceSummer)); 791 792 // obtain full grid 793 std::vector<VMGDataMap_t> VMGData_Potential_fused; 794 convertDataTo<VMGData, VMGDataMap_t>(longrangeData, VMGData_Potential_fused); 795 OrthogonalFullSummator<VMGDataMap_t, VMGDataFused::sampled_potential> potentialSummer( 796 subsetmap, 797 VMGData_Potential_fused, 798 extrajobids, 799 container->getContainer(), 800 extraMatrixNrLookup); 801 potentialSummer(subsetmap->getMaximumSubsetLevel()); 802 full_sample = potentialSummer.getFullContribution(); 803 LOG(0, "Remaining long-range energy from potential integral is " << full_sample.integral() << "."); 804 805 OrthogonalFullSummator<VMGDataMap_t, VMGDataFused::energy_long> elongSummer( 806 subsetmap, 807 VMGData_Potential_fused, 808 extrajobids, 809 container->getContainer(), 810 extraMatrixNrLookup); 811 elongSummer(subsetmap->getMaximumSubsetLevel()); 812 const double e_long = elongSummer.getFullContribution(); 813 LOG(0, "Remaining long-range energy is " << e_long << "."); 814 815 // print tables (without eigenvalues, they go extra) 816 const size_t MaxLevel = subsetmap->getMaximumSubsetLevel(); 817 const std::string energyresult = 818 writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( 819 Result_Energy_fused, MaxLevel); 820 LOG(0, "Energy table is \n" << energyresult); 821 const std::string eigenvalueresult; 822 823 LOG(0, "Eigenvalue table is \n" << eigenvalueresult); 824 const std::string forceresult = 825 writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()( 826 Result_Force_fused, MaxLevel); 827 LOG(0, "Force table is \n" << forceresult); 828 // we don't want to print grid to a table 829 // print times (without flops for now) 830 typedef boost::mpl::remove<MPQCDataTimeVector_t, MPQCDataFused::times_flops>::type MPQCDataTimeVector_noflops_t; 831 const std::string timesresult = 832 writeTable<MPQCDataTimeMap_t, MPQCDataTimeVector_noflops_t >()( 833 Result_Time_fused, MaxLevel); 834 LOG(0, "Times table is \n" << timesresult); 835 } 650 836 651 837 return true; … … 819 1005 "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresultd and VMGresults don't match."); 820 1006 1007 std::vector<VMGData> longrangeData; 1008 ConvertFragmentResultTo<VMGData>(VMGresults, longrangeData); 1009 1010 // Final phase: print result 1011 { 1012 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << "."); 1013 printReceivedFullResults( 1014 MPQCresults, 1015 VMGresults, 1016 fragmentData, 1017 longrangeData, 1018 params.path.get(), 1019 getNoAtomsFromAdjacencyFile(params.path.get()), 1020 full_sample); 1021 } 1022 } 1023 #else 821 1024 // Final phase: print result 822 1025 { … … 829 1032 full_sample); 830 1033 } 831 }832 1034 #endif 833 1035 size_t Exitflag = controller.getExitflag();
Note:
See TracChangeset
for help on using the changeset viewer.