Changeset 407536
- Timestamp:
- Oct 12, 2009, 1:26:12 PM (16 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:
- 93d120
- Parents:
- 14e73a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_fragmentation.cpp
r14e73a r407536 1156 1156 }; 1157 1157 1158 /** Initializes FragmenSearch. 1158 /** Allocates memory for UniqueFragments::BondsPerSPList. 1159 * \param *out output stream 1160 * \param Order bond order (limits BFS exploration and "number of digits" in power set generation 1161 * \param FragmentSearch UniqueFragments 1162 * \sa FreeSPList() 1163 */ 1164 void InitialiseSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch) 1165 { 1166 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList"); 1167 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount"); 1168 for (int i=Order;i--;) { 1169 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node 1170 FragmentSearch.BondsPerSPList[2*i+1] = new bond(); // end node 1171 FragmentSearch.BondsPerSPList[2*i]->next = FragmentSearch.BondsPerSPList[2*i+1]; // intertwine these two 1172 FragmentSearch.BondsPerSPList[2*i+1]->previous = FragmentSearch.BondsPerSPList[2*i]; 1173 FragmentSearch.BondsPerSPCount[i] = 0; 1174 } 1175 }; 1176 1177 /** Free's memory for for UniqueFragments::BondsPerSPList. 1178 * \param *out output stream 1179 * \param Order bond order (limits BFS exploration and "number of digits" in power set generation 1180 * \param FragmentSearch UniqueFragments\ 1181 * \sa InitialiseSPList() 1182 */ 1183 void FreeSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch) 1184 { 1185 Free(&FragmentSearch.BondsPerSPCount); 1186 for (int i=Order;i--;) { 1187 delete(FragmentSearch.BondsPerSPList[2*i]); 1188 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1189 } 1190 Free(&FragmentSearch.BondsPerSPList); 1191 }; 1192 1193 /** Sets FragmenSearch to initial value. 1159 1194 * Sets UniqueFragments::ShortestPathList entries to zero, UniqueFragments::BondsPerSPCount to zero (except zero level to 1) and 1160 1195 * adds initial bond UniqueFragments::Root to UniqueFragments::Root to UniqueFragments::BondsPerSPList … … 1164 1199 * \sa FreeSPList() 1165 1200 */ 1166 void InitialiseSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch)1201 void SetSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch) 1167 1202 { 1168 1203 // prepare Label and SP arrays of the BFS search … … 1183 1218 * \sa InitialiseSPList() 1184 1219 */ 1185 void FreeSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch)1220 void ResetSPList(ofstream *out, int Order, struct UniqueFragments &FragmentSearch) 1186 1221 { 1187 1222 bond *Binder = NULL; … … 1341 1376 *out << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl; 1342 1377 1343 InitialiseSPList(out, Order, FragmentSearch);1378 SetSPList(out, Order, FragmentSearch); 1344 1379 1345 1380 // do a BFS search to fill the SP lists and label the found vertices … … 1375 1410 1376 1411 // free'ing the bonds lists 1377 FreeSPList(out, Order, FragmentSearch);1412 ResetSPList(out, Order, FragmentSearch); 1378 1413 1379 1414 // return list … … 1408 1443 1409 1444 1445 /** Combines all KeySets from all orders into single ones (with just unique entries). 1446 * \param *out output stream for debugging 1447 * \param *&FragmentList list to fill 1448 * \param ***FragmentLowerOrdersList 1449 * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied) 1450 * \param *mol molecule with atoms and bonds 1451 */ 1452 int CombineAllOrderListIntoOne(ofstream *out, Graph *&FragmentList, Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol) 1453 { 1454 int RootNr = 0; 1455 int RootKeyNr = 0; 1456 int counter = 0; 1457 int NumLevels = 0; 1458 atom *Walker = NULL; 1459 1460 *out << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl; 1461 if (FragmentList == NULL) { 1462 FragmentList = new Graph; 1463 counter = 0; 1464 } else { 1465 counter = FragmentList->size(); 1466 } 1467 while (!RootStack.empty()) { 1468 RootKeyNr = RootStack.front(); 1469 RootStack.pop_front(); 1470 Walker = mol->FindAtom(RootKeyNr); 1471 NumLevels = 1 << (Walker->AdaptiveOrder - 1); 1472 for(int i=0;i<NumLevels;i++) { 1473 if (FragmentLowerOrdersList[RootNr][i] != NULL) { 1474 InsertGraphIntoGraph(out, *FragmentList, (*FragmentLowerOrdersList[RootNr][i]), &counter); 1475 } 1476 } 1477 RootStack.push_back(Walker->nr); 1478 RootNr++; 1479 } 1480 return counter; 1481 }; 1482 1483 /** Free's memory allocated for all KeySets from all orders. 1484 * \param *out output stream for debugging 1485 * \param ***FragmentLowerOrdersList 1486 * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied) 1487 * \param *mol molecule with atoms and bonds 1488 */ 1489 void FreeAllOrdersList(ofstream *out, Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol) 1490 { 1491 *out << Verbose(1) << "Free'ing the lists of all orders per order." << endl; 1492 int RootNr = 0; 1493 int RootKeyNr = 0; 1494 int NumLevels = 0; 1495 atom *Walker = NULL; 1496 while (!RootStack.empty()) { 1497 RootKeyNr = RootStack.front(); 1498 RootStack.pop_front(); 1499 Walker = mol->FindAtom(RootKeyNr); 1500 NumLevels = 1 << (Walker->AdaptiveOrder - 1); 1501 for(int i=0;i<NumLevels;i++) { 1502 if (FragmentLowerOrdersList[RootNr][i] != NULL) { 1503 delete(FragmentLowerOrdersList[RootNr][i]); 1504 } 1505 } 1506 Free(&FragmentLowerOrdersList[RootNr]); 1507 RootNr++; 1508 } 1509 Free(&FragmentLowerOrdersList); 1510 }; 1511 1512 1410 1513 /** Performs BOSSANOVA decomposition at selected sites, increasing the cutoff by one at these sites. 1411 1514 * -# constructs a complete keyset of the molecule … … 1428 1531 { 1429 1532 Graph ***FragmentLowerOrdersList = NULL; 1430 int NumLevels, NumMolecules, TotalNumMolecules = 0, *NumMoleculesOfOrder = NULL; 1431 int counter = 0, Order; 1533 int NumLevels = 0; 1534 int NumMolecules = 0; 1535 int TotalNumMolecules = 0; 1536 int *NumMoleculesOfOrder = NULL; 1537 int Order = 0; 1432 1538 int UpgradeCount = RootStack.size(); 1433 1539 KeyStack FragmentRootStack; 1434 int RootKeyNr, RootNr; 1540 int RootKeyNr = 0; 1541 int RootNr = 0; 1435 1542 struct UniqueFragments FragmentSearch; 1436 1543 … … 1478 1585 1479 1586 // initialise Order-dependent entries of UniqueFragments structure 1480 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList"); 1481 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount"); 1482 for (int i=Order;i--;) { 1483 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node 1484 FragmentSearch.BondsPerSPList[2*i+1] = new bond(); // end node 1485 FragmentSearch.BondsPerSPList[2*i]->next = FragmentSearch.BondsPerSPList[2*i+1]; // intertwine these two 1486 FragmentSearch.BondsPerSPList[2*i+1]->previous = FragmentSearch.BondsPerSPList[2*i]; 1487 FragmentSearch.BondsPerSPCount[i] = 0; 1488 } 1587 InitialiseSPList(out, Order, FragmentSearch); 1489 1588 1490 1589 // allocate memory for all lower level orders in this 1D-array of ptrs … … 1504 1603 FragmentSearch.Root = Walker; 1505 1604 NumMoleculesOfOrder[RootNr] = PowerSetGenerator(out, Walker->AdaptiveOrder, FragmentSearch, CompleteMolecule); 1605 1606 // output resulting number 1506 1607 *out << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl; 1507 1608 if (NumMoleculesOfOrder[RootNr] != 0) { 1508 1609 NumMolecules = 0; 1509 1510 // we don't have to dive into suborders! These keysets are all already created on lower orders!1511 // this was all ancient stuff, when we still depended on the TEFactors (and for those the suborders were needed)1512 1513 // if ((NumLevels >> 1) > 0) {1514 // // create lower order fragments1515 // *out << Verbose(0) << "Creating list of unique fragments of lower Bond Order terms to be subtracted." << endl;1516 // Order = Walker->AdaptiveOrder;1517 // for (int source=0;source<(NumLevels >> 1);source++) { // 1-terms don't need any more splitting, that's why only half is gone through (shift again)1518 // // step down to next order at (virtual) boundary of powers of 2 in array1519 // while (source >= (1 << (Walker->AdaptiveOrder-Order))) // (int)pow(2,Walker->AdaptiveOrder-Order))1520 // Order--;1521 // *out << Verbose(0) << "Current Order is: " << Order << "." << endl;1522 // for (int SubOrder=Order-1;SubOrder>0;SubOrder--) {1523 // int dest = source + (1 << (Walker->AdaptiveOrder-(SubOrder+1)));1524 // *out << Verbose(0) << "--------------------------------------------------------------------------------------------------------------" << endl;1525 // *out << Verbose(0) << "Current SubOrder is: " << SubOrder << " with source " << source << " to destination " << dest << "." << endl;1526 //1527 // // every molecule is split into a list of again (Order - 1) molecules, while counting all molecules1528 // //*out << Verbose(1) << "Splitting the " << (*FragmentLowerOrdersList[RootNr][source]).size() << " molecules of the " << source << "th cell in the array." << endl;1529 // //NumMolecules = 0;1530 // FragmentLowerOrdersList[RootNr][dest] = new Graph;1531 // for(Graph::iterator runner = (*FragmentLowerOrdersList[RootNr][source]).begin();runner != (*FragmentLowerOrdersList[RootNr][source]).end(); runner++) {1532 // for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {1533 // Graph TempFragmentList;1534 // FragmentSearch.TEFactor = -(*runner).second.second;1535 // FragmentSearch.Leaflet = &TempFragmentList; // set to insertion graph1536 // FragmentSearch.Root = FindAtom(*sprinter);1537 // NumMoleculesOfOrder[RootNr] += PowerSetGenerator(out, SubOrder, FragmentSearch, (*runner).first);1538 // // insert new keysets FragmentList into FragmentLowerOrdersList[Walker->AdaptiveOrder-1][dest]1539 // *out << Verbose(1) << "Merging resulting key sets with those present in destination " << dest << "." << endl;1540 // InsertGraphIntoGraph(out, *FragmentLowerOrdersList[RootNr][dest], TempFragmentList, &NumMolecules);1541 // }1542 // }1543 // *out << Verbose(1) << "Number of resulting molecules for SubOrder " << SubOrder << " is: " << NumMolecules << "." << endl;1544 // }1545 // }1546 // }1547 1610 } else { 1548 1611 Walker->GetTrueFather()->MaxOrder = true; 1549 // *out << Verbose(1) << "Hence, we don't dive into SubOrders ... " << endl;1550 1612 } 1551 1613 // now, we have completely filled each cell of FragmentLowerOrdersList[] for the current Walker->AdaptiveOrder … … 1557 1619 1558 1620 // free Order-dependent entries of UniqueFragments structure for next loop cycle 1559 Free(&FragmentSearch.BondsPerSPCount); 1560 for (int i=Order;i--;) { 1561 delete(FragmentSearch.BondsPerSPList[2*i]); 1562 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1563 } 1564 Free(&FragmentSearch.BondsPerSPList); 1621 FreeSPList(out, Order, FragmentSearch); 1565 1622 } 1566 1623 } … … 1581 1638 1582 1639 // Subsequently, we combine all into a single list (FragmentList) 1583 1584 *out << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl; 1585 if (FragmentList == NULL) { 1586 FragmentList = new Graph; 1587 counter = 0; 1588 } else { 1589 counter = FragmentList->size(); 1590 } 1591 RootNr = 0; 1592 while (!RootStack.empty()) { 1593 RootKeyNr = RootStack.front(); 1594 RootStack.pop_front(); 1595 Walker = FindAtom(RootKeyNr); 1596 NumLevels = 1 << (Walker->AdaptiveOrder - 1); 1597 for(int i=0;i<NumLevels;i++) { 1598 if (FragmentLowerOrdersList[RootNr][i] != NULL) { 1599 InsertGraphIntoGraph(out, *FragmentList, (*FragmentLowerOrdersList[RootNr][i]), &counter); 1600 delete(FragmentLowerOrdersList[RootNr][i]); 1601 } 1602 } 1603 Free(&FragmentLowerOrdersList[RootNr]); 1604 RootNr++; 1605 } 1606 Free(&FragmentLowerOrdersList); 1640 CombineAllOrderListIntoOne(out, FragmentList, FragmentLowerOrdersList, RootStack, this); 1641 FreeAllOrdersList(out, FragmentLowerOrdersList, RootStack, this); 1607 1642 Free(&NumMoleculesOfOrder); 1608 1643
Note:
See TracChangeset
for help on using the changeset viewer.