Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    re5ad5c r1f1b23  
    147147        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    148148          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;
    150150          if (List != NULL) {
    151151            for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    152152              Walker = AtomMap[(*Runner)->nr];
    153 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     153              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    154154              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    155155              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    157157                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    158158                    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;
    160160                    if (OtherList != NULL) {
    161161                      for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    162162                        if ((*OtherRunner)->nr > Walker->nr) {
    163163                          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);
    165166                          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);
    168167                          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
    177171                          } 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;
    179173                          }
    180174                        }
     
    932926        break; // breaking here will not cause error!
    933927    }
    934     if (i == vertex->ListOfBonds.size())
     928    if (i == vertex->ListOfBonds.size()) {
    935929      eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;
    936   } else
     930      performCriticalExit();
     931    }
     932  } else {
    937933    eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;
     934    performCriticalExit();
     935  }
    938936}
    939937;
     
    994992  Log() << Verbose(1) << "Saving adjacency list ... ";
    995993  if (AdjacencyFile != NULL) {
     994    AdjacencyFile << "m\tn" << endl;
    996995    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    997996    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 */
     1013bool 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();
    9981026    Log() << Verbose(1) << "done." << endl;
    9991027  } else {
     
    11191147  bool status = true;
    11201148  if (ReferenceStack->IsEmpty()) {
    1121     eLog() << Verbose(0) << "ReferenceStack is empty!" << endl;
     1149    Log() << Verbose(1) << "ReferenceStack is empty!" << endl;
    11221150    return false;
    11231151  }
Note: See TracChangeset for help on using the changeset viewer.