- Timestamp:
- Mar 2, 2011, 9:53:07 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:
- 766ba5
- Parents:
- 99752a
- git-author:
- Frederik Heber <heber@…> (02/25/11 15:44:44)
- git-committer:
- Frederik Heber <heber@…> (03/02/11 21:53:07)
- Location:
- src
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r99752a r53d6b2 8 8 LinearAlgebra \ 9 9 Shapes \ 10 Graph \ 10 11 Actions \ 11 12 UIElements … … 319 320 UIElements/libMolecuilderUI.la \ 320 321 Actions/libMolecuilderActions.la \ 322 Graph/libMolecuilderGraph.la \ 321 323 libMolecuilder.la \ 322 324 Parser/libMolecuilderParser.la \ … … 340 342 UIElements/libMolecuilderQtUI.la \ 341 343 Actions/libMolecuilderActions.la \ 344 Graph/libMolecuilderGraph.la \ 342 345 libMolecuilder.la \ 343 346 Parser/libMolecuilderParser.la \ … … 354 357 UIElements/libMolecuilderUI.la \ 355 358 Actions/libMolecuilderActions.la \ 359 Graph/libMolecuilderGraph.la \ 356 360 libMolecuilder.la \ 357 361 Parser/libMolecuilderParser.la \ … … 367 371 UIElements/libMolecuilderUI.la \ 368 372 Actions/libMolecuilderActions.la \ 373 Graph/libMolecuilderGraph.la \ 369 374 libMolecuilder.la \ 370 375 Parser/libMolecuilderParser.la \ -
src/molecule.hpp
r99752a r53d6b2 214 214 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 215 215 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 216 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);217 216 218 217 /// -# BOSSANOVA -
src/molecule_graph.cpp
r99752a r53d6b2 1138 1138 ; 1139 1139 1140 void BreadthFirstSearchAdd_Init(struct BFSAccounting &BFS, atom *&Root, int AtomCount, int BondOrder, atom **AddedAtomList = NULL)1141 {1142 BFS.AtomCount = AtomCount;1143 BFS.BondOrder = BondOrder;1144 BFS.PredecessorList = new atom*[AtomCount];1145 BFS.ShortestPathList = new int[AtomCount];1146 BFS.ColorList = new enum bond::Shading[AtomCount];1147 BFS.BFSStack = new std::deque<atom *> (AtomCount);1148 1149 BFS.Root = Root;1150 BFS.BFSStack->clear();1151 BFS.BFSStack->push_front(Root);1152 1153 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray1154 for (int i = AtomCount; i--;) {1155 BFS.PredecessorList[i] = NULL;1156 BFS.ShortestPathList[i] = -1;1157 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited1158 BFS.ColorList[i] = bond::lightgray;1159 else1160 BFS.ColorList[i] = bond::white;1161 }1162 //BFS.ShortestPathList[Root->getNr()] = 0; // done by Calloc1163 }1164 ;1165 1166 void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS)1167 {1168 delete[](BFS.PredecessorList);1169 delete[](BFS.ShortestPathList);1170 delete[](BFS.ColorList);1171 delete (BFS.BFSStack);1172 BFS.AtomCount = 0;1173 }1174 ;1175 1176 void BreadthFirstSearchAdd_UnvisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)1177 {1178 if (Binder != Bond) // let other atom white if it's via Root bond. In case it's cyclic it has to be reached again (yet Root is from OtherAtom already black, thus no problem)1179 BFS.ColorList[OtherAtom->getNr()] = bond::lightgray;1180 BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor1181 BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1;1182 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->getNr()] == bond::white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl);1183 if ((((BFS.ShortestPathList[OtherAtom->getNr()] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance1184 DoLog(3) && (Log() << Verbose(3));1185 if (AddedAtomList[OtherAtom->getNr()] == NULL) { // add if it's not been so far1186 AddedAtomList[OtherAtom->getNr()] = Mol->AddCopyAtom(OtherAtom);1187 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->getName());1188 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->getNr()], AddedAtomList[OtherAtom->getNr()], Binder);1189 DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");1190 } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place)1191 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->getName());1192 if (AddedBondList[Binder->nr] == NULL) {1193 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->getNr()], AddedAtomList[OtherAtom->getNr()], Binder);1194 DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]));1195 } else1196 DoLog(0) && (Log() << Verbose(0) << ", not added Bond ");1197 }1198 DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl);1199 BFS.BFSStack->push_front(OtherAtom);1200 } else { // out of bond order, then replace1201 if ((AddedAtomList[OtherAtom->getNr()] == NULL) && (Binder->Cyclic))1202 BFS.ColorList[OtherAtom->getNr()] = bond::white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)1203 if (Binder == Bond)1204 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");1205 else if (BFS.ShortestPathList[OtherAtom->getNr()] >= BFS.BondOrder)1206 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder);1207 if (!Binder->Cyclic)1208 DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl);1209 if (AddedBondList[Binder->nr] == NULL) {1210 if ((AddedAtomList[OtherAtom->getNr()] != NULL)) { // .. whether we add or saturate1211 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->getNr()], AddedAtomList[OtherAtom->getNr()], Binder);1212 } else {1213 #ifdef ADDHYDROGEN1214 if (!Mol->AddHydrogenReplacementAtom(Binder, AddedAtomList[Walker->getNr()], Walker, OtherAtom, IsAngstroem))1215 exit(1);1216 #endif1217 }1218 }1219 }1220 }1221 ;1222 1223 void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)1224 {1225 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);1226 // This has to be a cyclic bond, check whether it's present ...1227 if (AddedBondList[Binder->nr] == NULL) {1228 if ((Binder != Bond) && (Binder->Cyclic) && (((BFS.ShortestPathList[Walker->getNr()] + 1) < BFS.BondOrder))) {1229 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->getNr()], AddedAtomList[OtherAtom->getNr()], Binder);1230 } else { // if it's root bond it has to broken (otherwise we would not create the fragments)1231 #ifdef ADDHYDROGEN1232 if(!Mol->AddHydrogenReplacementAtom(Binder, AddedAtomList[Walker->getNr()], Walker, OtherAtom, IsAngstroem))1233 exit(1);1234 #endif1235 }1236 }1237 }1238 ;1239 1240 /** Adds atoms up to \a BondCount distance from \a *Root and notes them down in \a **AddedAtomList.1241 * Gray vertices are always enqueued in an std::deque<atom *> FIFO queue, the rest is usual BFS with adding vertices found was1242 * white and putting into queue.1243 * \param *Mol Molecule class to add atoms to1244 * \param **AddedAtomList list with added atom pointers, index is atom father's number1245 * \param **AddedBondList list with added bond pointers, index is bond father's number1246 * \param *Root root vertex for BFS1247 * \param *Bond bond not to look beyond1248 * \param BondOrder maximum distance for vertices to add1249 * \param IsAngstroem lengths are in angstroem or bohrradii1250 */1251 void molecule::BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem)1252 {1253 struct BFSAccounting BFS;1254 atom *Walker = NULL, *OtherAtom = NULL;1255 bond *Binder = NULL;1256 1257 // add Root if not done yet1258 if (AddedAtomList[Root->getNr()] == NULL) // add Root if not yet present1259 AddedAtomList[Root->getNr()] = Mol->AddCopyAtom(Root);1260 1261 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);1262 1263 // and go on ... Queue always contains all lightgray vertices1264 while (!BFS.BFSStack->empty()) {1265 // we have to pop the oldest atom from stack. This keeps the atoms on the stack always of the same ShortestPath distance.1266 // e.g. if current atom is 2, push to end of stack are of length 3, but first all of length 2 would be popped. They again1267 // append length of 3 (their neighbours). Thus on stack we have always atoms of a certain length n at bottom of stack and1268 // followed by n+1 till top of stack.1269 Walker = BFS.BFSStack->front(); // pop oldest added1270 BFS.BFSStack->pop_front();1271 const BondList& ListOfBonds = Walker->getListOfBonds();1272 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << ListOfBonds.size() << " bonds." << endl);1273 for (BondList::const_iterator Runner = ListOfBonds.begin();1274 Runner != ListOfBonds.end();1275 ++Runner) {1276 if ((*Runner) != NULL) { // don't look at bond equal NULL1277 Binder = (*Runner);1278 OtherAtom = (*Runner)->GetOtherAtom(Walker);1279 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);1280 if (BFS.ColorList[OtherAtom->getNr()] == bond::white) {1281 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);1282 } else {1283 BreadthFirstSearchAdd_VisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);1284 }1285 }1286 }1287 BFS.ColorList[Walker->getNr()] = bond::black;1288 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);1289 }1290 BreadthFirstSearchAdd_Free(BFS);1291 }1292 ;1293 1294 1140 /** Adds a bond as a copy to a given one 1295 1141 * \param *left leftatom of new bond
Note:
See TracChangeset
for help on using the changeset viewer.