- Timestamp:
- Nov 21, 2012, 9:57:01 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:
- 635645
- Parents:
- a22e05
- git-author:
- Frederik Heber <heber@…> (08/08/12 11:33:59)
- git-committer:
- Frederik Heber <heber@…> (11/21/12 09:57:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
ra22e05 rc4ee08 186 186 } 187 187 188 189 /** Print MPQCData from received results. 190 * 191 * @param results results with ids to associate with fragment number 192 * @param fragmentData MPQCData resulting from the jobs 193 * @param KeySetFilename filename with keysets to associate forces correctly 194 * @param NoAtoms total number of atoms 188 /** Creates a lookup from FragmentJob::id to the true fragment number. 189 * 190 * @param results result with job ids 191 * @param MatrixNrLookup Lookup up-map, filled on return 192 * @param FragmentCounter total number of fragments on return 195 193 */ 196 bool printReceivedMPQCResults(194 void createMatrixNrLookup( 197 195 const std::vector<FragmentResult::ptr> &results, 198 const std::vector<MPQCData> &fragmentData, 199 const std::string &KeySetFilename, 200 size_t NoAtoms) 201 { 202 EnergyMatrix Energy; 203 EnergyMatrix EnergyFragments; 204 ForceMatrix Force; 205 ForceMatrix ForceFragments; 206 196 std::map< JobId_t, size_t > &MatrixNrLookup, 197 size_t &FragmentCounter) 198 { 207 199 // align fragments 208 std::map< JobId_t, size_t > MatrixNrLookup;209 size_tFragmentCounter = 0;200 MatrixNrLookup.clear(); 201 FragmentCounter = 0; 210 202 { 211 203 // bring ids in order ... … … 228 220 } 229 221 LOG(1, "INFO: There are " << FragmentCounter << " fragments."); 230 222 } 223 224 /** Place results from FragmentResult into EnergyMatrix and ForceMatrix. 225 * 226 * @param results results with ids to associate with fragment number 227 * @param fragmentData MPQCData resulting from the jobs 228 * @param MatrixNrLookup Lookup up-map from job id to fragment number 229 * @param FragmentCounter total number of fragments 230 * @param NoAtoms total number of atoms 231 * @param Energy energy matrix to be filled on return 232 * @param Force force matrix to be filled on return 233 * @return true - everything ok, false - else 234 */ 235 bool putResultsintoMatrices( 236 const std::vector<FragmentResult::ptr> &results, 237 const std::vector<MPQCData> &fragmentData, 238 std::map< JobId_t, size_t > &MatrixNrLookup, 239 const size_t FragmentCounter, 240 const size_t NoAtoms, 241 EnergyMatrix &Energy, 242 ForceMatrix &Force) 243 { 244 ASSERT( results.size() == fragmentData.size(), 245 "printReceivedMPQCResults() - results and fragmentData differ in size."); 231 246 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 232 247 std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin(); … … 281 296 return false; 282 297 283 // initialise indices 298 return true; 299 } 300 301 void convertMPQCDatatoEnergyMap( 302 const std::vector<MPQCData> &fragmentData, 303 std::vector<MPQCDataEnergyMap_t> &MPQCData_Energy_fused) 304 { 305 // energy_t 306 MPQCData_Energy_fused.clear(); 307 MPQCData_Energy_fused.reserve(fragmentData.size()); 308 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 309 dataiter != fragmentData.end(); ++dataiter) { 310 const MPQCData &extractedData = *dataiter; 311 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 312 MPQCDataEnergyMap_t instance; 313 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total; 314 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion; 315 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb; 316 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange; 317 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation; 318 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap; 319 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic; 320 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore; 321 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues; 322 MPQCData_Energy_fused.push_back(instance); 323 } 324 } 325 326 void convertMPQCDatatoForceMap( 327 const std::vector<MPQCData> &fragmentData, 328 const KeySetsContainer &ForceKeySet, 329 std::vector<MPQCDataForceMap_t> &MPQCData_Force_fused) 330 { 331 // forces 332 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(), 333 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size."); 334 MPQCData_Force_fused.clear(); 335 MPQCData_Force_fused.reserve(fragmentData.size()); 336 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 337 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin(); 338 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) { 339 const MPQCData &extractedData = *dataiter; 340 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 341 MPQCDataForceMap_t instance; 342 // must convert int to index_t 343 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end()); 344 boost::fusion::at_key<MPQCDataFused::forces>(instance) = 345 IndexedVectors(indices, extractedData.forces); 346 MPQCData_Force_fused.push_back(instance); 347 } 348 } 349 350 void convertMPQCDatatoGridMap( 351 const std::vector<MPQCData> &fragmentData, 352 std::vector<MPQCDataGridMap_t> &MPQCData_Grid_fused) 353 { 354 // sampled_grid 355 MPQCData_Grid_fused.clear(); 356 MPQCData_Grid_fused.reserve(fragmentData.size()); 357 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 358 dataiter != fragmentData.end(); ++dataiter) { 359 const MPQCData &extractedData = *dataiter; 360 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 361 MPQCDataGridMap_t instance; 362 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid; 363 MPQCData_Grid_fused.push_back(instance); 364 } 365 } 366 367 void convertMPQCDatatoTimeMap( 368 const std::vector<MPQCData> &fragmentData, 369 std::vector<MPQCDataTimeMap_t> &MPQCData_Time_fused) 370 { 371 // times 372 MPQCData_Time_fused.clear(); 373 MPQCData_Time_fused.reserve(fragmentData.size()); 374 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 375 dataiter != fragmentData.end(); ++dataiter) { 376 const MPQCData &extractedData = *dataiter; 377 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 378 MPQCDataTimeMap_t instance; 379 boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime; 380 boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime; 381 boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops; 382 MPQCData_Time_fused.push_back(instance); 383 } 384 } 385 386 /** Print MPQCData from received results. 387 * 388 * @param results results with ids to associate with fragment number 389 * @param fragmentData MPQCData resulting from the jobs 390 * @param KeySetFilename filename with keysets to associate forces correctly 391 * @param NoAtoms total number of atoms 392 */ 393 bool printReceivedMPQCResults( 394 const std::vector<FragmentResult::ptr> &results, 395 const std::vector<MPQCData> &fragmentData, 396 const std::string &KeySetFilename, 397 size_t NoAtoms) 398 { 399 // create lookup from job nr to fragment number 400 std::map< JobId_t, size_t > MatrixNrLookup; 401 size_t FragmentCounter = 0; 402 createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter); 403 404 // place results into maps 405 EnergyMatrix Energy; 406 ForceMatrix Force; 407 if (!putResultsintoMatrices(results, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force)) 408 return false; 409 410 // initialise keysets 284 411 KeySetsContainer KeySet; 285 412 KeySetsContainer ForceKeySet; … … 289 416 290 417 { 418 // else needs keysets without hydrogens 291 419 std::stringstream filename; 292 420 filename << FRAGMENTPREFIX << KEYSETFILE; … … 295 423 296 424 { 425 // forces need keysets including hydrogens 297 426 std::stringstream filename; 298 427 filename << FRAGMENTPREFIX << FORCESFILE; … … 307 436 SubsetMap::ptr subsetmap(new SubsetMap(*container)); 308 437 309 // we probably don't need this, it suffices if IndexedVectors has some extra indices310 // // forces need different keysets: they must include hydrogen311 // // (though without ones added by saturation)312 // IndexSetContainer::ptr forceindices(new IndexSetContainer(ForceKeySet));313 // // create the map of all keysets314 // SubsetMap::ptr subsetmapforces(new SubsetMap(*forceindices));315 316 438 /// convert all MPQCData to MPQCDataMap_t 317 439 { 318 // energy_t319 std::vector<MPQCDataEnergyMap_t> MPQCData_Energy_fused;320 MPQCData_Energy_fused.reserve(fragmentData.size());321 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();322 dataiter != fragmentData.end(); ++dataiter) {323 const MPQCData &extractedData = *dataiter;324 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");325 MPQCDataEnergyMap_t instance;326 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;327 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;328 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;329 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;330 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;331 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;332 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;333 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;334 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;335 MPQCData_Energy_fused.push_back(instance);336 }337 338 // forces339 440 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(), 340 441 "FragmentationAutomationAction::performCall() - ForceKeySet's KeySets and fragmentData differ in size."); 442 443 std::vector<MPQCDataEnergyMap_t> MPQCData_Energy_fused; 444 convertMPQCDatatoEnergyMap(fragmentData, MPQCData_Energy_fused); 341 445 std::vector<MPQCDataForceMap_t> MPQCData_Force_fused; 342 MPQCData_Force_fused.reserve(fragmentData.size()); 343 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 344 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin(); 345 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) { 346 const MPQCData &extractedData = *dataiter; 347 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 348 MPQCDataForceMap_t instance; 349 // must convert int to index_t 350 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end()); 351 boost::fusion::at_key<MPQCDataFused::forces>(instance) = 352 IndexedVectors(indices, extractedData.forces); 353 MPQCData_Force_fused.push_back(instance); 354 } 355 356 // sampled_grid 446 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused); 357 447 std::vector<MPQCDataGridMap_t> MPQCData_Grid_fused; 358 MPQCData_Grid_fused.reserve(fragmentData.size()); 359 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 360 dataiter != fragmentData.end(); ++dataiter) { 361 const MPQCData &extractedData = *dataiter; 362 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 363 MPQCDataGridMap_t instance; 364 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid; 365 MPQCData_Grid_fused.push_back(instance); 366 } 367 368 // times 448 convertMPQCDatatoGridMap(fragmentData, MPQCData_Grid_fused); 369 449 std::vector<MPQCDataTimeMap_t> MPQCData_Time_fused; 370 MPQCData_Time_fused.reserve(fragmentData.size()); 371 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 372 dataiter != fragmentData.end(); ++dataiter) { 373 const MPQCData &extractedData = *dataiter; 374 LOG(2, "DEBUG: Current extracted Data is " << extractedData << "."); 375 MPQCDataTimeMap_t instance; 376 boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime; 377 boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime; 378 boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops; 379 MPQCData_Time_fused.push_back(instance); 380 } 450 convertMPQCDatatoTimeMap(fragmentData, MPQCData_Time_fused); 381 451 382 452 // create a vector of all job ids … … 452 522 if (!KeySet.ParseManyBodyTerms()) return false; 453 523 524 EnergyMatrix EnergyFragments; 525 ForceMatrix ForceFragments; 454 526 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return false; 455 527 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return false;
Note:
See TracChangeset
for help on using the changeset viewer.