Changeset 5a8512
- Timestamp:
- Jul 2, 2012, 7:54:13 AM (13 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:
- bc1625
- Parents:
- a98afb
- git-author:
- Frederik Heber <heber@…> (04/19/12 18:24:04)
- git-committer:
- Frederik Heber <heber@…> (07/02/12 07:54:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/controller.cpp
ra98afb r5a8512 43 43 #include "Fragmentation/KeySetsContainer.hpp" 44 44 #include "FragmentController.hpp" 45 #include "Helpers/defs.hpp" 45 46 #include "Jobs/MPQCCommandJob.hpp" 46 47 #include "Jobs/MPQCCommandJob_MPQCData.hpp" … … 115 116 /** Print MPQCData from received results. 116 117 * 117 * @param results vector of all received FragmentResult's 118 * @param KeySetFilename filename containing keysets 118 * @param results received results to extract MPQCData from 119 * @param KeySetFilename filename with keysets to associate forces correctly 120 * @param NoAtoms total number of atoms 119 121 */ 120 122 bool printReceivedMPQCResults( 121 std::vector<FragmentResult::ptr> &results, 122 const std::string &KeySetFilename) 123 const std::vector<FragmentResult::ptr> &results, 124 const std::string &KeySetFilename, 125 size_t NoAtoms) 123 126 { 124 127 EnergyMatrix Energy; … … 128 131 KeySetsContainer KeySet; 129 132 130 // place results into EnergyMatrix and ForceMatrix 131 //if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return false; 132 //if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return false; 133 // combine all found data 133 // align fragments 134 std::map< JobId_t, size_t > MatrixNrLookup; 135 size_t FragmentCounter = 0; 136 { 137 // bring ids in order ... 138 typedef std::map< JobId_t, FragmentResult::ptr> IdResultMap_t; 139 IdResultMap_t IdResultMap; 140 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin(); 141 iter != results.end(); ++iter) { 142 #ifndef NDEBUG 143 std::pair< IdResultMap_t::iterator, bool> inserter = 144 #endif 145 IdResultMap.insert( make_pair((*iter)->getId(), *iter) ); 146 ASSERT( inserter.second, 147 "printReceivedMPQCResults() - two results have same id " 148 +toString((*iter)->getId())+"."); 149 } 150 // ... and fill lookup 151 for(IdResultMap_t::const_iterator iter = IdResultMap.begin(); 152 iter != IdResultMap.end(); ++iter) 153 MatrixNrLookup.insert( make_pair(iter->first, FragmentCounter++) ); 154 } 155 LOG(1, "INFO: There are " << FragmentCounter << " fragments."); 156 157 // extract results 134 158 std::vector<MPQCData> fragmentData(results.size()); 135 159 MPQCData combinedData; … … 141 165 MPQCData extractedData; 142 166 std::stringstream inputstream((*iter)->result); 167 LOG(2, "DEBUG: First 50 characters FragmentResult's string: "+(*iter)->result.substr(0, 50)); 143 168 boost::archive::text_iarchive ia(inputstream); 144 169 ia >> extractedData; 145 170 LOG(1, "INFO: extracted data is " << extractedData << "."); 146 } 147 171 172 // place results into EnergyMatrix ... 173 { 174 MatrixContainer::MatrixArray matrix; 175 matrix.resize(1); 176 matrix[0].resize(1, extractedData.energy); 177 if (!Energy.AddMatrix( 178 std::string("MPQCJob ")+toString((*iter)->getId()), 179 matrix, 180 MatrixNrLookup[(*iter)->getId()])) { 181 ELOG(1, "Adding energy matrix failed."); 182 return false; 183 } 184 } 185 // ... and ForceMatrix (with two empty columns in front) 186 { 187 MatrixContainer::MatrixArray matrix; 188 const size_t rows = extractedData.forces.size(); 189 matrix.resize(rows); 190 for (size_t i=0;i<rows;++i) { 191 const size_t columns = 2+extractedData.forces[i].size(); 192 matrix[i].resize(columns, 0.); 193 // for (size_t j=0;j<2;++j) 194 // matrix[i][j] = 0.; 195 for (size_t j=2;j<columns;++j) 196 matrix[i][j] = extractedData.forces[i][j-2]; 197 } 198 if (!Force.AddMatrix( 199 std::string("MPQCJob ")+toString((*iter)->getId()), 200 matrix, 201 MatrixNrLookup[(*iter)->getId()])) { 202 ELOG(1, "Adding force matrix failed."); 203 return false; 204 } 205 } 206 } 207 // add one more matrix (not required for energy) 208 MatrixContainer::MatrixArray matrix; 209 matrix.resize(1); 210 matrix[0].resize(1, 0.); 211 if (!Energy.AddMatrix(std::string("MPQCJob total"), matrix, FragmentCounter)) 212 return false; 213 // but for energy because we need to know total number of atoms 214 matrix.resize(NoAtoms); 215 for (size_t i = 0; i< NoAtoms; ++i) 216 matrix[i].resize(2+NDIM, 0.); 217 if (!Force.AddMatrix(std::string("MPQCJob total"), matrix, FragmentCounter)) 218 return false; 219 220 221 // combine all found data 148 222 if (!Energy.InitialiseIndices()) return false; 149 223 … … 172 246 } 173 247 248 // for debugging print resulting energy and forces 249 LOG(1, "INFO: Resulting energy is " << Energy.Matrix[ FragmentCounter ][0][0]); 250 std::stringstream output; 251 for (int i=0; i< Force.RowCounter[FragmentCounter]; ++i) { 252 for (int j=0; j< Force.ColumnCounter[FragmentCounter]; ++j) 253 output << Force.Matrix[ FragmentCounter ][i][j] << " "; 254 output << "\n"; 255 } 256 LOG(1, "INFO: Resulting forces are " << std::endl << output.str()); 257 174 258 return true; 259 } 260 261 /** Helper function to get number of atoms somehow. 262 * 263 * Here, we just parse the number of lines in the adjacency file as 264 * it should correspond to the number of atoms, except when some atoms 265 * are not bonded, but then fragmentation makes no sense. 266 * 267 * @param path path to the adjacency file 268 */ 269 size_t getNoAtomsFromAdjacencyFile(const std::string &path) 270 { 271 size_t NoAtoms = 0; 272 273 // parse in special file to get atom count (from line count) 274 std::string filename(path); 275 filename += FRAGMENTPREFIX; 276 filename += ADJACENCYFILE; 277 std::ifstream adjacency(filename.c_str()); 278 if (adjacency.fail()) { 279 LOG(0, endl << "getNoAtomsFromAdjacencyFile() - Unable to open " << filename << ", is the directory correct?"); 280 return false; 281 } 282 std::string buffer; 283 while (getline(adjacency, buffer)) 284 NoAtoms++; 285 LOG(1, "INFO: There are " << NoAtoms << " atoms."); 286 287 return NoAtoms; 175 288 } 176 289 … … 355 468 case ReceiveMPQCIndex: 356 469 { 357 if (argc == 4) {358 ELOG(1, "'receivempqc' require s one option: [KeySetFilename].");470 if (argc < 5) { 471 ELOG(1, "'receivempqc' require one option: [path to fragment files]."); 359 472 } else { 360 const std::string KeySetFilename= argv[4];361 LOG(1, "INFO: Parsing id associations from " << KeySetFilename<< ".");473 const std::string path = argv[4]; 474 LOG(1, "INFO: Parsing fragment files from " << path << "."); 362 475 std::vector<FragmentResult::ptr> results = controller.getReceivedResults(); 363 printReceivedMPQCResults(results, KeySetFilename); 476 printReceivedMPQCResults( 477 results, 478 path, 479 getNoAtomsFromAdjacencyFile(path)); 364 480 } 365 481 break;
Note:
See TracChangeset
for help on using the changeset viewer.