Changeset 3690e4 for src/Fragmentation
- Timestamp:
- Feb 2, 2016, 5:50:29 PM (9 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:
- 9ae11c
- Parents:
- d1831e (diff), 62d092 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Fragmentation
- Files:
-
- 2 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/ResultContainer_impl.hpp
rd1831e r3690e4 38 38 boost::archive::text_iarchive ia(inputstream); 39 39 ia >> extractedData; 40 LOG(1, "INFO: extracted data is " << extractedData << ".");40 LOG(1, "INFO: extracted data of #" << (*iter)->getId() << " is " << extractedData << "."); 41 41 fragmentData.push_back(extractedData); 42 42 } -
src/Fragmentation/Automation/VMGFragmentController.cpp
rd1831e r3690e4 76 76 const MPQCData::DoValenceOnly_t _DoValenceOnly, 77 77 const bool _DoPrintDebug, 78 const bool _OpenBoundaryConditions) 78 const bool _OpenBoundaryConditions, 79 const bool _DoSmearCharges) 79 80 { 80 81 std::vector<FragmentJob::ptr> jobs; … … 99 100 _SampleParticles == DoSampleParticles, 100 101 _DoPrintDebug, 101 _OpenBoundaryConditions) ); 102 _OpenBoundaryConditions, 103 _DoSmearCharges) ); 102 104 jobs.push_back(testJob); 103 105 } … … 147 149 _SampleParticles == DoSampleParticles, 148 150 _DoPrintDebug, 149 _OpenBoundaryConditions) ); 151 _OpenBoundaryConditions, 152 _DoSmearCharges) ); 150 153 jobs.push_back(testJob); 151 154 } -
src/Fragmentation/Automation/VMGFragmentController.hpp
rd1831e r3690e4 63 63 * \param _OpenBoundaryConditions whether we have open (true) or periodic (false) 64 64 * boundary conditions 65 * \param _DoSmearCharges whether to smear out electronic charge distributions with bsplines or not 65 66 */ 66 67 bool createLongRangeJobs( … … 73 74 const MPQCData::DoValenceOnly_t _DoValenceOnly, 74 75 const bool _DoPrintDebug, 75 const bool _OpenBoundaryConditions = false); 76 const bool _OpenBoundaryConditions = false, 77 const bool _DoSmearCharges = false); 76 78 77 79 void waitforResults(const size_t NoExpectedResults) -
src/Fragmentation/Exporters/ExportGraph_ToJobs.cpp
rd1831e r3690e4 80 80 RealSpaceMatrix M = World::getInstance().getDomain().getM(); 81 81 M *= 1./AtomicLengthToAngstroem; // scale to atomic length units 82 const double size = M.at(0,0);82 const double size = std::max( std::max(M.at(0,0), M.at(1,1)), M.at(2,2)); 83 83 double end[NDIM] = { size, size, size }; 84 84 const ParserTypes jobtype = -
src/Fragmentation/Interfragmenter.cpp
rd1831e r3690e4 37 37 #include "Interfragmenter.hpp" 38 38 39 #include <list>40 #include <map>41 42 39 #include "CodePatterns/Assert.hpp" 43 40 #include "CodePatterns/Log.hpp" … … 45 42 #include "LinearAlgebra/Vector.hpp" 46 43 47 #include " AtomIdSet.hpp"44 #include "Descriptors/AtomDescriptor.hpp" 48 45 #include "Element/element.hpp" 49 46 #include "Fragmentation/Graph.hpp" … … 53 50 #include "World.hpp" 54 51 55 void Interfragmenter::operator()( 56 size_t MaxOrder, 57 double Rcut,58 const enum HydrogenTreatment treatment)52 53 Interfragmenter::atomkeyset_t Interfragmenter::getAtomKeySetMap( 54 size_t _MaxOrder 55 ) const 59 56 { 60 57 /// create a map of atom to keyset (below equal MaxOrder) 61 typedef std::list<const KeySet *> keysets_t;62 typedef std::map<const atom *, keysets_t > atomkeyset_t;63 58 atomkeyset_t atomkeyset; 64 59 LOG(1, "INFO: Placing all atoms and their keysets into a map."); … … 69 64 const AtomIdSet atoms(keyset); 70 65 const size_t atoms_size = atoms.getAtomIds().size(); 71 if ((atoms_size > MaxOrder) || (atoms_size == 0))66 if ((atoms_size > _MaxOrder) || (atoms_size == 0)) 72 67 continue; 73 68 for (AtomIdSet::const_iterator atomiter = atoms.begin(); … … 87 82 LOG(2, "DEBUG: There are " << atomkeyset.size() << " entries in lookup."); 88 83 84 return atomkeyset; 85 } 86 87 static Vector getAtomIdSetCenter( 88 const AtomIdSet &_atoms) 89 { 90 const molecule * const _mol = (*_atoms.begin())->getMolecule(); 91 const size_t atoms_size = _atoms.getAtomIds().size(); 92 Vector center; 93 for (AtomIdSet::const_iterator iter = _atoms.begin(); 94 iter != _atoms.end(); ++iter) { 95 center += (*iter)->getPosition(); 96 ASSERT ( _mol == (*iter)->getMolecule(), 97 "getAtomIdSetCenter() - ids in same keyset belong to different molecule."); 98 } 99 center *= 1./(double)atoms_size; 100 101 return center; 102 } 103 104 Interfragmenter::candidates_t Interfragmenter::getNeighborsOutsideMolecule( 105 const AtomIdSet &_atoms, 106 double _Rcut, 107 const enum HydrogenTreatment _treatment) const 108 { 109 /// go through linked cell and get all neighboring atoms up to Rcut 110 const LinkedCell::LinkedCell_View view = World::getInstance().getLinkedCell(_Rcut); 111 const Vector center = getAtomIdSetCenter(_atoms); 112 const LinkedCell::LinkedList neighbors = view.getAllNeighbors(_Rcut, center); 113 LOG(4, "DEBUG: Obtained " << neighbors.size() << " neighbors in distance of " 114 << _Rcut << " around " << center << "."); 115 116 /// remove all atoms that belong to same molecule as does one of the 117 /// fragment's atoms 118 const molecule * const _mol = (*_atoms.begin())->getMolecule(); 119 candidates_t candidates; 120 candidates.reserve(neighbors.size()); 121 for (LinkedCell::LinkedList::const_iterator iter = neighbors.begin(); 122 iter != neighbors.end(); ++iter) { 123 const atom * const _atom = static_cast<const atom * const >(*iter); 124 ASSERT( _atom != NULL, 125 "Interfragmenter::getNeighborsOutsideMolecule() - a neighbor is not actually an atom?"); 126 if ((_atom->getMolecule() != _mol) 127 && (_atom->getPosition().DistanceSquared(center) < _Rcut*_Rcut) 128 && ((_treatment == IncludeHydrogen) || (_atom->getType()->getAtomicNumber() != 1))) { 129 candidates.push_back(_atom); 130 } 131 } 132 LOG(3, "DEBUG: There remain " << candidates.size() << " candidates."); 133 134 return candidates; 135 } 136 137 Interfragmenter::atomkeyset_t Interfragmenter::getCandidatesSpecificKeySetMap( 138 const candidates_t &_candidates, 139 const atomkeyset_t &_atomkeyset) const 140 { 141 atomkeyset_t fragmentmap; 142 for (candidates_t::const_iterator candidateiter = _candidates.begin(); 143 candidateiter != _candidates.end(); ++candidateiter) { 144 const atom * _atom = *candidateiter; 145 atomkeyset_t::const_iterator iter = _atomkeyset.find(_atom); 146 ASSERT( iter != _atomkeyset.end(), 147 "Interfragmenter::getAtomSpecificKeySetMap() - could not find atom " 148 +toString(_atom->getId())+" in lookup."); 149 fragmentmap.insert( std::make_pair( _atom, iter->second) ); 150 } 151 LOG(4, "DEBUG: Copied part of lookup map contains " << fragmentmap.size() << " keys."); 152 153 return fragmentmap; 154 } 155 156 void Interfragmenter::combineFragments( 157 const size_t _MaxOrder, 158 const candidates_t &_candidates, 159 atomkeyset_t &_fragmentmap, 160 const KeySet &_keyset, 161 Graph &_InterFragments, 162 int &_counter) 163 { 164 for (candidates_t::const_iterator candidateiter = _candidates.begin(); 165 candidateiter != _candidates.end(); ++candidateiter) { 166 const atom *_atom = *candidateiter; 167 LOG(3, "DEBUG: Current candidate is " << *_atom << "."); 168 atomkeyset_t::iterator finditer = _fragmentmap.find(_atom); 169 ASSERT( finditer != _fragmentmap.end(), 170 "Interfragmenter::combineFragments() - could not find atom " 171 +toString(_atom->getId())+" in fragment specific lookup."); 172 keysets_t &othersets = finditer->second; 173 ASSERT( !othersets.empty(), 174 "Interfragmenter::combineFragments() - keysets to "+toString(_atom->getId())+ 175 "is empty."); 176 keysets_t::iterator otheriter = othersets.begin(); 177 while (otheriter != othersets.end()) { 178 const KeySet &otherset = **otheriter; 179 LOG(3, "DEBUG: Current keyset is " << otherset << "."); 180 // only add them one way round and not the other 181 if (otherset < _keyset) { 182 ++otheriter; 183 continue; 184 } 185 // only add if combined they don't exceed the desired maxorder 186 if (otherset.size() + _keyset.size() > _MaxOrder) { 187 LOG(3, "INFO: Rejecting " << otherset << " as in sum their orders exceed " << _MaxOrder); 188 ++otheriter; 189 continue; 190 } 191 KeySet newset(otherset); 192 newset.insert(_keyset.begin(), _keyset.end()); 193 LOG(3, "DEBUG: Inserting new combined set " << newset << "."); 194 _InterFragments.insert( std::make_pair(newset, std::make_pair(++_counter, 1.))); 195 // finally, remove the set such that no other combination exists 196 otheriter = othersets.erase(otheriter); 197 } 198 } 199 } 200 201 void Interfragmenter::operator()( 202 const size_t MaxOrder, 203 const double Rcut, 204 const enum HydrogenTreatment treatment) 205 { 206 atomkeyset_t atomkeyset = getAtomKeySetMap(MaxOrder); 207 89 208 Graph InterFragments; 90 209 int counter = TotalGraph.size(); … … 101 220 continue; 102 221 103 /// go through linked cell and get all neighboring atoms up to Rcut 104 Vector center; 105 const molecule *_mol = (*atoms.begin())->getMolecule(); 106 for (AtomIdSet::const_iterator iter = atoms.begin(); 107 iter != atoms.end(); ++iter) { 108 center += (*iter)->getPosition(); 109 ASSERT ( _mol == (*iter)->getMolecule(), 110 "Interfragmenter::operator() - ids in same keyset belong to different molecule."); 111 } 112 center *= 1./(double)atoms_size; 113 LinkedCell::LinkedCell_View view = World::getInstance().getLinkedCell(Rcut); 114 LinkedCell::LinkedList neighbors = view.getAllNeighbors(Rcut, center); 115 LOG(4, "DEBUG: Obtained " << neighbors.size() << " neighbors in distance of " 116 << Rcut << " around " << center << "."); 117 118 /// remove all atoms that belong to same molecule as does one of the 119 /// fragment's atoms 120 typedef std::vector<const atom *> candidates_t; 121 candidates_t candidates; 122 candidates.reserve(neighbors.size()); 123 for (LinkedCell::LinkedList::const_iterator iter = neighbors.begin(); 124 iter != neighbors.end(); ++iter) { 125 const atom * const _atom = static_cast<const atom * const >(*iter); 126 ASSERT( _atom != NULL, 127 "Interfragmenter::operator() - a neighbor is not actually an atom?"); 128 if ((_atom->getMolecule() != _mol) 129 && (_atom->getPosition().DistanceSquared(center) < Rcut*Rcut) 130 && ((treatment == IncludeHydrogen) || (_atom->getType()->getAtomicNumber() != 1))) { 131 candidates.push_back(_atom); 132 } 133 } 134 LOG(3, "DEBUG: There remain " << candidates.size() << " candidates."); 222 // get neighboring atoms outside the current molecule 223 candidates_t candidates = getNeighborsOutsideMolecule(atoms, Rcut, treatment); 135 224 136 225 // create a lookup specific to this fragment 137 atomkeyset_t fragmentmap; 138 for (candidates_t::const_iterator candidateiter = candidates.begin(); 139 candidateiter != candidates.end(); ++candidateiter) { 140 const atom * _atom = *candidateiter; 141 atomkeyset_t::const_iterator iter = atomkeyset.find(_atom); 142 ASSERT( iter != atomkeyset.end(), 143 "Interfragmenter::operator() - could not find atom " 144 +toString(_atom->getId())+" in lookup."); 145 fragmentmap.insert( std::make_pair( _atom, iter->second) ); 146 } 147 LOG(4, "DEBUG: Copied part of lookup map contains " << fragmentmap.size() << " keys."); 226 atomkeyset_t fragmentmap = getCandidatesSpecificKeySetMap(candidates, atomkeyset); 148 227 149 228 /// combine each remaining fragment with current fragment to a new fragment 150 /// if keyset is less 151 for (candidates_t::const_iterator candidateiter = candidates.begin(); 152 candidateiter != candidates.end(); ++candidateiter) { 153 const atom *_atom = *candidateiter; 154 LOG(3, "DEBUG: Current candidate is " << *_atom << "."); 155 atomkeyset_t::iterator finditer = fragmentmap.find(_atom); 156 ASSERT( finditer != fragmentmap.end(), 157 "Interfragmenter::operator() - could not find atom " 158 +toString(_atom->getId())+" in fragment specific lookup."); 159 keysets_t &othersets = finditer->second; 160 keysets_t::iterator otheriter = othersets.begin(); 161 while (otheriter != othersets.end()) { 162 const KeySet &otherset = **otheriter; 163 LOG(3, "DEBUG: Current keyset is " << otherset << "."); 164 // only add them one way round and not the other 165 if (otherset < keyset) { 166 ++otheriter; 167 continue; 168 } 169 KeySet newset(otherset); 170 newset.insert(keyset.begin(), keyset.end()); 171 LOG(3, "DEBUG: Inserting new combined set " << newset << "."); 172 InterFragments.insert( std::make_pair(newset, std::make_pair(++counter, 1.))); 173 // finally, remove the set such that no other combination exists 174 otheriter = othersets.erase(otheriter); 175 } 176 } 229 /// if keyset is less (to prevent addding same inter-fragment twice) 230 combineFragments(MaxOrder, candidates, fragmentmap, keyset, InterFragments, counter); 177 231 } 178 232 … … 181 235 TotalGraph.InsertGraph(InterFragments, counter); 182 236 } 237 238 double Interfragmenter::findLargestCutoff( 239 const size_t _MaxOrder, 240 const double _upperbound, 241 const enum HydrogenTreatment _treatment) const 242 { 243 double Rcut = _upperbound*_upperbound; 244 std::pair<atomId_t, atomId_t> ClosestPair; 245 // place all atoms into LC grid with some upper bound 246 const LinkedCell::LinkedCell_View view = World::getInstance().getLinkedCell(_upperbound); 247 248 atomkeyset_t atomkeyset = getAtomKeySetMap(_MaxOrder); 249 250 // go through each atom and find closest atom not in the same keyset 251 for (Graph::const_iterator keysetiter = TotalGraph.begin(); 252 keysetiter != TotalGraph.end(); ++keysetiter) { 253 const KeySet &keyset = keysetiter->first; 254 LOG(2, "DEBUG: Current keyset is " << keyset); 255 const AtomIdSet atoms(keyset); 256 257 // get neighboring atoms outside the current molecule 258 const candidates_t candidates = getNeighborsOutsideMolecule(atoms, _upperbound, _treatment); 259 const Vector center = getAtomIdSetCenter(atoms); 260 261 for (candidates_t::const_iterator candidateiter = candidates.begin(); 262 candidateiter != candidates.end(); ++candidateiter) { 263 atom const * const Walker = *candidateiter; 264 // go through each atom in set and pick minimal distance 265 for (AtomIdSet::const_iterator setiter = atoms.begin(); setiter != atoms.end(); ++setiter) { 266 const double distanceSquared = Walker->getPosition().DistanceSquared(center); 267 // pick the smallest compared to current Rcut if smaller 268 if (distanceSquared < Rcut) { 269 Rcut = distanceSquared; 270 ClosestPair.first = (*setiter)->getId(); 271 ClosestPair.second = Walker->getId(); 272 LOG(2, "DEBUG: Found new pair " << ClosestPair << " with distance " << sqrt(Rcut)); 273 } 274 } 275 } 276 } 277 const double largest_distance = sqrt(Rcut); 278 LOG(1, "INFO: Largest inter-fragment distance to cause no additional fragments: " 279 << largest_distance); 280 281 return largest_distance; 282 } -
src/Fragmentation/Interfragmenter.hpp
rd1831e r3690e4 14 14 #endif 15 15 16 #include <list> 17 #include <map> 16 18 #include <vector> 17 19 20 #include "AtomIdSet.hpp" 18 21 #include "Fragmentation/HydrogenSaturation_enum.hpp" 19 22 … … 50 53 */ 51 54 void operator()( 52 size_t MaxOrder,53 double Rcut,55 const size_t MaxOrder, 56 const double Rcut, 54 57 const enum HydrogenTreatment treatment); 58 59 /** This finds the largest cut off distance (\a Rcut) such that when running 60 * operator() no additional inter-fragments would be produced. 61 * 62 * \param MaxOrder maximum order for fragments to interrelate 63 * \param _upperbound upper bound on \a Rcut above which we do not look 64 * \param treatment whether hydrogens are treated specially or not 65 * \return largest cutoff distance to cause no additional inter-fragments 66 */ 67 double findLargestCutoff( 68 const size_t _MaxOrder, 69 const double _upperbound, 70 const enum HydrogenTreatment _treatment) const; 55 71 56 72 private: … … 62 78 std::vector<atom *> getAtomsFromKeySet(const KeySet &keyset) const; 63 79 80 typedef std::list<const KeySet *> keysets_t; 81 typedef std::map<const atom *, keysets_t > atomkeyset_t; 82 83 /** Helper function to create a map of atoms and their fragments/keysets. 84 * 85 * \param _MaxOrder maximum order 86 * \return map with atoms as a keys and fragments as values 87 */ 88 atomkeyset_t getAtomKeySetMap(size_t _MaxOrder) const; 89 90 typedef std::vector<const atom *> candidates_t; 91 92 /** Helper function to get all atoms around a specific keyset not contained in 93 * the same molecule. 94 * 95 * \param _atoms all atoms of a fragment 96 * \param _Rcut desired distance cutoff 97 * \param _treatment whether hydrogens are treated special or not 98 */ 99 candidates_t getNeighborsOutsideMolecule( 100 const AtomIdSet &_atoms, 101 const double _Rcut, 102 const enum HydrogenTreatment _treatment) const; 103 104 /** Helper function to return a fragment/KeySet map specific to all candidates. 105 * 106 * \param _candidates all neighboring atoms around keyset 107 * \param _atomkeyset map with all atoms and the KeySets they are contained in 108 * \return specific fragment map 109 */ 110 atomkeyset_t getCandidatesSpecificKeySetMap( 111 const candidates_t &_candidates, 112 const atomkeyset_t &_atomkeyset) const; 113 114 /** For a given set of candidates atoms in \a _candidates and a \a _keyset 115 * we combine each fragment from either atom and place it into internal 116 * Graph. 117 * 118 * \param _MaxOrder maximum order 119 * \param _candidates all atoms neighboring the current out outside of its molecule 120 * \param _fragmentmap all keysets related to this atom 121 * \param _keyset current keyset (used as base for creating inter-fragments) 122 * \param _InterFragments container for all created inter-fragments 123 * \param _counter counts added fragments 124 */ 125 void combineFragments( 126 const size_t _MaxOrder, 127 const candidates_t &_candidates, 128 atomkeyset_t &_fragmentmap, 129 const KeySet &_keyset, 130 Graph &_InterFragments, 131 int &_counter); 64 132 65 133 private: -
src/Fragmentation/Makefile.am
rd1831e r3690e4 128 128 libMolecuilderFragmentation_KeysetsContainer_libincludedir = $(libdir)/MoleCuilder/include 129 129 nodist_libMolecuilderFragmentation_KeysetsContainer_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h 130 131 ## Install the generated pkg-config file (.pc) into the expected location for132 ## architecture-dependent package configuration information. Occasionally,133 ## pkg-config files are also used for architecture-independent data packages,134 ## in which case the correct install location would be $(datadir)/pkgconfig.135 #pkgconfigdir = $(libdir)/pkgconfig136 #pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc -
src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp
rd1831e r3690e4 65 65 const KeySetsContainer& _ForceKeySet) : 66 66 KeySet(_KeySet), 67 ForceKeySet(_ForceKeySet) 67 ForceKeySet(_ForceKeySet), 68 hasForces((!longrangeData.empty()) && (longrangeData.begin()->second.hasForces)) 68 69 { 69 70 initLookups(fragmentData, longrangeData); … … 126 127 Result_LongRange_fused, Result_perIndexSet_LongRange); 127 128 129 IndexedVectors::indices_t fullindices; 130 if (hasLongRangeForces()) { 131 // force has extra data converter (this is similar to MPQCData's forces 132 std::map<JobId_t, VMGDataForceMap_t> VMGData_Force_fused; 133 convertDatatoForceMap<VMGData, VMGDataForceMap_t, VMGDataFused>( 134 longrangeData, ForceKeySet, VMGData_Force_fused); 135 Result_ForceLongRange_fused.resize(MaxLevel); // we need the results of correct size already 136 AllLevelOrthogonalSummator<VMGDataForceMap_t> forceSummer( 137 subsetmap, 138 VMGData_Force_fused, 139 container->getContainer(), 140 VMGMatrixNrLookup, 141 Result_ForceLongRange_fused, 142 Result_perIndexSet_LongRange_Force); 143 boost::mpl::for_each<VMGDataForceVector_t>(boost::ref(forceSummer)); 144 // build full force index set 145 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin(); 146 std::set<IndexedVectors::index_t> sorted_indices; 147 for (;arrayiter != ForceKeySet.KeySets.end(); ++arrayiter) { 148 sorted_indices.insert(arrayiter->begin(), arrayiter->end()); 149 } 150 sorted_indices.erase(-1); 151 fullindices.insert(fullindices.begin(), sorted_indices.begin(), sorted_indices.end()); 152 } 153 154 // then sum up 155 OrthogonalSumUpPerLevel<VMGDataGridMap_t, VMGData, VMGDataGridVector_t>( 156 longrangeData, VMGMatrixNrLookup, container, subsetmap, 157 Result_GridLongRange_fused, Result_perIndexSet_LongRange_Grid); 158 128 159 Result_LongRangeIntegrated_fused.reserve(MaxLevel); 129 160 // NOTE: potential for level 1 is wrongly calculated within a molecule … … 146 177 // the full solution. 147 178 const SamplingGrid &short_range_correction = 148 boost::fusion::at_key<VMGDataFused::sampled_potential>(Result_ LongRange_fused[level-1]);179 boost::fusion::at_key<VMGDataFused::sampled_potential>(Result_GridLongRange_fused[level-1]); 149 180 double electron_short_range_energy = short_range_correction.integral(); 150 181 full_sample_solution -= short_range_correction; … … 202 233 + boost::fusion::at_key<VMGDataFused::nuclei_shortrange>(instance); 203 234 Result_LongRangeIntegrated_fused.push_back(instance); 235 236 if (hasLongRangeForces()) { 237 VMGDataLongRangeForceMap_t forceinstance; 238 IndexedVectors fullforces( fullindices, fullsolutionData[level-1].forces); 239 IndexedVectors longrangeforces = 240 boost::fusion::at_key<VMGDataFused::forces>(Result_ForceLongRange_fused[level-1]); 241 boost::fusion::at_key<VMGDataFused::forces_shortrange>(forceinstance) = 242 fullforces; 243 fullforces -= longrangeforces; 244 boost::fusion::at_key<VMGDataFused::forces_longrange>(forceinstance) = 245 fullforces; 246 Result_ForcesLongRangeIntegrated_fused.push_back(forceinstance); 247 } 204 248 } 205 249 // { … … 207 251 // SamplingGrid full_sample_solution = fullsolutionData.back().sampled_potential; 208 252 // const SamplingGrid &short_range_correction = 209 // boost::fusion::at_key<VMGDataFused::sampled_potential>(Result_ LongRange_fused.back()).getFullContribution();253 // boost::fusion::at_key<VMGDataFused::sampled_potential>(Result_GridLongRange_fused.back()).getFullContribution(); 210 254 // full_sample_solution -= short_range_correction; 211 255 // // multiply element-wise with charge distribution -
src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp
rd1831e r3690e4 87 87 } 88 88 89 const bool hasLongRangeForces() const 90 { return hasForces; } 91 89 92 private: 90 93 void initLookups( … … 100 103 IndexSetContainer::ptr container; 101 104 SubsetMap::ptr subsetmap; 105 //!> indicates whether the longrange results contain VMG forces data or not 106 bool hasForces; 102 107 103 108 public: 104 109 //!> results per level of summed up sampled grid charge 105 110 std::vector<MPQCDataGridMap_t> Result_Grid_fused; 106 //!> results per level of summed up long range potential grids and energy111 //!> results per level of summed up long range energies 107 112 std::vector<VMGDataMap_t> Result_LongRange_fused; 113 //!> results per level of summed up long range forces 114 std::vector<VMGDataForceMap_t> Result_ForceLongRange_fused; 115 //!> results per level of summed up long range potential grids 116 std::vector<VMGDataGridMap_t> Result_GridLongRange_fused; 108 117 //!> results per level of summed up long range true energy 109 118 std::vector<VMGDataLongRangeMap_t> Result_LongRangeIntegrated_fused; 119 //!> results per level of summed up long range true forces 120 std::vector<VMGDataLongRangeForceMap_t> Result_ForcesLongRangeIntegrated_fused; 110 121 111 122 //!> results per IndexSet of summed up sampled grid charge 112 123 std::map<IndexSet::ptr, std::pair<MPQCDataGridMap_t,MPQCDataGridMap_t> > Result_perIndexSet_Grid; 113 //!> results per IndexSet of summed up long range potential grids and energy124 //!> results per IndexSet of summed up long range energies 114 125 std::map<IndexSet::ptr, std::pair<VMGDataMap_t, VMGDataMap_t> > Result_perIndexSet_LongRange; 126 //!> results per IndexSet of summed up long range forces 127 std::map<IndexSet::ptr, std::pair<VMGDataForceMap_t, VMGDataForceMap_t> > Result_perIndexSet_LongRange_Force; 128 //!> results per IndexSet of summed up long range potential grids 129 std::map<IndexSet::ptr, std::pair<VMGDataGridMap_t, VMGDataGridMap_t> > Result_perIndexSet_LongRange_Grid; 115 130 // we don't need the map pendant for Result_LongRangeIntegrated_fused, as this 116 131 // quantity makes sense only level-wise -
src/Fragmentation/Summation/Containers/FragmentationShortRangeResults.cpp
rd1831e r3690e4 109 109 // force has extra data converter 110 110 std::map<JobId_t, MPQCDataForceMap_t> MPQCData_Force_fused; 111 convert MPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused);111 convertDatatoForceMap<MPQCData, MPQCDataForceMap_t, MPQCDataFused>(fragmentData, ForceKeySet, MPQCData_Force_fused); 112 112 Result_Force_fused.resize(MaxLevel); // we need the results of correct size already 113 113 AllLevelOrthogonalSummator<MPQCDataForceMap_t> forceSummer( -
src/Fragmentation/Summation/Containers/MPQCData.hpp
rd1831e r3690e4 22 22 23 23 #include "Fragmentation/Summation/SetValues/SamplingGrid.hpp" 24 #include "Fragmentation/Summation/SetValues/FragmentForces.hpp" 24 25 25 26 class MPQCCommandJob; … … 77 78 78 79 /// Forces 79 typedef std::vector<double> vector_type; 80 std::vector< vector_type > forces; 80 FragmentForces forces; 81 81 82 82 //!> whether to actually sample the density … … 131 131 ar & energies.hcore; 132 132 ar & energies.eigenvalues; 133 ar & forces; 133 if (version < 2) { 134 FragmentForces::forces_t justforces(forces); 135 ar & justforces; 136 dynamic_cast<FragmentForces::forces_t &>(forces) = justforces; 137 } else 138 ar & forces; 134 139 ar & sampled_grid; 135 140 ar & DoLongrange; … … 147 152 }; 148 153 149 BOOST_CLASS_VERSION(MPQCData, 1)154 BOOST_CLASS_VERSION(MPQCData, 2) 150 155 151 156 std::ostream & operator<<(std::ostream &ost, const MPQCData &data); -
src/Fragmentation/Summation/Containers/MPQCDataFused.hpp
rd1831e r3690e4 22 22 * instance when going throughb the list with boost::mpl::for_each. 23 23 */ 24 namespaceMPQCDataFused {24 struct MPQCDataFused { 25 25 // keys for energy_t 26 26 struct energy_total {}; … … 51 51 struct times_gather_cputime {}; 52 52 struct times_gather_flops {}; 53 } 53 }; 54 54 55 55 -
src/Fragmentation/Summation/Containers/VMGData.cpp
rd1831e r3690e4 44 44 sampled_potential(_props), 45 45 nuclei_long(0.), 46 electron_long(0.) 46 electron_long(0.), 47 hasForces(false) 47 48 {} 48 49 … … 54 55 ost << "Nuclei long-Range energy: " << data.nuclei_long << std::endl; 55 56 ost << "Electron long-Range energy: " << data.electron_long << std::endl; 57 ost << "Nuclei long-Range forces: " << data.forces << std::endl; 56 58 return ost; 57 59 } -
src/Fragmentation/Summation/Containers/VMGData.hpp
rd1831e r3690e4 22 22 #include <vector> 23 23 24 #include "Fragmentation/Summation/SetValues/FragmentForces.hpp" 24 25 #include "Fragmentation/Summation/SetValues/SamplingGrid.hpp" 25 26 … … 48 49 //!> electron long-range contribution to energy 49 50 double electron_long; 51 //!> force vectors of all nuclei 52 FragmentForces forces; 53 54 //!> internal value to check when we should sum forces and when not 55 bool hasForces; 50 56 51 57 private: … … 61 67 ar & nuclei_long; 62 68 ar & electron_long; 69 if (version > 2) { 70 ar & forces; 71 hasForces = true; 72 } else 73 hasForces = false; 63 74 } 64 75 }; 65 76 66 BOOST_CLASS_VERSION(VMGData, 2)77 BOOST_CLASS_VERSION(VMGData, 3) 67 78 68 79 std::ostream & operator<<(std::ostream &ost, const VMGData &data); -
src/Fragmentation/Summation/Containers/VMGDataFused.hpp
rd1831e r3690e4 23 23 * instance when going throughb the list with boost::mpl::for_each. 24 24 */ 25 namespaceVMGDataFused {25 struct VMGDataFused { 26 26 // keys for sampled_potential 27 27 struct sampled_potential {}; … … 29 29 struct nuclei_long {}; 30 30 struct electron_long {}; 31 // keys for forces 32 struct forces {}; 31 33 32 34 // keys for longrange 33 34 35 struct electron_longrange {}; 35 36 struct electron_shortrange {}; … … 40 41 struct total_longrange {}; 41 42 struct total_shortrange {}; 42 } 43 44 struct forces_longrange {}; 45 struct forces_shortrange {}; 46 }; 43 47 44 48 -
src/Fragmentation/Summation/Containers/VMGDataMap.hpp
rd1831e r3690e4 18 18 #include <boost/mpl/list.hpp> 19 19 20 #include <vector> 21 20 22 #include "Fragmentation/Summation/Containers/VMGDataFused.hpp" 21 23 22 24 class SamplingGrid; 25 class IndexedVectors; 23 26 24 27 /** This boost::fusion map defines key-value or rather key-type pairs with … … 30 33 */ 31 34 typedef boost::fusion::map< 32 boost::fusion::pair<VMGDataFused::sampled_potential, SamplingGrid >,33 boost::fusion::pair<VMGDataFused::both_sampled_potential, SamplingGrid >,34 35 boost::fusion::pair<VMGDataFused::nuclei_long, double >, 35 36 boost::fusion::pair<VMGDataFused::electron_long, double > … … 37 38 38 39 typedef boost::mpl::list< 39 VMGDataFused::sampled_potential,40 VMGDataFused::both_sampled_potential,41 40 VMGDataFused::nuclei_long, 42 41 VMGDataFused::electron_long 43 42 > VMGDataVector_t; 43 44 /** This boost::fusion map defines key-value or rather key-type pairs with 45 * which we associate all forces data members in VMGData and their type. 46 * 47 * This lets us resolves any ambiguitites of types in VMGData, e.g. 48 * to know vector<double> is forces or energy_eigenvalues. 49 * 50 */ 51 typedef boost::fusion::map< 52 boost::fusion::pair<VMGDataFused::forces, IndexedVectors > 53 > VMGDataForceMap_t; 54 55 typedef boost::mpl::list< 56 VMGDataFused::forces 57 > VMGDataForceVector_t; 58 59 typedef boost::fusion::map< 60 boost::fusion::pair<VMGDataFused::sampled_potential, SamplingGrid >, 61 boost::fusion::pair<VMGDataFused::both_sampled_potential, SamplingGrid > 62 > VMGDataGridMap_t; 63 64 typedef boost::mpl::list< 65 VMGDataFused::sampled_potential, 66 VMGDataFused::both_sampled_potential 67 > VMGDataGridVector_t; 44 68 45 69 /** This boost::fusion map defines key-value or rather key-type pairs with … … 72 96 > VMGDataLongRangeVector_t; 73 97 98 typedef boost::fusion::map< 99 boost::fusion::pair<VMGDataFused::forces_longrange, IndexedVectors >, 100 boost::fusion::pair<VMGDataFused::forces_shortrange, IndexedVectors > 101 > VMGDataLongRangeForceMap_t; 102 103 typedef boost::mpl::list< 104 VMGDataFused::forces_longrange, 105 VMGDataFused::forces_shortrange 106 > VMGDataLongRangeForceVector_t; 107 74 108 75 109 #endif /* VMGDATAMAP_HPP_ */ -
src/Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp
rd1831e r3690e4 38 38 (nuclei_long) \ 39 39 (electron_long) \ 40 (forces) \ 40 41 (electron_longrange) \ 41 42 (electron_shortrange) \ … … 45 46 (nuclei_shortrange) \ 46 47 (total_longrange) \ 47 (total_shortrange) 48 (total_shortrange) \ 49 (forces_longrange) \ 50 (forces_shortrange) 48 51 49 52 /// we take note of the number of keys in tokensequence as (local) loop bounds below -
src/Fragmentation/Summation/Converter/DataConverter.hpp
rd1831e r3690e4 88 88 LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); 89 89 VMGDataMap_t instance; 90 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;91 boost::fusion::at_key<VMGDataFused::both_sampled_potential>(instance) = extractedData.both_sampled_potential;92 90 boost::fusion::at_key<VMGDataFused::nuclei_long>(instance) = extractedData.nuclei_long; 93 91 boost::fusion::at_key<VMGDataFused::electron_long>(instance) = extractedData.electron_long; … … 95 93 } 96 94 } 97 #endif 98 99 inline void convertMPQCDatatoForceMap( 100 const std::map<JobId_t, MPQCData> &fragmentData, 95 96 template <> 97 inline void convertDataTo<VMGData, VMGDataGridMap_t>( 98 const std::map<JobId_t, VMGData> &longrangeData, 99 std::map<JobId_t, VMGDataGridMap_t> &VMGData_fused) 100 { 101 // energy_t 102 VMGData_fused.clear(); 103 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin(); 104 dataiter != longrangeData.end(); ++dataiter) { 105 const VMGData &extractedData = dataiter->second; 106 LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); 107 VMGDataGridMap_t instance; 108 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential; 109 boost::fusion::at_key<VMGDataFused::both_sampled_potential>(instance) = extractedData.both_sampled_potential; 110 VMGData_fused.insert( std::make_pair(dataiter->first, instance) ); 111 } 112 } 113 #endif 114 115 template <class datatype, class dataforcemap, class dataforcefused> 116 inline void convertDatatoForceMap( 117 const std::map<JobId_t, datatype> &fragmentData, 101 118 const KeySetsContainer &ForceKeySet, 102 std::map<JobId_t, MPQCDataForceMap_t> &MPQCData_Force_fused)119 std::map<JobId_t, dataforcemap> &Data_Force_fused) 103 120 { 104 121 // forces 105 122 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(), 106 123 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size."); 107 MPQCData_Force_fused.clear();108 std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();124 Data_Force_fused.clear(); 125 typename std::map<JobId_t, datatype>::const_iterator dataiter = fragmentData.begin(); 109 126 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin(); 110 127 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) { 111 const MPQCData&extractedData = dataiter->second;112 LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); 113 MPQCDataForceMap_tinstance;128 const datatype &extractedData = dataiter->second; 129 LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); 130 dataforcemap instance; 114 131 // must convert int to index_t 115 132 if (DoLog(5)) { … … 122 139 } 123 140 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end()); 124 boost::fusion::at_key< MPQCDataFused::forces>(instance) =141 boost::fusion::at_key<typename dataforcefused::forces>(instance) = 125 142 IndexedVectors(indices, extractedData.forces); 126 MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) );143 Data_Force_fused.insert( std::make_pair(dataiter->first, instance) ); 127 144 } 128 145 } -
src/Fragmentation/Summation/Makefile.am
rd1831e r3690e4 77 77 libMolecuilderFragmentationSummation_libincludedir = $(libdir)/MoleCuilder/include 78 78 nodist_libMolecuilderFragmentationSummation_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h 79 80 ## Install the generated pkg-config file (.pc) into the expected location for81 ## architecture-dependent package configuration information. Occasionally,82 ## pkg-config files are also used for architecture-independent data packages,83 ## in which case the correct install location would be $(datadir)/pkgconfig.84 #pkgconfigdir = $(libdir)/pkgconfig85 #pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc -
src/Fragmentation/Summation/SetValues/Makefile.am
rd1831e r3690e4 5 5 Fragmentation/Summation/SetValues/Eigenvalues.cpp \ 6 6 Fragmentation/Summation/SetValues/Fragment.cpp \ 7 Fragmentation/Summation/SetValues/FragmentForces.cpp \ 7 8 Fragmentation/Summation/SetValues/Histogram.cpp \ 8 9 Fragmentation/Summation/SetValues/IndexedVectors.cpp \ … … 13 14 Fragmentation/Summation/SetValues/Eigenvalues.hpp \ 14 15 Fragmentation/Summation/SetValues/Fragment.hpp \ 16 Fragmentation/Summation/SetValues/FragmentForces.hpp \ 15 17 Fragmentation/Summation/SetValues/Histogram.hpp \ 16 18 Fragmentation/Summation/SetValues/IndexedVectors.hpp \
Note:
See TracChangeset
for help on using the changeset viewer.