Changeset 851be8
- Timestamp:
- Oct 25, 2011, 12:08:03 PM (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:
- 3a9091
- Parents:
- 730d7a
- git-author:
- Frederik Heber <heber@…> (10/20/11 11:05:14)
- git-committer:
- Frederik Heber <heber@…> (10/25/11 12:08:03)
- Location:
- src/Fragmentation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/AdaptivityMap.cpp
r730d7a r851be8 23 23 #include <fstream> 24 24 25 #include "CodePatterns/Assert.hpp" 25 26 #include "CodePatterns/Log.hpp" 26 27 … … 51 52 * \param value energy value 52 53 */ 53 void AdaptivityMap::InsertIntoAdaptiveCriteriaList(std::map<int, std::pair<double,int> > *AdaptiveCriteriaList, int FragOrder, int No, double Value) const 54 { 54 void AdaptivityMap::InsertIntoAdaptiveCriteriaList(int FragOrder, int No, double Value) 55 { 56 ASSERT( AdaptiveCriteriaList != NULL, 57 "AdaptivityMap::InsertIntoAdaptiveCriteriaList() - AdaptiveCriteriaList is not allocated yet."); 55 58 const_iterator marker = find(No); // find keyset to Frag No. 56 59 if (marker != end()) { // if found … … 80 83 /** Scans the adaptive order file and insert (index, value) into map. 81 84 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 82 * \return adaptive criteria list from file 83 */ 84 std::map<int, std::pair<double,int> > * AdaptivityMap::ScanAdaptiveFileIntoMap(std::string &path) 85 { 86 std::map<int, pair<double,int> > *AdaptiveCriteriaList = new std::map<int, pair<double,int> >; 85 */ 86 void AdaptivityMap::ScanAdaptiveFileIntoMap(std::string &path) 87 { 87 88 int No = 0, FragOrder = 0; 88 89 double Value = 0.; … … 93 94 if (InputFile.fail()) { 94 95 DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl); 95 return AdaptiveCriteriaList;96 return; 96 97 } 97 98 … … 113 114 114 115 // clean the list of those entries that have been superceded by higher order terms already 115 InsertIntoAdaptiveCriteriaList( AdaptiveCriteriaList,FragOrder, No, Value);116 InsertIntoAdaptiveCriteriaList(FragOrder, No, Value); 116 117 } 117 118 } … … 120 121 InputFile.clear(); 121 122 } 122 123 return AdaptiveCriteriaList;124 123 }; 125 124 126 125 /** Maps adaptive criteria list back onto (Value, (Root Nr., Order)) 127 126 * (i.e. sorted by value to pick the highest ones) 128 * \param *out output stream for debugging129 * \param &AdaptiveCriteriaList list to insert into130 127 * \param *mol molecule with atoms 131 128 * \return remapped list 132 129 */ 133 std::map<double, std::pair<int,int> > * AdaptivityMap::ReMapAdaptiveCriteriaListToValue(std::map<int, std::pair<double,int> > *AdaptiveCriteriaList,molecule *mol)130 void AdaptivityMap::ReMapAdaptiveCriteriaListToValue(molecule *mol) 134 131 { 135 132 atom *Walker = NULL; 136 std::map<double, std::pair<int,int> > *FinalRootCandidates = new std::map<double, std::pair<int,int> > ; 133 ASSERT( AdaptiveCriteriaList != NULL, 134 "AdaptivityMap::ReMapAdaptiveCriteriaListToValue() - AdaptiveCriteriaList is not allocated yet."); 135 FinalRootCandidates = new AdaptiveCriteriaValueMap; 137 136 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); 138 for( std::map<int, std::pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) {137 for(AdaptiveCriteriaIndexMap::const_iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) { 139 138 Walker = mol->FindAtom((*runner).first); 140 139 if (Walker != NULL) { … … 151 150 } 152 151 } 153 return FinalRootCandidates;154 152 }; 155 153 … … 175 173 return lines; 176 174 }; 175 176 /** Marks all candidate sites for update if below adaptive threshold. 177 * Picks a given number of highest values and set *AtomMask to true. 178 * \param *AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively 179 * \param Order desired order 180 * \param *mol molecule with atoms 181 * \return true - if update is necessary, false - not 182 */ 183 bool AdaptivityMap::MarkUpdateCandidates(bool *AtomMask, int Order, molecule *mol) const 184 { 185 atom *Walker = NULL; 186 int No = -1; 187 bool status = false; 188 ASSERT( FinalRootCandidates != NULL, 189 "AdaptivityMap::MarkUpdateCandidates() - FinalRootCandidates is not allocated yet."); 190 for(AdaptiveCriteriaValueMap::const_iterator runner = FinalRootCandidates->upper_bound(pow(10.,Order)); runner != FinalRootCandidates->end(); runner++) { 191 No = (*runner).second.first; 192 Walker = mol->FindAtom(No); 193 //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->getNr()]) { 194 DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl); 195 AtomMask[No] = true; 196 status = true; 197 //} else 198 //Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", however MinimumRingSize of " << MinimumRingSize[Walker->getNr()] << " does not allow further adaptive increase." << endl; 199 } 200 return status; 201 }; 202 203 /** Checks whether there are any adaptive items currently. 204 * 205 * @return true - there are items for adaptive refinement, false - there are none 206 */ 207 bool AdaptivityMap::IsAdaptiveCriteriaListEmpty() const 208 { 209 ASSERT( AdaptiveCriteriaList != NULL, 210 "AdaptivityMap::ReMapAdaptiveCriteriaListToValue() - AdaptiveCriteriaList is not allocated yet."); 211 return AdaptiveCriteriaList->empty(); 212 } -
src/Fragmentation/AdaptivityMap.hpp
r730d7a r851be8 29 29 ~AdaptivityMap(); 30 30 31 void InsertIntoAdaptiveCriteriaList( std::map<int, std::pair<double,int> > *AdaptiveCriteriaList, int FragOrder, int No, double Value) const;32 std::map<int, std::pair<double,int> > *ScanAdaptiveFileIntoMap(std::string &path);33 std::map<double, std::pair<int,int> > * ReMapAdaptiveCriteriaListToValue(std::map<int, std::pair<double,int> > *AdaptiveCriteriaList,molecule *mol);31 void InsertIntoAdaptiveCriteriaList(int FragOrder, int No, double Value); 32 void ScanAdaptiveFileIntoMap(std::string &path); 33 void ReMapAdaptiveCriteriaListToValue(molecule *mol); 34 34 int CountLinesinFile(std::ifstream &InputFile) const; 35 bool MarkUpdateCandidates(bool *AtomMask, int Order, molecule *mol) const ; 36 37 bool IsAdaptiveCriteriaListEmpty() const; 38 39 private: 40 typedef std::map<double, std::pair<int,int> > AdaptiveCriteriaValueMap; 41 typedef std::map<int, std::pair<double,int> > AdaptiveCriteriaIndexMap; 42 43 AdaptiveCriteriaIndexMap *AdaptiveCriteriaList; 44 AdaptiveCriteriaValueMap *FinalRootCandidates; 35 45 }; 36 46 -
src/Fragmentation/Fragmentation.cpp
r730d7a r851be8 468 468 469 469 // parse the EnergyPerFragment file 470 std::map<int, std::pair<double,int> > *AdaptiveCriteriaList = IndexKeySetList->ScanAdaptiveFileIntoMap(path); // (Root No., (Value, Order)) ! 471 if (AdaptiveCriteriaList->empty()) { 470 IndexKeySetList->ScanAdaptiveFileIntoMap(path); // (Root No., (Value, Order)) ! 471 // then map back onto (Value, (Root Nr., Order)) (i.e. sorted by value to pick the highest ones) 472 IndexKeySetList->ReMapAdaptiveCriteriaListToValue(mol); 473 474 // pick the ones still below threshold and mark as to be adaptively updated 475 if (IndexKeySetList->IsAdaptiveCriteriaListEmpty()) { 472 476 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl); 473 477 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { … … 480 484 } 481 485 } 482 } 483 // then map back onto (Value, (Root Nr., Order)) (i.e. sorted by value to pick the highest ones) 484 std::map<double, std::pair<int,int> > *FinalRootCandidates = IndexKeySetList->ReMapAdaptiveCriteriaListToValue(AdaptiveCriteriaList, mol); 485 486 // pick the ones still below threshold and mark as to be adaptively updated 487 MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, mol); 486 } else { 487 IndexKeySetList->MarkUpdateCandidates(AtomMask, Order, mol); 488 } 488 489 489 490 delete[](IndexKeySetList); 490 delete[](AdaptiveCriteriaList);491 delete[](FinalRootCandidates);492 491 } else { // global increase of Bond Order 493 492 for(molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { -
src/Fragmentation/fragmentation_helpers.cpp
r730d7a r851be8 37 37 38 38 using namespace std; 39 40 41 42 43 /** Marks all candidate sites for update if below adaptive threshold.44 * Picks a given number of highest values and set *AtomMask to true.45 * \param *out output stream for debugging46 * \param *AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively47 * \param FinalRootCandidates list candidates to check48 * \param Order desired order49 * \param *mol molecule with atoms50 * \return true - if update is necessary, false - not51 */52 bool MarkUpdateCandidates(bool *AtomMask, std::map<double, std::pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)53 {54 atom *Walker = NULL;55 int No = -1;56 bool status = false;57 for(map<double, pair<int,int> >::iterator runner = FinalRootCandidates.upper_bound(pow(10.,Order)); runner != FinalRootCandidates.end(); runner++) {58 No = (*runner).second.first;59 Walker = mol->FindAtom(No);60 //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->getNr()]) {61 DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl);62 AtomMask[No] = true;63 status = true;64 //} else65 //Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", however MinimumRingSize of " << MinimumRingSize[Walker->getNr()] << " does not allow further adaptive increase." << endl;66 }67 return status;68 };69 39 70 40 /** print atom mask for debugging. -
src/Fragmentation/fragmentation_helpers.hpp
r730d7a r851be8 22 22 typedef std::deque<int> KeyStack; 23 23 24 class AdaptivityMap;25 class bond;26 24 class Graph; 27 25 class KeySet; 28 26 class molecule; 29 27 30 bool MarkUpdateCandidates(bool *AtomMask, std::map<double, std::pair<int,int> > &FinalRootCandidates, int Order, molecule *mol);31 28 void PrintAtomMask(bool *AtomMask, int AtomCount); 32 29
Note:
See TracChangeset
for help on using the changeset viewer.