Changes in src/molecule_graph.cpp [e5ad5c:1f1b23]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
re5ad5c r1f1b23 147 147 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 148 148 const LinkedNodes *List = LC->GetCurrentCell(); 149 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;149 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 150 150 if (List != NULL) { 151 151 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 152 152 Walker = AtomMap[(*Runner)->nr]; 153 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;153 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 154 154 // 3c. check for possible bond between each atom in this and every one in the 27 cells 155 155 for (n[0] = -1; n[0] <= 1; n[0]++) … … 157 157 for (n[2] = -1; n[2] <= 1; n[2]++) { 158 158 const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n); 159 //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;159 //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 160 160 if (OtherList != NULL) { 161 161 for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 162 162 if ((*OtherRunner)->nr > Walker->nr) { 163 163 OtherWalker = AtomMap[(*OtherRunner)->nr]; 164 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 164 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 165 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 165 166 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size); 166 // Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;167 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);168 167 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 169 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; 170 if (OtherWalker->father->nr > Walker->father->nr) { 171 if (status) { // create bond if distance is smaller 172 // Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 173 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 174 } else { 175 // Log() << Verbose(1) << "Not Adding: distance too great." << endl; 176 } 168 if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller 169 //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 170 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 177 171 } else { 178 // Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;172 //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl; 179 173 } 180 174 } … … 932 926 break; // breaking here will not cause error! 933 927 } 934 if (i == vertex->ListOfBonds.size()) 928 if (i == vertex->ListOfBonds.size()) { 935 929 eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl; 936 } else 930 performCriticalExit(); 931 } 932 } else { 937 933 eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl; 934 performCriticalExit(); 935 } 938 936 } 939 937 ; … … 994 992 Log() << Verbose(1) << "Saving adjacency list ... "; 995 993 if (AdjacencyFile != NULL) { 994 AdjacencyFile << "m\tn" << endl; 996 995 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 997 996 AdjacencyFile.close(); 997 Log() << Verbose(1) << "done." << endl; 998 } else { 999 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl; 1000 status = false; 1001 } 1002 1003 return status; 1004 } 1005 ; 1006 1007 /** Storing the bond structure of a molecule to file. 1008 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1009 * \param *out output stream for debugging 1010 * \param *path path to file 1011 * \return true - file written successfully, false - writing failed 1012 */ 1013 bool molecule::StoreBondsToFile(char *path) 1014 { 1015 ofstream BondFile; 1016 stringstream line; 1017 bool status = true; 1018 1019 line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1020 BondFile.open(line.str().c_str(), ios::out); 1021 Log() << Verbose(1) << "Saving adjacency list ... "; 1022 if (BondFile != NULL) { 1023 BondFile << "m\tn" << endl; 1024 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1025 BondFile.close(); 998 1026 Log() << Verbose(1) << "done." << endl; 999 1027 } else { … … 1119 1147 bool status = true; 1120 1148 if (ReferenceStack->IsEmpty()) { 1121 eLog() << Verbose(0) << "ReferenceStack is empty!" << endl;1149 Log() << Verbose(1) << "ReferenceStack is empty!" << endl; 1122 1150 return false; 1123 1151 }
Note:
See TracChangeset
for help on using the changeset viewer.