Changeset 7218f8 for src/molecule_fragmentation.cpp
- Timestamp:
- Nov 3, 2009, 12:37:55 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, Candidate_v1.7.0, 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:
- 2aeefd
- Parents:
- fa649a
- git-author:
- Frederik Heber <heber@…> (11/03/09 08:41:45)
- git-committer:
- Frederik Heber <heber@…> (11/03/09 12:37:55)
- File:
-
- 1 edited
-
src/molecule_fragmentation.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_fragmentation.cpp
rfa649a r7218f8 123 123 } 124 124 125 Free(&filename); 125 126 return status; 126 127 }; … … 574 575 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== 575 576 Subgraphs = DepthFirstSearchAnalysis(out, BackEdgeStack); 576 // fill the bond structure of the individually stored subgraphs 577 Subgraphs->next->FillBondStructureFromReference(out, this, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 577 578 578 // analysis of the cycles (print rings, get minimum cycle length) for each subgraph 579 579 for(int i=AtomCount;i--;) … … 583 583 while (MolecularWalker->next != NULL) { 584 584 MolecularWalker = MolecularWalker->next; 585 // fill the bond structure of the individually stored subgraphs 586 MolecularWalker->FillBondStructureFromReference(out, this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 585 587 *out << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 586 588 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); … … 599 601 delete(LocalBackEdgeStack); 600 602 } 603 delete(BackEdgeStack); 601 604 602 605 // ===== 3. if structure still valid, parse key set file and others ===== … … 663 666 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== 664 667 //if (FragmentationToDo) { // we should always store the fragments again as coordination might have changed slightly without changing bond structure 665 // allocate memory for the pointer array and transmorph graphs into full molecular fragments666 BondFragments = new MoleculeListClass();667 int k=0;668 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {669 KeySet test = (*runner).first;670 *out << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl;671 BondFragments->insert(StoreFragmentFromKeySet(out, test, configuration));672 k++;673 }674 *out << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl;675 676 // ===== 9. Save fragments' configuration and keyset files et al to disk ===677 if (BondFragments->ListOfMolecules.size() != 0) {678 // create the SortIndex from BFS labels to order in the config file679 CreateMappingLabelsToConfigSequence(out, SortIndex);680 681 *out << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl;682 if (BondFragments->OutputConfigForListOfFragments(out, configuration, SortIndex))683 *out << Verbose(1) << "All configs written." << endl;684 else685 *out << Verbose(1) << "Some config writing failed." << endl;686 687 // store force index reference file688 BondFragments->StoreForcesFile(out, configuration->configpath, SortIndex);689 690 // store keysets file691 StoreKeySetFile(out, TotalGraph, configuration->configpath);692 693 // store Adjacency file694 StoreAdjacencyToFile(out, configuration->configpath);695 696 // store Hydrogen saturation correction file697 BondFragments->AddHydrogenCorrection(out, configuration->configpath);698 699 // store adaptive orders into file700 StoreOrderAtSiteFile(out, configuration->configpath);701 702 // restore orbital and Stop values703 CalculateOrbitals(*configuration);704 705 // free memory for bond part706 *out << Verbose(1) << "Freeing bond memory" << endl;707 delete(FragmentList); // remove bond molecule from memory708 Free(&SortIndex);709 } else710 *out << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl;711 //} else712 // *out << Verbose(1) << "No fragments to store." << endl;668 // allocate memory for the pointer array and transmorph graphs into full molecular fragments 669 BondFragments = new MoleculeListClass(); 670 int k=0; 671 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) { 672 KeySet test = (*runner).first; 673 *out << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl; 674 BondFragments->insert(StoreFragmentFromKeySet(out, test, configuration)); 675 k++; 676 } 677 *out << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl; 678 679 // ===== 9. Save fragments' configuration and keyset files et al to disk === 680 if (BondFragments->ListOfMolecules.size() != 0) { 681 // create the SortIndex from BFS labels to order in the config file 682 CreateMappingLabelsToConfigSequence(out, SortIndex); 683 684 *out << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl; 685 if (BondFragments->OutputConfigForListOfFragments(out, configuration, SortIndex)) 686 *out << Verbose(1) << "All configs written." << endl; 687 else 688 *out << Verbose(1) << "Some config writing failed." << endl; 689 690 // store force index reference file 691 BondFragments->StoreForcesFile(out, configuration->configpath, SortIndex); 692 693 // store keysets file 694 StoreKeySetFile(out, TotalGraph, configuration->configpath); 695 696 // store Adjacency file 697 StoreAdjacencyToFile(out, configuration->configpath); 698 699 // store Hydrogen saturation correction file 700 BondFragments->AddHydrogenCorrection(out, configuration->configpath); 701 702 // store adaptive orders into file 703 StoreOrderAtSiteFile(out, configuration->configpath); 704 705 // restore orbital and Stop values 706 CalculateOrbitals(*configuration); 707 708 // free memory for bond part 709 *out << Verbose(1) << "Freeing bond memory" << endl; 710 delete(FragmentList); // remove bond molecule from memory 711 Free(&SortIndex); 712 } else { 713 *out << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl; 714 } 715 delete(BondFragments); 713 716 *out << Verbose(0) << "End of bond fragmentation." << endl; 714 717 … … 751 754 bool molecule::ParseOrderAtSiteFromFile(ofstream *out, char *path) 752 755 { 753 unsigned char *OrderArray = Malloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");754 bool *MaxArray = Malloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");756 unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray"); 757 bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray"); 755 758 bool status; 756 759 int AtomNr, value; … … 759 762 760 763 *out << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl; 761 for(int i=AtomCount;i--;)762 OrderArray[i] = 0;763 764 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 764 765 file.open(line.str().c_str()); 765 766 if (file != NULL) { 766 for (int i=AtomCount;i--;) { // initialise with 0767 OrderArray[i] = 0;768 MaxArray[i] = 0;769 }770 767 while (!file.eof()) { // parse from file 771 768 AtomNr = -1; … … 830 827 * \param *Leaf fragment molecule 831 828 * \param &Leaflet pointer to KeySet structure 832 * \param **SonList list which atom of \a *Leaf is a son of which atom in \a *mol829 * \param **SonList calloc'd list which atom of \a *Leaf is a son of which atom in \a *mol 833 830 * \return number of atoms in fragment 834 831 */ … … 840 837 for(int i=NDIM*2;i--;) 841 838 Leaf->cell_size[i] = mol->cell_size[i]; 842 843 // initialise SonList (indicates when we need to replace a bond with hydrogen instead)844 for(int i=mol->AtomCount;i--;)845 SonList[i] = NULL;846 839 847 840 // first create the minimal set of atoms from the KeySet … … 924 917 molecule * molecule::StoreFragmentFromKeySet(ofstream *out, KeySet &Leaflet, bool IsAngstroem) 925 918 { 926 atom **SonList = Malloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");919 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList"); 927 920 molecule *Leaf = new molecule(elemente); 928 921 … … 1389 1382 1390 1383 // prepare the subset and call the generator 1391 BondsList = Malloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");1384 BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList"); 1392 1385 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 1393 1386 … … 1544 1537 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 1545 1538 // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5) 1546 NumMoleculesOfOrder = Malloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder");1547 FragmentLowerOrdersList = Malloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList");1539 NumMoleculesOfOrder = Calloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder"); 1540 FragmentLowerOrdersList = Calloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList"); 1548 1541 1549 1542 // initialise the fragments structure 1550 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");1551 1543 FragmentSearch.FragmentCounter = 0; 1552 1544 FragmentSearch.FragmentSet = new KeySet; 1553 1545 FragmentSearch.Root = FindAtom(RootKeyNr); 1546 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList"); 1554 1547 for (int i=AtomCount;i--;) { 1555 1548 FragmentSearch.ShortestPathList[i] = -1; … … 1587 1580 // allocate memory for all lower level orders in this 1D-array of ptrs 1588 1581 NumLevels = 1 << (Order-1); // (int)pow(2,Order); 1589 FragmentLowerOrdersList[RootNr] = Malloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 1590 for (int i=0;i<NumLevels;i++) 1591 FragmentLowerOrdersList[RootNr][i] = NULL; 1582 FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 1592 1583 1593 1584 // create top order where nothing is reduced … … 1665 1656 *out << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl; 1666 1657 1667 ColorList = Malloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");1658 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); 1668 1659 while (flag) { 1669 1660 // remove bonds that are beyond bonddistance
Note:
See TracChangeset
for help on using the changeset viewer.
