- Timestamp:
- May 8, 2008, 12:04:42 PM (17 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:
- 386aa2
- Parents:
- c82f3d
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
rc82f3d r9fcf47 2111 2111 }; 2112 2112 2113 /** Checks whether the OrderAtSite is still bewloe \a Order at some site. 2114 * \param *out output stream for debugging 2115 * \param &FragmentationToDo return boolean 2116 * \param Order desired Order 2117 */ 2118 void molecule::CheckOrderAtSite(ofstream *out, bool &FragmentationToDo, int Order) 2119 { 2120 atom *Walker = NULL; 2121 2122 if (FragmentationToDo) { // check whether OrderAtSite is above Order everywhere 2123 FragmentationToDo = false; 2124 Walker = start; 2125 while (Walker->next != end) { 2126 Walker = Walker->next; 2127 #ifdef ADDHYDROGEN 2128 if (Walker->type->Z != 1) // skip hydrogen 2129 #endif 2130 if (Walker->AdaptiveOrder < Order) 2131 FragmentationToDo = true; 2132 } 2133 } else 2134 *out << Verbose(1) << "Parsing order at site file failed" << endl; 2135 2136 if (!FragmentationToDo) 2137 *out << Verbose(0) << "Order at every site is already equal or above desired order " << Order << "." << endl; 2138 }; 2139 2113 2140 /** Performs a many-body bond order analysis for a given bond order. 2114 2141 * -# parses adjacency, keysets and orderatsite files … … 2132 2159 MoleculeListClass *BondFragments = NULL; 2133 2160 atom *Walker = NULL; 2134 atom *OtherWalker = NULL;2135 bond *Binder = NULL;2136 2161 int *SortIndex = NULL; 2137 2162 element *runner = NULL; … … 2149 2174 int TotalNumberOfKeySets = 0; 2150 2175 int KeySetCounter = 0; 2176 atom **ListOfAtoms = NULL; 2151 2177 atom ***ListOfLocalAtoms = NULL; 2152 2178 … … 2158 2184 #endif 2159 2185 2186 // ++++++++++++++++++++++++++++ INITIAL STUFF: Bond structure analysis, ... ++++++++++++++++++++++++++++++++++++++++++ 2187 2160 2188 // ===== 1. Check whether bond structure is same as stored in files ==== 2161 2189 … … 2164 2192 2165 2193 // create lookup table for Atom::nr 2166 atom **ListOfAtoms = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::FragmentMolecule - **ListOfAtoms"); 2167 Walker = start; 2168 while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron 2169 Walker = Walker->next; 2170 if ((Walker->nr >= 0) && (Walker->nr < AtomCount)) { 2171 ListOfAtoms[Walker->nr] = Walker; 2172 } else 2173 break; 2174 } 2175 if (Walker->next != end) { // everything went alright 2176 *out << " range of nuclear ids exceeded [0, AtomCount)." << endl; 2177 FragmentationToDo = false; 2178 } 2194 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(out, start, end, ListOfAtoms, AtomCount); 2195 2179 2196 // === compare it with adjacency file === 2180 2197 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms); … … 2184 2201 Subgraphs = DepthFirstSearchAnalysis((ofstream *)&*out, false, MinimumRingSize); 2185 2202 2186 // fill index lookup list for each subgraph from global nr to local pointer2187 ListOfLocalAtoms = (atom ***) Malloc(sizeof(atom **)*FragmentCounter, "molecule::FragmentMolecule - **ListOfLocalAtoms");2188 for (int i=0;i<FragmentCounter;i++) {2189 ListOfLocalAtoms[i] = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::FragmentMolecule - *ListOfLocalAtoms[]");2190 for(int j=0;j<AtomCount;j++)2191 ListOfLocalAtoms[i][j] = NULL;2192 }2193 FragmentCounter = 0;2194 MolecularWalker = Subgraphs;2195 while (MolecularWalker->next != NULL) {2196 MolecularWalker = MolecularWalker->next;2197 Walker = MolecularWalker->Leaf->start;2198 while (Walker->next != MolecularWalker->Leaf->end) {2199 Walker = Walker->next;2200 #ifdef ADDHYDROGEN2201 if (Walker->type->Z != 1) // skip hydrogen2202 #endif2203 ListOfLocalAtoms[FragmentCounter][Walker->GetTrueFather()->nr] = Walker; // set present global id index to the local pointer2204 }2205 FragmentCounter++;2206 }2207 2208 2203 // fill the bond structure of the individually stored subgraphs 2209 FragmentCounter = 0; 2210 MolecularWalker = Subgraphs; 2211 while (MolecularWalker->next != NULL) { 2212 MolecularWalker = MolecularWalker->next; 2213 *out << Verbose(1) << "Creating adjacency list for subgraph " << MolecularWalker << "." << endl; 2214 Walker = MolecularWalker->Leaf->start; 2215 while (Walker->next != MolecularWalker->Leaf->end) { 2216 Walker = Walker->next; 2217 AtomNo = Walker->father->nr; // global id of the current walker 2218 for(int i=0;i<NumberOfBondsPerAtom[AtomNo];i++) { // go through father's bonds and copy them all 2219 Binder = ListOfBondsPerAtom[AtomNo][i]; 2220 OtherWalker = ListOfLocalAtoms[FragmentCounter][Binder->GetOtherAtom(Walker->father)->nr]; // local copy of current bond partner of walker 2221 if ((OtherWalker != NULL) && (OtherWalker->nr > Walker->nr)) 2222 MolecularWalker->Leaf->AddBond(Walker, OtherWalker, Binder->BondDegree); 2223 } 2224 } 2225 //MolecularWalker->Leaf->CreateAdjacencyList(out, BondDistance); 2226 MolecularWalker->Leaf->CreateListOfBondsPerAtom(out); 2227 FragmentCounter++; 2228 } 2204 FragmentationToDo = FragmentationToDo && Subgraphs->next->FillBondStructureFromReference(out, this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 2229 2205 2230 2206 // ===== 3. if structure still valid, parse key set file and others ===== 2231 if (FragmentationToDo) { 2232 // parse key sets into new graph 2233 TempFragmentList = new Graph; 2234 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, TempFragmentList, configuration->GetIsAngstroem()); 2235 } else 2236 *out << Verbose(1) << "Creation of lookup table Atom::nr <-> Atom failed!" << endl; 2237 if (FragmentationToDo) // parse the adaptive order per atom/site/vertex 2238 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(out, configuration->configpath); 2239 else 2240 *out << Verbose(1) << "Parsing keyset file failed" << endl; 2241 2207 TempFragmentList = new Graph; 2208 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, TempFragmentList, configuration->GetIsAngstroem()); 2209 2242 2210 // ===== 4. check globally whether there's something to do actually (first adaptivity check) 2243 if (FragmentationToDo) { // check whether OrderAtSite is above Order everywhere 2244 FragmentationToDo = false; 2245 Walker = start; 2246 while (Walker->next != end) { 2247 Walker = Walker->next; 2248 #ifdef ADDHYDROGEN 2249 if (Walker->type->Z != 1) // skip hydrogen 2250 #endif 2251 if (Walker->AdaptiveOrder < Order) 2252 FragmentationToDo = true; 2253 } 2254 } else 2255 *out << Verbose(1) << "Parsing order at site file failed" << endl; 2256 2257 if (!FragmentationToDo) 2258 *out << Verbose(0) << "Order at every site is already equal or above desired order " << Order << "." << endl; 2259 2211 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(out, configuration->configpath); 2212 CheckOrderAtSite(out, FragmentationToDo, Order); 2213 2260 2214 // =================================== Begin of FRAGMENTATION =============================== 2261 2215 // check cyclic lengths … … 2263 2217 *out << Verbose(0) << "Bond order " << Order << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl; 2264 2218 } else { 2265 FragmentCounter = 0;2266 MolecularWalker = Subgraphs;2267 // count subgraphs and allocate fragments2268 while (MolecularWalker->next != NULL) {2269 MolecularWalker = MolecularWalker->next;2270 FragmentCounter++;2271 }2272 2219 FragmentList = (Graph **) Malloc(sizeof(Graph *)*FragmentCounter, "molecule::FragmentMolecule - **BondFragments"); 2273 2220 … … 2325 2272 delete(FragmentList[FragmentCounter]); 2326 2273 else 2327 *out << Verbose(1) << KeySetCounter << " atoms were put into subgraph " << FragmentCounter << "." << endl;2274 *out << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl; 2328 2275 FragmentCounter++; 2329 2276 } … … 2365 2312 MolecularWalker->Leaf->FragmentBOSSANOVA(out, FragmentList[FragmentCounter], RootStack[FragmentCounter]); 2366 2313 2367 // translate list into global numbers (i.e. valid in "this" molecule, not in MolecularWalker->Leaf)2368 KeySet *TempSet = new KeySet;2369 for(Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {2370 for(KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)2371 TempSet->insert((MolecularWalker->Leaf->FindAtom(*sprinter))->GetTrueFather()->nr);2372 TotalGraph.insert(GraphPair(*TempSet, pair<int,double>(TotalNumberOfKeySets++, (*runner).second.second)));2373 TempSet->clear();2374 }2375 delete(TempSet);2376 delete(FragmentList[FragmentCounter]);2377 2314 } else { 2378 2315 cerr << "Subgraph " << MolecularWalker << " has no atoms!" << endl; … … 2381 2318 } 2382 2319 } 2320 2321 // ==================================== End of FRAGMENTATION ============================================ 2322 2323 // ===== 8a. translate list into global numbers (i.e. valid in "this" molecule, not in MolecularWalker->Leaf) 2324 MolecularWalker = Subgraphs; 2325 FragmentCounter = 0; 2326 while (MolecularWalker->next != NULL) { 2327 MolecularWalker = MolecularWalker->next; 2328 KeySet *TempSet = new KeySet; 2329 for(Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) { 2330 for(KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++) 2331 TempSet->insert((MolecularWalker->Leaf->FindAtom(*sprinter))->GetTrueFather()->nr); 2332 TotalGraph.insert(GraphPair(*TempSet, pair<int,double>(TotalNumberOfKeySets++, (*runner).second.second))); 2333 TempSet->clear(); 2334 } 2335 delete(TempSet); 2336 delete(FragmentList[FragmentCounter]); 2337 FragmentCounter++; 2338 } 2383 2339 Free((void **)&FragmentList, "molecule::FragmentMolecule - **FragmentList"); 2384 2340 2385 // ===== 8 . gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====2341 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== 2386 2342 // allocate memory for the pointer array and transmorph graphs into full molecular fragments 2387 2343 BondFragments = new MoleculeListClass(TotalGraph.size(), AtomCount); … … 2394 2350 } 2395 2351 *out << k << "/" << BondFragments->NumberOfMolecules << " fragments generated from the keysets." << endl; 2396 2397 // ==================================== End of FRAGMENTATION ================================2398 2352 2399 2353 // ===== 10. Save fragments' configuration and keyset files et al to disk === -
src/molecules.hpp
rc82f3d r9fcf47 340 340 /// Fragment molecule by two different approaches: 341 341 void FragmentMolecule(ofstream *out, int Order, config *configuration); 342 void CheckOrderAtSite(ofstream *out, bool &FragmentationToDo, int Order); 342 343 bool StoreAdjacencyToFile(ofstream *out, char *path); 343 344 bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms); … … 408 409 409 410 bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous); 411 bool FillBondStructureFromReference(ofstream *out, molecule *reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false); 410 412 }; 411 413
Note:
See TracChangeset
for help on using the changeset viewer.