Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    rca2587 r437922  
    3535 * \return true - add successful
    3636 */
    37 bool MoleculeListClass::insert(molecule *mol)
     37void MoleculeListClass::insert(molecule *mol)
    3838{
    3939  mol->IndexNr = MaxIndex++;
     
    128128  atom *Walker = NULL;
    129129  int Counts[MAX_ELEMENTS];
     130  double size=0;
     131  Vector Origin;
    130132
    131133  // header
    132   *out << "Index\tName\tNo.Atoms\tformula" << endl;
     134  *out << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;
    133135  cout << Verbose(0) << "-----------------------------------------------" << endl;
    134136  if (ListOfMolecules.size() == 0)
    135137    *out << "\tNone" << endl;
    136138  else {
     139    Origin.Zero();
    137140    for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    138141      // reset element counts
    139142      for (int j = 0; j<MAX_ELEMENTS;j++)
    140143        Counts[j] = 0;
    141       // count atoms per element
     144      // count atoms per element and determine size of bounding sphere
     145      size=0.;
    142146      Walker = (*ListRunner)->start;
    143147      while (Walker->next != (*ListRunner)->end) {
    144148        Walker = Walker->next;
    145149        Counts[Walker->type->Z]++;
     150        if (Walker->x.DistanceSquared(&Origin) > size)
     151          size = Walker->x.DistanceSquared(&Origin);
    146152      }
    147153      // output Index, Name, number of atoms, chemical formula
    148154      *out << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
    149155      Elemental = (*ListRunner)->elemente->end;
    150       while(Elemental != (*ListRunner)->elemente->start) {
     156      while(Elemental->previous != (*ListRunner)->elemente->start) {
    151157        Elemental = Elemental->previous;
    152158        if (Counts[Elemental->Z] != 0)
    153159          *out << Elemental->symbol << Counts[Elemental->Z];
    154160      }
    155       *out << endl;
     161      // Center and size
     162      *out << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
    156163    }
    157164  }
     
    164171molecule * MoleculeListClass::ReturnIndex(int index)
    165172{
    166   int count = 1;
    167   MoleculeList::iterator ListRunner = ListOfMolecules.begin();
    168   for(; ((ListRunner != ListOfMolecules.end()) && (count < index)); ListRunner++);
    169   if (count == index)
    170     return (*ListRunner);
    171   else
    172     return NULL;
     173  for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
     174    if ((*ListRunner)->IndexNr == index)
     175      return (*ListRunner);
     176  return NULL;
    173177};
    174178
     
    523527
    524528  // open file for the force factors
    525   *out << Verbose(1) << "Saving force factors ... ";
     529  *out << Verbose(1) << "Saving  force factors ... ";
    526530  line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    527531  ForcesFile.open(line.str().c_str(), ios::out);
     
    691695MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL)
    692696{
    693   //    if (Up != NULL)
    694   //            if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
    695   //                    Up->DownLeaf = this;
    696   //    UpLeaf = Up;
    697   //    DownLeaf = NULL;
     697  //  if (Up != NULL)
     698  //    if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
     699  //      Up->DownLeaf = this;
     700  //  UpLeaf = Up;
     701  //  DownLeaf = NULL;
    698702  Leaf = NULL;
    699703  previous = PreviousLeaf;
     
    711715MoleculeLeafClass::~MoleculeLeafClass()
    712716{
    713   //    if (DownLeaf != NULL) {// drop leaves further down
    714   //            MoleculeLeafClass *Walker = DownLeaf;
    715   //            MoleculeLeafClass *Next;
    716   //            do {
    717   //                    Next = Walker->NextLeaf;
    718   //                    delete(Walker);
    719   //                    Walker = Next;
    720   //            } while (Walker != NULL);
    721   //            // Last Walker sets DownLeaf automatically to NULL
    722   //    }
     717  //  if (DownLeaf != NULL) {// drop leaves further down
     718  //    MoleculeLeafClass *Walker = DownLeaf;
     719  //    MoleculeLeafClass *Next;
     720  //    do {
     721  //      Next = Walker->NextLeaf;
     722  //      delete(Walker);
     723  //      Walker = Next;
     724  //    } while (Walker != NULL);
     725  //    // Last Walker sets DownLeaf automatically to NULL
     726  //  }
    723727  // remove the leaf itself
    724728  if (Leaf != NULL) {
     
    729733  if (previous != NULL)
    730734    previous->next = next;
    731   //    } else { // we are first in list (connects to UpLeaf->DownLeaf)
    732   //            if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
    733   //                    NextLeaf->UpLeaf = UpLeaf;      // either null as we are top level or the upleaf of the first node
    734   //            if (UpLeaf != NULL)
    735   //                    UpLeaf->DownLeaf = NextLeaf;    // either null as we are only leaf or NextLeaf if we are just the first
    736   //    }
    737   //    UpLeaf = NULL;
     735  //  } else { // we are first in list (connects to UpLeaf->DownLeaf)
     736  //    if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
     737  //      NextLeaf->UpLeaf = UpLeaf;  // either null as we are top level or the upleaf of the first node
     738  //    if (UpLeaf != NULL)
     739  //      UpLeaf->DownLeaf = NextLeaf;  // either null as we are only leaf or NextLeaf if we are just the first
     740  //  }
     741  //  UpLeaf = NULL;
    738742  if (next != NULL) // are we last in list
    739743    next->previous = previous;
Note: See TracChangeset for help on using the changeset viewer.