- Timestamp:
- Nov 12, 2012, 4:04:51 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:
- adccae
- Parents:
- 56df37
- git-author:
- Frederik Heber <heber@…> (07/31/12 14:30:24)
- git-committer:
- Frederik Heber <heber@…> (11/12/12 16:04:51)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
r56df37 r8cae4c 59 59 #include "Jobs/MPQCJob.hpp" 60 60 #include "Jobs/MPQCData.hpp" 61 #include "Jobs/MPQCData_printName.hpp" 61 62 #include "molecule.hpp" 62 63 #include "World.hpp" … … 65 66 #include <string> 66 67 #include <vector> 68 69 #include <boost/mpl/for_each.hpp> 67 70 68 71 #include "Actions/FragmentationAction/FragmentationAutomationAction.hpp" … … 138 141 } 139 142 143 144 template <typename MapType> 145 struct printSum { 146 printSum( 147 SubsetMap::ptr &_subsetmap, 148 const std::vector<MapType> &_data, 149 const std::vector<JobId_t> &_jobids, 150 const IndexSetContainer::Container_t &_container, 151 std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */ 152 subsetmap(_subsetmap), 153 data(_data), 154 jobids(_jobids), 155 container(_container), 156 MatrixNrLookup(_MatrixNrLookup) 157 {} 158 template <typename MapKey> 159 void operator()(MapKey &) { 160 Summator<MapType, MapKey> sum_value( 161 subsetmap, data, jobids, container, MatrixNrLookup 162 ); 163 double value = sum_value(); 164 LOG(0, "STATUS: Resulting " << MPQCDataNames::printName<MapKey>() << " is " << value << "."); 165 } 166 167 private: 168 //!> Hierarchy of IndexSet's 169 SubsetMap::ptr &subsetmap; 170 //!> vector of data converted from MPQCData 171 const std::vector<MapType> &data; 172 //!> vector of jobids 173 const std::vector<JobId_t> &jobids; 174 //!> container with all IndexSet's 175 const IndexSetContainer::Container_t &container; 176 //!> lookup map from job ids to ordering in above vectors 177 std::map< JobId_t, size_t > MatrixNrLookup; 178 }; 140 179 141 180 /** Print MPQCData from received results. … … 276 315 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 277 316 278 // convert all MPQCData to MPQCDataMap_t 279 std::vector<MPQCDataMap_t> MPQCData_fused; 280 MPQCData_fused.reserve(fragmentData.size()); 281 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 282 dataiter != fragmentData.end(); ++dataiter) { 283 MPQCDataMap_t instance; 284 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = dataiter->energies.total; 285 // boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = dataiter->energies.eigenvalues; 286 // boost::fusion::at_key<MPQCDataFused::forces>(instance) = dataiter->forces; 287 // boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = dataiter->times.walltime; 288 } 289 290 // get a vector of a job ids 291 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob); 292 // std::transform(results.begin(), results.end(), jobids.begin(), 293 // boost::bind(&FragmentResult::getId, 294 // boost::bind(&FragmentResult::ptr::, _1))); 295 std::vector<JobId_t>::iterator iditer = jobids.begin(); 296 for (std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin(); 297 resultiter != results.end(); ++resultiter) { 298 *iditer = (*resultiter)->getId(); 299 ++iditer; 300 } 301 302 // associate each index set with its value (do not use the full set, that is also contained!) 303 const IndexSetContainer::Container_t &_container = container->getContainer(); 304 Summator<MPQCDataMap_t, MPQCDataFused::energy_total> sum_energy_total( 305 subsetmap, 306 MPQCData_fused, 307 jobids, 308 _container, 309 MatrixNrLookup 310 ); 311 double energy_total = sum_energy_total(); 312 LOG(0, "STATUS: Resulting total energy is " << energy_total << "."); 313 314 // Summator<MPQCDataMap_t, MPQCDataFused::energy_eigenvalues> sum_energy_eigenvalues( 315 // subsetmap, 316 // MPQCData_fused, 317 // jobids, 318 // _container, 319 // MatrixNrLookup 320 // ); 321 322 // associate each index set with its value (do not use the full set, that is also contained!) 323 // { 324 // OrthogonalSummation<double>::InputSets_t indices(_container.begin(), _container.end()-1); 325 // OrthogonalSummation<double>::InputValues_t values(_container.size()-1, 0.); 326 // std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 327 // std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin(); 328 // for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) { 329 // const MPQCData &extractedData = *dataiter; 330 // values[ MatrixNrLookup[(*resultiter)->getId()] ] = extractedData.energies.total; 331 // } 332 // 333 // // create the summation functor and evaluate 334 // OrthogonalSummation<double> OS(indices, values, subsetmap); 335 // const double energyresult = OS(); 336 // LOG(0, "STATUS: Resulting energy is " << energyresult << "."); 337 // } 338 // { 339 // OrthogonalSummation<Histogram>::InputSets_t indices(_container.begin(), _container.end()-1); 340 // OrthogonalSummation<Histogram>::InputValues_t values(_container.size()-1); 341 // std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 342 // std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin(); 343 // for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) { 344 // const MPQCData &extractedData = *dataiter; 345 // values[ MatrixNrLookup[(*resultiter)->getId()] ] = Histogram(extractedData.energies.eigenvalues, 0., 0.1); 346 // } 347 // 348 // // create the summation functor and evaluate 349 // OrthogonalSummation<Histogram> OS(indices, values, subsetmap); 350 // const Histogram eigenvaluegram = OS(); 351 // LOG(0, "STATUS: Resulting histogram is " << eigenvaluegram << "."); 352 // } 317 { 318 /// convert all MPQCData to MPQCDataMap_t 319 320 // energy_t 321 std::vector<MPQCDataEnergyMap_t> MPQCData_Energy_fused; 322 MPQCData_Energy_fused.reserve(fragmentData.size()); 323 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 324 dataiter != fragmentData.end(); ++dataiter) { 325 const MPQCData &extractedData = *dataiter; 326 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 327 MPQCDataEnergyMap_t instance; 328 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total; 329 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion; 330 boost::fusion::at_key<MPQCDataFused::energy_electron_repulsion>(instance) = extractedData.energies.electron_repulsion; 331 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation; 332 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap; 333 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic; 334 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore; 335 // boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues; 336 MPQCData_Energy_fused.push_back(instance); 337 } 338 339 // forces 340 std::vector<MPQCDataForceMap_t> MPQCData_Force_fused; 341 MPQCData_Force_fused.reserve(fragmentData.size()); 342 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 343 dataiter != fragmentData.end(); ++dataiter) { 344 const MPQCData &extractedData = *dataiter; 345 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 346 MPQCDataForceMap_t instance; 347 boost::fusion::at_key<MPQCDataFused::forces>(instance) = extractedData.forces; 348 MPQCData_Force_fused.push_back(instance); 349 } 350 351 // times 352 std::vector<MPQCDataTimeMap_t> MPQCData_Time_fused; 353 MPQCData_Time_fused.reserve(fragmentData.size()); 354 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 355 dataiter != fragmentData.end(); ++dataiter) { 356 const MPQCData &extractedData = *dataiter; 357 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 358 MPQCDataTimeMap_t instance; 359 boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime; 360 boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime; 361 boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops; 362 MPQCData_Time_fused.push_back(instance); 363 } 364 365 // create a vector of all job ids 366 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob); 367 std::transform(results.begin(), results.end(), jobids.begin(), 368 boost::bind(&FragmentResult::getId, 369 boost::bind(&FragmentResult::ptr::operator->, _1))); 370 371 // sum up and print energies 372 boost::mpl::for_each<MPQCDataEnergyVector_t>( 373 printSum<MPQCDataEnergyMap_t>( 374 subsetmap, 375 MPQCData_Energy_fused, 376 jobids, 377 container->getContainer(), 378 MatrixNrLookup) 379 ); 380 // TODO: Histogram still needs cstor taking just vector<double> 381 382 383 // TODO: We need to put forces into specific class and implement operators 384 // // sum up and print forces 385 // boost::mpl::for_each<MPQCDataForceVector_t>( 386 // printSum<MPQCDataForceMap_t>( 387 // subsetmap, 388 // MPQCData_Force_fused, 389 // jobids, 390 // container->getContainer(), 391 // MatrixNrLookup) 392 // ); 393 394 // TODO: Times should just be summed not orthogonalized 395 // // sum up and print times 396 // boost::mpl::for_each<MPQCDataTimeVector_t>( 397 // printSum<MPQCDataTimeMap_t>( 398 // subsetmap, 399 // MPQCData_Time_fused, 400 // jobids, 401 // container->getContainer(), 402 // MatrixNrLookup) 403 // ); 404 } 353 405 354 406 // combine all found data
Note:
See TracChangeset
for help on using the changeset viewer.