Changeset 47d041 for src/Fragmentation/MatrixContainer.cpp
- Timestamp:
- Nov 3, 2011, 7:44:01 PM (14 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:
- 41a467
- Parents:
- 50e4e5
- git-author:
- Frederik Heber <heber@…> (10/27/11 11:53:58)
- git-committer:
- Frederik Heber <heber@…> (11/03/11 19:44:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/MatrixContainer.cpp
r50e4e5 r47d041 56 56 bool MatrixContainer::InitialiseIndices(class MatrixContainer *_container) 57 57 { 58 DoLog(0) && (Log() << Verbose(0) << "Initialising indices");59 58 if (_container == NULL) { 60 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);59 LOG(0, "Initialising indices with trivial mapping."); 61 60 Indices.resize(MatrixCounter + 1); 62 61 for(int i=MatrixCounter+1;i--;) { … … 66 65 } 67 66 } else { 68 DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);67 std::stringstream output; 69 68 if (MatrixCounter != _container->MatrixCounter) 70 69 return false; … … 76 75 for(int j=_container->RowCounter[i];j--;) { 77 76 Indices[i][j] = _container->Indices[i][j]; 78 //Log() << Verbose(0)<< Indices[i][j] << "\t";77 output << Indices[i][j] << "\t"; 79 78 } 80 //Log() << Verbose(0) << endl;81 }79 } 80 LOG(0, "Initialising indices from other MatrixContainer: " << output.str()); 82 81 } 83 82 return true; … … 104 103 105 104 if (input.fail()) { 106 DoeLog(1) && (eLog()<< Verbose(1) << endl << "MatrixContainer::ParseMatrix: Unable to parse istream." << endl);105 ELOG(1, endl << "MatrixContainer::ParseMatrix: Unable to parse istream."); 107 106 //performCriticalExit(); 108 107 return false; … … 119 118 for(int k=skipcolumns;k--;) 120 119 line >> Header[MatrixNr]; 121 L og() << Verbose(0) << line.str() << endl;120 LOG(0, line.str()); 122 121 123 122 // scan header for number of columns … … 129 128 ColumnCounter[MatrixNr]++; 130 129 } 131 L og() << Verbose(0) << line.str() << endl;132 L og() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;130 LOG(0, line.str()); 131 LOG(1, "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "."); 133 132 if (ColumnCounter[MatrixNr] == 0) { 134 DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from ostream." << endl);133 ELOG(0, "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from ostream."); 135 134 performCriticalExit(); 136 135 } … … 142 141 while (!input.eof()) { 143 142 input.getline(filename, 1023); 144 L og() << Verbose(0) << "Comparing: " << strncmp(filename,"MeanForce",9) << endl;143 LOG(0, "Comparing: " << strncmp(filename,"MeanForce",9)); 145 144 RowCounter[MatrixNr]++; // then line was not last MeanForce 146 145 if (strncmp(filename,"MeanForce", 9) == 0) { … … 148 147 } 149 148 } 150 L og() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from input stream." << endl;149 LOG(1, "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from input stream."); 151 150 if (RowCounter[MatrixNr] == 0) { 152 DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from input stream." << endl);151 ELOG(0, "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from input stream."); 153 152 performCriticalExit(); 154 153 } … … 177 176 input.getline(dummy, 1023); // skip header 178 177 line.str(dummy); 179 L og() << Verbose(0) << "Header: " << line.str() << endl;178 LOG(0, "Header: " << line.str()); 180 179 for(int k=skipcolumns;k--;) // skip columns in header too 181 180 line >> filename; … … 183 182 for(int j=0;j<RowCounter[MatrixNr];j++) { 184 183 input.getline(filename, 1023); 185 stringstream lines(filename); 186 Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl; 184 std::stringstream lines(filename); 185 std::stringstream output; 186 output << "INFO: Matrix at level " << j << ":";// << filename << endl; 187 187 for(int k=skipcolumns;k--;) 188 188 lines >> filename; 189 189 for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) { 190 190 lines >> Matrix[MatrixNr][j][k]; 191 Log() << Verbose(1) << " " << std::setprecision(2) << Matrix[MatrixNr][j][k] << endl; 192 } 191 output << " " << std::setprecision(2) << Matrix[MatrixNr][j][k] << endl; 192 } 193 LOG(1, output.str()); 193 194 } 194 195 … … 227 228 input.open(file.str().c_str(), ios::in); 228 229 if (input.bad()) { 229 DoLog(0) && (Log() << Verbose(0) << endl << "MatrixContainer::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);230 LOG(0, endl << "MatrixContainer::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?"); 230 231 return false; 231 232 } … … 236 237 } 237 238 input.close(); 238 DoLog(0) && (Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl);239 240 DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);239 LOG(0, "Determined " << MatrixCounter << " fragments."); 240 241 LOG(0, "Parsing through each fragment and retrieving " << prefix << suffix << "."); 241 242 Header.clear(); 242 243 Matrix.clear(); … … 253 254 file << name << FRAGMENTPREFIX << FragmentNumber << prefix << suffix; 254 255 std::ifstream input(file.str().c_str()); 255 DoLog(0) &&( Log() << Verbose(0) << "Opening " << file.str() << " ... " << endl);256 LOG(1, "INFO: Opening " << file.str() << " ... "); 256 257 if (!ParseMatrix(input, skiplines, skipcolumns, i)) { 257 258 input.close(); … … 373 374 // go through each order 374 375 for (int CurrentFragment=0;CurrentFragment<KeySets.FragmentsPerOrder[Order];CurrentFragment++) { 375 //L og() << Verbose(0) << "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;376 //LOG(0, "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "."); 376 377 // then go per order through each suborder and pick together all the terms that contain this fragment 377 378 for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order 378 379 for (int j=0;j<KeySets.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder 379 380 if (KeySets.Contains(KeySets.OrderSet[Order][CurrentFragment], KeySets.OrderSet[SubOrder][j])) { 380 //L og() << Verbose(0) << "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "." << endl;381 //LOG(0, "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "."); 381 382 // if the fragment's indices are all in the current fragment 382 383 for(int k=0;k<RowCounter[ KeySets.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment 383 384 int m = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][k]; 384 //L og() << Verbose(0) << "Current index is " << k << "/" << m << "." << endl;385 //LOG(0, "Current index is " << k << "/" << m << "."); 385 386 if (m != -1) { // if it's not an added hydrogen 386 387 for (int l=0;l<RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment 387 //L og() << Verbose(0) << "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "." << endl;388 //LOG(0, "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "."); 388 389 if (m == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l]) { 389 390 m = l; … … 391 392 } 392 393 } 393 //L og() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;394 //LOG(0, "Corresponding index in CurrentFragment is " << m << "."); 394 395 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 395 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);396 ELOG(0, "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!"); 396 397 performCriticalExit(); 397 398 return false; … … 406 407 } 407 408 //if ((ColumnCounter[ KeySets.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1)) 408 //L og() << Verbose(0) << "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;409 //LOG(0, "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1]); 409 410 } 410 411 } else { 411 //L og() << Verbose(0) << "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "." << endl;412 //LOG(0, "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "."); 412 413 } 413 414 } 414 415 } 415 //L og() << Verbose(0) << "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1] << endl;416 //LOG(0, "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1]); 416 417 } 417 418 … … 429 430 char *FragmentNumber = NULL; 430 431 431 DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);432 LOG(0, "Writing fragment files."); 432 433 for(int i=0;i<MatrixCounter;i++) { 433 434 stringstream line; … … 437 438 output.open(line.str().c_str(), ios::out); 438 439 if (output == NULL) { 439 DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteTotalFragments: Unable to open output energy file " << line.str() << "!" << endl);440 ELOG(0, "MatrixContainer::WriteTotalFragments: Unable to open output energy file " << line.str() << "!"); 440 441 performCriticalExit(); 441 442 return false; … … 463 464 stringstream line; 464 465 465 DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);466 LOG(0, "Writing matrix values of " << suffix << "."); 466 467 line << name << prefix << suffix; 467 468 output.open(line.str().c_str(), ios::out); 468 469 if (output == NULL) { 469 DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteLastMatrix: Unable to open output matrix file " << line.str() << "!" << endl);470 ELOG(0, "MatrixContainer::WriteLastMatrix: Unable to open output matrix file " << line.str() << "!"); 470 471 performCriticalExit(); 471 472 return false;
Note:
See TracChangeset
for help on using the changeset viewer.