- Timestamp:
- Nov 27, 2012, 8:35:34 AM (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:
- c9f9bb
- Parents:
- 0398bd
- git-author:
- Frederik Heber <heber@…> (08/27/12 12:12:59)
- git-committer:
- Frederik Heber <heber@…> (11/27/12 08:35:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
r0398bd r995e2f 198 198 /** Creates a lookup from FragmentJob::id to the true fragment number. 199 199 * 200 * @param results resultwith job ids200 * @param jobids vector with job ids 201 201 * @param MatrixNrLookup Lookup up-map, filled on return 202 202 * @param FragmentCounter total number of fragments on return 203 203 */ 204 204 void createMatrixNrLookup( 205 const std::vector< FragmentResult::ptr> &results,205 const std::vector<JobId_t> &jobids, 206 206 std::map< JobId_t, size_t > &MatrixNrLookup, 207 207 size_t &FragmentCounter) … … 210 210 MatrixNrLookup.clear(); 211 211 FragmentCounter = 0; 212 { 213 // bring ids in order ... 214 typedef std::map< JobId_t, FragmentResult::ptr> IdResultMap_t; 215 IdResultMap_t IdResultMap; 216 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin(); 217 iter != results.end(); ++iter) { 218 #ifndef NDEBUG 219 std::pair< IdResultMap_t::iterator, bool> inserter = 220 #endif 221 IdResultMap.insert( make_pair((*iter)->getId(), *iter) ); 222 ASSERT( inserter.second, 223 "ExtractMPQCDataFromResults() - two results have same id " 224 +toString((*iter)->getId())+"."); 225 } 226 // ... and fill lookup 227 for(IdResultMap_t::const_iterator iter = IdResultMap.begin(); 228 iter != IdResultMap.end(); ++iter) 229 MatrixNrLookup.insert( make_pair(iter->first, FragmentCounter++) ); 212 for (std::vector<JobId_t>::const_iterator iter = jobids.begin(); 213 iter != jobids.end(); ++iter) { 214 #ifndef NDEBUG 215 std::pair< std::map< JobId_t, size_t >::iterator, bool> inserter = 216 #endif 217 MatrixNrLookup.insert( std::make_pair(*iter, FragmentCounter++) ); 218 ASSERT( inserter.second, 219 "createMatrixNrLookup() - two results have same id " 220 +toString(*iter)+"."); 230 221 } 231 222 LOG(1, "INFO: There are " << FragmentCounter << " fragments."); … … 234 225 /** Place results from FragmentResult into EnergyMatrix and ForceMatrix. 235 226 * 236 * @param results results with ids to associate with fragment number227 * @param jobids jobids with ids to associate with fragment number 237 228 * @param fragmentData MPQCData resulting from the jobs 238 229 * @param MatrixNrLookup Lookup up-map from job id to fragment number … … 244 235 */ 245 236 bool putResultsintoMatrices( 246 const std::vector< FragmentResult::ptr> &results,237 const std::vector<JobId_t> &jobids, 247 238 const std::vector<MPQCData> &fragmentData, 248 239 std::map< JobId_t, size_t > &MatrixNrLookup, … … 252 243 ForceMatrix &Force) 253 244 { 254 ASSERT( results.size() == fragmentData.size(),255 "p rintReceivedMPQCResults() - results and fragmentData differ in size.");245 ASSERT( jobids.size() == fragmentData.size(), 246 "putResultsintoMatrices() - jobids and fragmentData differ in size."); 256 247 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 257 std::vector< FragmentResult::ptr>::const_iterator resultiter = results.begin();258 for (; dataiter != fragmentData.end(); ++dataiter, ++ resultiter) {248 std::vector<JobId_t>::const_iterator iditer = jobids.begin(); 249 for (; dataiter != fragmentData.end(); ++dataiter, ++iditer) { 259 250 const MPQCData &extractedData = *dataiter; 260 251 // place results into EnergyMatrix ... … … 264 255 matrix[0].resize(1, extractedData.energies.total); 265 256 if (!Energy.AddMatrix( 266 std::string("MPQCJob ")+toString( (*resultiter)->getId()),257 std::string("MPQCJob ")+toString(*iditer), 267 258 matrix, 268 MatrixNrLookup[ (*resultiter)->getId()])) {259 MatrixNrLookup[*iditer])) { 269 260 ELOG(1, "Adding energy matrix failed."); 270 261 return false; … … 285 276 } 286 277 if (!Force.AddMatrix( 287 std::string("MPQCJob ")+toString( (*resultiter)->getId()),278 std::string("MPQCJob ")+toString(*iditer), 288 279 matrix, 289 MatrixNrLookup[ (*resultiter)->getId()])) {280 MatrixNrLookup[*iditer])) { 290 281 ELOG(1, "Adding force matrix failed."); 291 282 return false; … … 310 301 /** Print MPQCData from received results. 311 302 * 312 * @param results results with ids to associate with fragment number303 * @param jobids jobids with ids to associate with fragment number 313 304 * @param fragmentData MPQCData resulting from the jobs 314 305 * @param KeySetFilename filename with keysets to associate forces correctly … … 318 309 */ 319 310 bool sumUpChargeDensity( 320 const std::vector< FragmentResult::ptr> &results,311 const std::vector<JobId_t> &jobids, 321 312 const std::vector<MPQCData> &fragmentData, 322 313 const std::string &KeySetFilename, … … 327 318 std::map< JobId_t, size_t > MatrixNrLookup; 328 319 size_t FragmentCounter = 0; 329 createMatrixNrLookup( results, MatrixNrLookup, FragmentCounter);320 createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter); 330 321 331 322 // initialise keysets … … 344 335 // create the map of all keysets 345 336 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 346 347 // create a vector of all job ids348 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);349 std::transform(results.begin(), results.end(), jobids.begin(),350 boost::bind(&FragmentResult::getId,351 boost::bind(&FragmentResult::ptr::operator->, _1)));352 337 353 338 /// convert all MPQCData to MPQCDataMap_t … … 374 359 */ 375 360 bool printReceivedMPQCResults( 376 const std::vector< FragmentResult::ptr> &results,361 const std::vector<JobId_t> &jobids, 377 362 const std::vector<MPQCData> &fragmentData, 378 363 const std::string &KeySetFilename, … … 383 368 std::map< JobId_t, size_t > MatrixNrLookup; 384 369 size_t FragmentCounter = 0; 385 createMatrixNrLookup( results, MatrixNrLookup, FragmentCounter);370 createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter); 386 371 387 372 // place results into maps 388 373 EnergyMatrix Energy; 389 374 ForceMatrix Force; 390 if (!putResultsintoMatrices( results, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force))375 if (!putResultsintoMatrices(jobids, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force)) 391 376 return false; 392 377 … … 418 403 // create the map of all keysets 419 404 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 420 421 // create a vector of all job ids422 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);423 std::transform(results.begin(), results.end(), jobids.begin(),424 boost::bind(&FragmentResult::getId,425 boost::bind(&FragmentResult::ptr::operator->, _1)));426 405 427 406 /// convert all MPQCData to MPQCDataMap_t … … 536 515 SamplingGrid &full_sample) 537 516 { 538 // create lookup from job nr to fragment number539 std::map< JobId_t, size_t > MatrixNrLookup;540 size_t FragmentCounter = 0;541 createMatrixNrLookup(fragmentresults, MatrixNrLookup, FragmentCounter);542 543 // initialise keysets544 KeySetsContainer KeySet;545 KeySetsContainer ForceKeySet;546 {547 // else needs keysets without hydrogens548 std::stringstream filename;549 filename << FRAGMENTPREFIX << KEYSETFILE;550 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;551 }552 553 {554 // forces need keysets including hydrogens555 std::stringstream filename;556 filename << FRAGMENTPREFIX << FORCESFILE;557 if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;558 }559 560 /// prepare for OrthogonalSummation561 562 // convert KeySetContainer to IndexSetContainer563 IndexSetContainer::ptr container(new IndexSetContainer(KeySet));564 // create the map of all keysets565 SubsetMap::ptr subsetmap(new SubsetMap(*container));566 567 517 // create a vector of all job ids from short-range 568 518 std::vector<JobId_t> jobids(fragmentresults.size(), JobId::IllegalJob); … … 570 520 boost::bind(&FragmentResult::getId, 571 521 boost::bind(&FragmentResult::ptr::operator->, _1))); 522 523 // create lookup from job nr to fragment number 524 std::map< JobId_t, size_t > MatrixNrLookup; 525 size_t FragmentCounter = 0; 526 createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter); 527 528 // initialise keysets 529 KeySetsContainer KeySet; 530 KeySetsContainer ForceKeySet; 531 { 532 // else needs keysets without hydrogens 533 std::stringstream filename; 534 filename << FRAGMENTPREFIX << KEYSETFILE; 535 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false; 536 } 537 538 { 539 // forces need keysets including hydrogens 540 std::stringstream filename; 541 filename << FRAGMENTPREFIX << FORCESFILE; 542 if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false; 543 } 544 545 /// prepare for OrthogonalSummation 546 547 // convert KeySetContainer to IndexSetContainer 548 IndexSetContainer::ptr container(new IndexSetContainer(KeySet)); 549 // create the map of all keysets 550 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 572 551 573 552 /// convert all MPQCData to MPQCDataMap_t … … 805 784 "FragmentationFragmentationAutomationAction::performCall() - please load the full molecule into the World before."); 806 785 786 // create a vector of all job ids 787 std::vector<JobId_t> jobids(MPQCresults.size(), JobId::IllegalJob); 788 std::transform(MPQCresults.begin(), MPQCresults.end(), jobids.begin(), 789 boost::bind(&FragmentResult::getId, 790 boost::bind(&FragmentResult::ptr::operator->, _1))); 791 807 792 // obtain combined charge density 808 793 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << "."); … … 810 795 Fragment full_fragment; 811 796 sumUpChargeDensity( 812 MPQCresults,797 jobids, 813 798 fragmentData, 814 799 params.path.get(), … … 858 843 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << "."); 859 844 printReceivedMPQCResults( 860 MPQCresults,845 jobids, 861 846 fragmentData, 862 847 params.path.get(),
Note:
See TracChangeset
for help on using the changeset viewer.