Changeset fa9d1d for src/Actions/GraphAction/CreateAdjacencyAction.cpp
- Timestamp:
- Oct 20, 2011, 9:29:24 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:
- 360c8b
- Parents:
- 539f32
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/GraphAction/CreateAdjacencyAction.cpp
r539f32 rfa9d1d 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "Descriptors/AtomIdDescriptor.hpp" 23 #include "Descriptors/MoleculeDescriptor.hpp" 22 #include "CodePatterns/Log.hpp" 24 23 25 #include "atom.hpp" 26 #include "Bond/bond.hpp" 27 #include "CodePatterns/Log.hpp" 28 #include "CodePatterns/Range.hpp" 29 #include "CodePatterns/Verbose.hpp" 30 #include "config.hpp" 24 #include "Descriptors/AtomSelectionDescriptor.hpp" 31 25 #include "Graph/BondGraph.hpp" 32 #include "linkedcell.hpp"33 26 #include "molecule.hpp" 34 #include "PointCloudAdaptor.hpp"35 27 #include "World.hpp" 36 #include "WorldTime.hpp"37 28 38 29 #include <iostream> 39 30 #include <list> 40 31 #include <string> 41 42 typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;43 32 44 33 #include "Actions/GraphAction/CreateAdjacencyAction.hpp" … … 54 43 getParametersfromValueStorage(); 55 44 56 DoLog(1) && (Log() << Verbose(1) << "Constructing bond graph for selected atoms ... " << endl);57 58 45 BondGraph *BG = World::getInstance().getBondGraph(); 59 46 ASSERT(BG != NULL, "GraphCreateAdjacencyAction: BondGraph is NULL."); 60 double BondDistance = BG->getMaxPossibleBondDistance(AtomSetMixin<std::vector<atom *> >(World::getInstance().getSelectedAtoms()));61 47 62 atom *Walker = NULL; 63 atom *OtherWalker = NULL; 64 int n[NDIM]; 65 LinkedCell *LC = NULL; 66 Box &domain = World::getInstance().getDomain(); 48 World::AtomComposite Set = World::getInstance().getAllAtoms(AtomsBySelection()); 49 BG->CreateAdjacency(Set); 67 50 68 // remove every bond from the selected atoms' list 69 int AtomCount = 0; 70 for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); 71 AtomRunner != World::getInstance().endAtomSelection(); 72 ++AtomRunner) { 73 AtomCount++; 74 (AtomRunner->second)->removeAllBonds(); 75 // BondList& ListOfBonds = (AtomRunner->second)->getListOfBonds(); 76 // for(BondList::iterator BondRunner = ListOfBonds.begin(); 77 // !ListOfBonds.empty(); 78 // BondRunner = ListOfBonds.begin()) 79 // if ((*BondRunner)->leftatom == AtomRunner->second) 80 // delete((*BondRunner)); 81 } 82 int BondCount = 0; 83 84 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 85 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << BondDistance << "." << endl); 86 87 if ((AtomCount > 1) && (BondDistance > 1.)) { 88 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 89 TesselPointSTLList list; 90 for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); 91 AtomRunner != World::getInstance().endAtomSelection(); 92 ++AtomRunner) { 93 list.push_back(AtomRunner->second); 94 } 95 PointCloudAdaptor< TesselPointSTLList > cloud(&list, "AtomSelection"); 96 LC = new LinkedCell(cloud, BondDistance); 97 98 // create a list to map Tesselpoint::Nr to atom * 99 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 100 101 // set numbers for atoms that can later be used 102 std::map<TesselPoint *, int> AtomIds; 103 int i=0; 104 for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); 105 AtomRunner != World::getInstance().endAtomSelection(); 106 ++AtomRunner) { 107 AtomIds.insert(pair<TesselPoint *, int> (AtomRunner->second, i++) ); 108 } 109 110 // 3a. go through every cell 111 DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl); 112 for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++) 113 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) 114 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 115 const TesselPointSTLList *List = LC->GetCurrentCell(); 116 // Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 117 if (List != NULL) { 118 for (TesselPointSTLList::const_iterator Runner = List->begin(); 119 Runner != List->end(); 120 Runner++) { 121 Walker = dynamic_cast<atom*>(*Runner); 122 ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode"); 123 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 124 // 3c. check for possible bond between each atom in this and every one in the 27 cells 125 for (n[0] = -1; n[0] <= 1; n[0]++) 126 for (n[1] = -1; n[1] <= 1; n[1]++) 127 for (n[2] = -1; n[2] <= 1; n[2]++) { 128 const TesselPointSTLList *OtherList = LC->GetRelativeToCurrentCell(n); 129 // Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 130 if (OtherList != NULL) { 131 for (TesselPointSTLList::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 132 if (AtomIds.find(*OtherRunner)->second > AtomIds.find(Walker)->second) { 133 OtherWalker = dynamic_cast<atom*>(*OtherRunner); 134 ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode"); 135 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 136 const range<double> MinMaxDistanceSquared( 137 BG->getMinMaxDistanceSquared(Walker, OtherWalker)); 138 const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition()); 139 const bool status = MinMaxDistanceSquared.isInRange(distance); 140 // LOG3, "INFO: MinMaxDistanceSquared interval is " << MinMaxDistanceSquared << "."); 141 if (AtomIds[OtherWalker->father] > AtomIds[Walker->father]) { 142 if (status) { // create bond if distance is smaller 143 // Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 144 //const bond * Binder = 145 Walker->father->addBond(WorldTime::getTime(), OtherWalker->father); 146 BondCount++; 147 } else { 148 // Log() << Verbose(1) << "Not Adding: distance too great." << endl; 149 } 150 } else { 151 // Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl; 152 } 153 } 154 } 155 } 156 } 157 } 158 } 159 } 160 delete (LC); 161 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); 162 163 // correct bond degree by comparing valence and bond degree 164 DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl); 165 //CorrectBondDegree(); 166 167 } else 168 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl); 169 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 51 size_t BondCount = 0; 52 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 53 for (std::vector<molecule *>::const_iterator iter = molecules.begin(); 54 iter != molecules.end(); ++iter) 55 BondCount += (*iter)->getBondCount(); 56 LOG(0, "STATUS: Recognized " << BondCount << " bonds."); 170 57 171 58 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.