- Timestamp:
- May 8, 2008, 3:25:00 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:
- da5355
- Parents:
- d2a294
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
rd2a294 rdf2fca 1056 1056 return true; 1057 1057 } 1058 }; 1059 1060 /** Outputs contents of molecule::ListOfBondsPerAtom. 1061 * \param *out output stream 1062 */ 1063 void molecule::OutputListOfBonds(ofstream *out) const 1064 { 1065 *out << Verbose(2) << endl << "From Contents of ListOfBondsPerAtom, all non-hydrogen atoms:" << endl; 1066 atom *Walker = start; 1067 while (Walker->next != end) { 1068 Walker = Walker->next; 1069 #ifdef ADDHYDROGEN 1070 if (Walker->type->Z != 1) { // regard only non-hydrogen 1071 #endif 1072 *out << Verbose(2) << "Atom " << Walker->Name << " has Bonds: "<<endl; 1073 for(int j=0;j<NumberOfBondsPerAtom[Walker->nr];j++) { 1074 *out << Verbose(3) << *(ListOfBondsPerAtom)[Walker->nr][j] << endl; 1075 } 1076 #ifdef ADDHYDROGEN 1077 } 1078 #endif 1079 } 1080 *out << endl; 1058 1081 }; 1059 1082 … … 1940 1963 } 1941 1964 1965 // free memory 1942 1966 Free((void **)&filename, "molecule::ParseKeySetFile - filename"); 1943 1967 … … 2131 2155 FragmentationToDo = true; 2132 2156 } 2157 if (!FragmentationToDo) 2158 *out << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl; 2133 2159 } else 2134 2160 *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 2161 }; 2139 2162 … … 2169 2192 bool FragmentationToDo = true; 2170 2193 Graph **FragmentList = NULL; 2171 Graph * TempFragmentList = NULL;2194 Graph *ParsedFragmentList = NULL; 2172 2195 Graph TotalGraph; // graph with all keysets however local numbers 2173 KeySet *TempSet = NULL;2174 2196 int TotalNumberOfKeySets = 0; 2175 int KeySetCounter = 0;2176 2197 atom **ListOfAtoms = NULL; 2177 2198 atom ***ListOfLocalAtoms = NULL; … … 2199 2220 2200 2221 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== 2201 Subgraphs = DepthFirstSearchAnalysis((ofstream *)&*out, false, MinimumRingSize); 2202 2222 Subgraphs = DepthFirstSearchAnalysis(out, false, MinimumRingSize); 2203 2223 // fill the bond structure of the individually stored subgraphs 2204 FragmentationToDo = FragmentationToDo && Subgraphs->next->FillBondStructureFromReference(out, this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms2224 Subgraphs->next->FillBondStructureFromReference(out, this, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 2205 2225 2206 2226 // ===== 3. if structure still valid, parse key set file and others ===== 2207 TempFragmentList = new Graph; 2208 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, TempFragmentList, configuration->GetIsAngstroem()); 2227 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, ParsedFragmentList, configuration->GetIsAngstroem()); 2209 2228 2210 2229 // ===== 4. check globally whether there's something to do actually (first adaptivity check) … … 2217 2236 *out << Verbose(0) << "Bond order " << Order << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl; 2218 2237 } else { 2219 FragmentList = (Graph **) Malloc(sizeof(Graph *)*Subgraphs->next->Count(), "molecule::FragmentMolecule - **BondFragments");2220 2221 2238 // ===== 6a. fill RootStack for each subgraph (second adaptivity check) ===== 2222 2239 // NOTE: (keep this extern of following while loop, as lateron we may here look for which site to add to which subgraph) … … 2226 2243 2227 2244 // ===== 6b. assign each keyset to its respective subgraph ===== 2228 if ((TempFragmentList != NULL) && (TempFragmentList->size() != 0)) { // if there are some scanned keysets at all 2229 // spread the keysets 2230 FragmentCounter = 0; 2231 MolecularWalker = Subgraphs; 2232 while (MolecularWalker->next != NULL) { 2233 MolecularWalker = MolecularWalker->next; 2234 // assign scanned keysets 2235 FragmentList[FragmentCounter] = new Graph; 2236 TempSet = new KeySet; 2237 KeySetCounter = 0; 2238 for(Graph::iterator runner = TempFragmentList->begin();runner != TempFragmentList->end(); runner++) { // key sets contain global numbers! 2239 if ( ListOfLocalAtoms[FragmentCounter][FindAtom(*((*runner).first.begin()))->nr]->nr != -1) {// as we may assume that that bond structure is unchanged, we only test the first key in each set 2240 // translate keyset to local numbers 2241 for(KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++) 2242 TempSet->insert(ListOfLocalAtoms[FragmentCounter][FindAtom(*sprinter)->nr]->nr); 2243 // insert into FragmentList 2244 FragmentList[FragmentCounter]->insert(GraphPair (*TempSet, pair<int,double>(KeySetCounter++, (*runner).second.second))); 2245 } 2246 TempSet->clear(); 2247 } 2248 delete(TempSet); 2249 if (KeySetCounter == 0) 2250 delete(FragmentList[FragmentCounter]); 2251 else 2252 *out << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl; 2253 FragmentCounter++; 2254 } 2255 } else // otherwise make sure all lists are initialised to NULL 2256 for(int i=0;i<FragmentCounter;i++) 2257 FragmentList[i] = NULL; 2258 2245 Subgraphs->next->AssignKeySetsToFragment(out, this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), false); 2259 2246 2260 2247 // ===== 7. fill the bond fragment list ===== 2261 2248 FragmentCounter = 0; 2262 TotalNumberOfKeySets = 0;2263 2249 MolecularWalker = Subgraphs; 2264 2250 while (MolecularWalker->next != NULL) { 2265 2251 MolecularWalker = MolecularWalker->next; 2266 2252 *out << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl; 2253 // output ListOfBondsPerAtom for debugging 2254 MolecularWalker->Leaf->OutputListOfBonds(out); 2267 2255 if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) { 2268 // output ListOfBondsPerAtom for debugging2269 *out << Verbose(0) << endl << "From Contents of ListOfBondsPerAtom, all non-hydrogen atoms:" << endl;2270 Walker = MolecularWalker->Leaf->start;2271 while (Walker->next != MolecularWalker->Leaf->end) {2272 Walker = Walker->next;2273 #ifdef ADDHYDROGEN2274 if (Walker->type->Z != 1) { // regard only non-hydrogen2275 #endif2276 *out << Verbose(0) << "Atom " << Walker->Name << " has Bonds: "<<endl;2277 for(int j=0;j<MolecularWalker->Leaf->NumberOfBondsPerAtom[Walker->nr];j++) {2278 *out << Verbose(1) << *(MolecularWalker->Leaf->ListOfBondsPerAtom)[Walker->nr][j] << endl;2279 }2280 #ifdef ADDHYDROGEN2281 }2282 #endif2283 }2284 *out << endl;2285 2256 2257 // call BOSSANOVA method 2286 2258 *out << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl; 2287 *out << Verbose(0) << "Begin of bond fragmentation." << endl;2288 2289 // call BOSSANOVA method2290 2259 MolecularWalker->Leaf->FragmentBOSSANOVA(out, FragmentList[FragmentCounter], RootStack[FragmentCounter]); 2291 2292 2260 } else { 2293 2261 cerr << "Subgraph " << MolecularWalker << " has no atoms!" << endl; … … 2296 2264 } 2297 2265 } 2266 2267 // free the index lookup list 2268 for (int i=0;i<FragmentCounter;i++) 2269 Free((void **)&ListOfLocalAtoms[i], "molecule::FragmentMolecule - *ListOfLocalAtoms[]"); 2270 Free((void **)&ListOfLocalAtoms, "molecule::FragmentMolecule - **ListOfLocalAtoms"); 2298 2271 2299 2272 // ==================================== End of FRAGMENTATION ============================================ 2300 2273 2301 // ===== 8a. translate list into global numbers (i.e. valid in "this" molecule, not in MolecularWalker->Leaf)2274 // ===== 8a. translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf) 2302 2275 MolecularWalker = Subgraphs; 2303 2276 FragmentCounter = 0; … … 2316 2289 } 2317 2290 Free((void **)&FragmentList, "molecule::FragmentMolecule - **FragmentList"); 2291 // free subgraph memory again 2292 delete(ParsedFragmentList); 2293 if (Subgraphs != NULL) { 2294 while (Subgraphs->next != NULL) { 2295 Subgraphs = Subgraphs->next; 2296 delete(Subgraphs->previous); 2297 } 2298 delete(Subgraphs); 2299 } 2318 2300 2319 2301 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 2329 2311 *out << k << "/" << BondFragments->NumberOfMolecules << " fragments generated from the keysets." << endl; 2330 2312 2331 // ===== 10. Save fragments' configuration and keyset files et al to disk ===2313 // ===== 9. Save fragments' configuration and keyset files et al to disk === 2332 2314 if (BondFragments->NumberOfMolecules != 0) { 2333 2315 // create a SortIndex to map from BFS labels to the sequence in which the atoms are given in the config file … … 2377 2359 *out << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl; 2378 2360 2379 // free the index lookup list2380 for (int i=0;i<FragmentCounter;i++)2381 Free((void **)&ListOfLocalAtoms[i], "molecule::FragmentMolecule - *ListOfLocalAtoms[]");2382 Free((void **)&ListOfLocalAtoms, "molecule::FragmentMolecule - **ListOfLocalAtoms");2383 // free subgraph memory again2384 delete(TempFragmentList);2385 if (Subgraphs != NULL) {2386 while (Subgraphs->next != NULL) {2387 Subgraphs = Subgraphs->next;2388 delete(Subgraphs->previous);2389 }2390 delete(Subgraphs);2391 }2392 2393 2361 *out << Verbose(0) << "End of bond fragmentation." << endl; 2394 2362 };
Note:
See TracChangeset
for help on using the changeset viewer.