Ignore:
Timestamp:
Nov 4, 2009, 7:56:04 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
4ef101, aa8542
Parents:
ec70ec
Message:

Huge change from ofstream * (const) out --> Log().

  • first shift was done via regular expressions
  • then via error messages from the code
  • note that class atom, class element and class molecule kept in parts their output stream, was they print to file.
  • make check runs fine
  • MISSING: Verbosity is not fixed for everything (i.e. if no endl; is present and next has Verbose(0) ...)

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecule.cpp

    rec70ec r543ce4  
    1414#include "linkedcell.hpp"
    1515#include "lists.hpp"
     16#include "log.hpp"
    1617#include "molecule.hpp"
    1718#include "memoryallocator.hpp"
     
    143144 * \todo double and triple bonds splitting (always use the tetraeder angle!)
    144145 */
    145 bool molecule::AddHydrogenReplacementAtom(ofstream *out, bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
     146bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
    146147{
    147148  double bondlength;  // bond length of the bond to be replaced/cut
     
    157158  bond *Binder = NULL;
    158159
    159 //  *out << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     160//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    160161  // create vector in direction of bond
    161162  InBondvector.CopyVector(&TopReplacement->x);
     
    167168   // due to TopReplacement or Origin being on the wrong side!
    168169  if (bondlength > BondDistance) {
    169 //    *out << Verbose(4) << "InBondvector is: ";
     170//    Log() << Verbose(4) << "InBondvector is: ";
    170171//    InBondvector.Output(out);
    171 //    *out << endl;
     172//    Log() << Verbose(0) << endl;
    172173    Orthovector1.Zero();
    173174    for (int i=NDIM;i--;) {
     
    182183    Free(&matrix);
    183184    bondlength = InBondvector.Norm();
    184 //    *out << Verbose(4) << "Corrected InBondvector is now: ";
     185//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
    185186//    InBondvector.Output(out);
    186 //    *out << endl;
     187//    Log() << Verbose(0) << endl;
    187188  } // periodic correction finished
    188189
     
    191192  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    192193  if (BondRescale == -1) {
    193     cerr << Verbose(3) << "ERROR: There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     194    eLog() << Verbose(3) << "ERROR: There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
    194195    return false;
    195196    BondRescale = bondlength;
     
    216217      FirstOtherAtom->x.AddVector(&InBondvector);  // ... and add distance vector to replacement atom
    217218      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    218 //      *out << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     219//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    219220//      FirstOtherAtom->x.Output(out);
    220 //      *out << endl;
     221//      Log() << Verbose(0) << endl;
    221222      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    222223      Binder->Cyclic = false;
     
    234235            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    235236          } else {
    236             *out << Verbose(3) << "WARNING: Detected more than four bonds for atom " << TopOrigin->Name;
     237            Log() << Verbose(3) << "WARNING: Detected more than four bonds for atom " << TopOrigin->Name;
    237238          }
    238239        }
     
    243244      }
    244245      if (FirstOtherAtom != NULL) { // then we just have this double bond and the plane does not matter at all
    245 //        *out << Verbose(3) << "Regarding the double bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") to be constructed: Taking " << FirstOtherAtom->Name << " and " << SecondOtherAtom->Name << " along with " << TopOrigin->Name << " to determine orthogonal plane." << endl;
     246//        Log() << Verbose(3) << "Regarding the double bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") to be constructed: Taking " << FirstOtherAtom->Name << " and " << SecondOtherAtom->Name << " along with " << TopOrigin->Name << " to determine orthogonal plane." << endl;
    246247
    247248        // determine the plane of these two with the *origin
     
    250251        Orthovector1.GetOneNormalVector(&InBondvector);
    251252      }
    252       //*out << Verbose(3)<< "Orthovector1: ";
     253      //Log() << Verbose(3)<< "Orthovector1: ";
    253254      //Orthovector1.Output(out);
    254       //*out << endl;
     255      //Log() << Verbose(0) << endl;
    255256      // orthogonal vector and bond vector between origin and replacement form the new plane
    256257      Orthovector1.MakeNormalVector(&InBondvector);
    257258      Orthovector1.Normalize();
    258       //*out << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
     259      //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
    259260
    260261      // create the two Hydrogens ...
     
    271272      bondangle = TopOrigin->type->HBondAngle[1];
    272273      if (bondangle == -1) {
    273         *out << Verbose(3) << "ERROR: There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     274        Log() << Verbose(3) << "ERROR: There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
    274275        return false;
    275276        bondangle = 0;
    276277      }
    277278      bondangle *= M_PI/180./2.;
    278 //      *out << Verbose(3) << "ReScaleCheck: InBondvector ";
     279//      Log() << Verbose(3) << "ReScaleCheck: InBondvector ";
    279280//      InBondvector.Output(out);
    280 //      *out << endl;
    281 //      *out << Verbose(3) << "ReScaleCheck: Orthovector ";
     281//      Log() << Verbose(0) << endl;
     282//      Log() << Verbose(3) << "ReScaleCheck: Orthovector ";
    282283//      Orthovector1.Output(out);
    283 //      *out << endl;
    284 //      *out << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
     284//      Log() << Verbose(0) << endl;
     285//      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
    285286      FirstOtherAtom->x.Zero();
    286287      SecondOtherAtom->x.Zero();
     
    291292      FirstOtherAtom->x.Scale(&BondRescale);  // rescale by correct BondDistance
    292293      SecondOtherAtom->x.Scale(&BondRescale);
    293       //*out << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
     294      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    294295      for(int i=NDIM;i--;) { // and make relative to origin atom
    295296        FirstOtherAtom->x.x[i] += TopOrigin->x.x[i];
     
    299300      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    300301      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
    301 //      *out << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     302//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    302303//      FirstOtherAtom->x.Output(out);
    303 //      *out << endl;
    304 //      *out << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
     304//      Log() << Verbose(0) << endl;
     305//      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
    305306//      SecondOtherAtom->x.Output(out);
    306 //      *out << endl;
     307//      Log() << Verbose(0) << endl;
    307308      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    308309      Binder->Cyclic = false;
     
    332333      // we need to vectors orthonormal the InBondvector
    333334      AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(&InBondvector);
    334 //      *out << Verbose(3) << "Orthovector1: ";
     335//      Log() << Verbose(3) << "Orthovector1: ";
    335336//      Orthovector1.Output(out);
    336 //      *out << endl;
     337//      Log() << Verbose(0) << endl;
    337338      AllWentWell = AllWentWell && Orthovector2.MakeNormalVector(&InBondvector, &Orthovector1);
    338 //      *out << Verbose(3) << "Orthovector2: ";
     339//      Log() << Verbose(3) << "Orthovector2: ";
    339340//      Orthovector2.Output(out);
    340 //      *out << endl;
     341//      Log() << Verbose(0) << endl;
    341342
    342343      // create correct coordination for the three atoms
     
    347348      f = b/sqrt(3.);   // length for Orthvector1
    348349      g = b/2.;         // length for Orthvector2
    349 //      *out << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;
    350 //      *out << Verbose(3) << "The three Bond lengths: " << sqrt(d*d+f*f) << ", " << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << ", "  << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << endl;
     350//      Log() << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;
     351//      Log() << Verbose(3) << "The three Bond lengths: " << sqrt(d*d+f*f) << ", " << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << ", "  << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << endl;
    351352      factors[0] = d;
    352353      factors[1] = f;
     
    373374      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
    374375      AllWentWell = AllWentWell && AddAtom(ThirdOtherAtom);
    375 //      *out << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     376//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    376377//      FirstOtherAtom->x.Output(out);
    377 //      *out << endl;
    378 //      *out << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
     378//      Log() << Verbose(0) << endl;
     379//      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
    379380//      SecondOtherAtom->x.Output(out);
    380 //      *out << endl;
    381 //      *out << Verbose(4) << "Added " << *ThirdOtherAtom << " at: ";
     381//      Log() << Verbose(0) << endl;
     382//      Log() << Verbose(4) << "Added " << *ThirdOtherAtom << " at: ";
    382383//      ThirdOtherAtom->x.Output(out);
    383 //      *out << endl;
     384//      Log() << Verbose(0) << endl;
    384385      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    385386      Binder->Cyclic = false;
     
    393394      break;
    394395    default:
    395       cerr << "ERROR: BondDegree does not state single, double or triple bond!" << endl;
     396      eLog() << Verbose(0) << "ERROR: BondDegree does not state single, double or triple bond!" << endl;
    396397      AllWentWell = false;
    397398      break;
    398399  }
    399400
    400 //  *out << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     401//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
    401402  return AllWentWell;
    402403};
     
    425426  input = new istringstream(line);
    426427  *input >> NumberOfAtoms;
    427   cout << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;
     428  Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;
    428429  getline(xyzfile,line,'\n'); // Read comment
    429   cout << Verbose(1) << "Comment: " << line << endl;
     430  Log() << Verbose(1) << "Comment: " << line << endl;
    430431
    431432  if (MDSteps == 0) // no atoms yet present
     
    436437    istringstream *item = new istringstream(line);
    437438    //istringstream input(line);
    438     //cout << Verbose(1) << "Reading: " << line << endl;
     439    //Log() << Verbose(1) << "Reading: " << line << endl;
    439440    *item >> shorthand;
    440441    *item >> x[0];
     
    443444    Walker->type = elemente->FindElement(shorthand);
    444445    if (Walker->type == NULL) {
    445       cerr << "Could not parse the element at line: '" << line << "', setting to H.";
     446      eLog() << Verbose(0) << "Could not parse the element at line: '" << line << "', setting to H.";
    446447      Walker->type = elemente->FindElement(1);
    447448    }
     
    496497
    497498  // copy values
    498   copy->CountAtoms((ofstream *)&cout);
     499  copy->CountAtoms();
    499500  copy->CountElements();
    500501  if (first->next != last) {  // if adjaceny list is present
     
    517518  ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
    518519
    519   //TODO: copy->BuildInducedSubgraph((ofstream *)&cout, this);
     520  //TODO: copy->BuildInducedSubgraph(this);
    520521
    521522  return copy;
     
    539540    add(Binder, last);
    540541  } else {
    541     cerr << Verbose(1) << "ERROR: Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;
     542    eLog() << Verbose(1) << "ERROR: Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;
    542543  }
    543544  return Binder;
     
    551552bool molecule::RemoveBond(bond *pointer)
    552553{
    553   //cerr << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     554  //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
    554555  pointer->leftatom->RegisterBond(pointer);
    555556  pointer->rightatom->RegisterBond(pointer);
     
    565566bool molecule::RemoveBonds(atom *BondPartner)
    566567{
    567   //cerr << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     568  //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
    568569  BondList::const_iterator ForeRunner;
    569570  while (!BondPartner->ListOfBonds.empty()) {
     
    617618    AtomCount--;
    618619  } else
    619     cerr << "ERROR: Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     620    eLog() << Verbose(0) << "ERROR: Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
    620621  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    621622    ElementCount--;
     
    635636    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    636637  else
    637     cerr << "ERROR: Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     638    eLog() << Verbose(0) << "ERROR: Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
    638639  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    639640    ElementCount--;
     
    657658  atom * walker = find(&Nr, start,end);
    658659  if (walker != NULL) {
    659     //cout << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
     660    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    660661    return walker;
    661662  } else {
    662     cout << Verbose(0) << "Atom not found in list." << endl;
     663    Log() << Verbose(0) << "Atom not found in list." << endl;
    663664    return NULL;
    664665  }
     
    673674  atom *ion = NULL;
    674675  do {
    675     //cout << Verbose(0) << "============Atom list==========================" << endl;
     676    //Log() << Verbose(0) << "============Atom list==========================" << endl;
    676677    //mol->Output((ofstream *)&cout);
    677     //cout << Verbose(0) << "===============================================" << endl;
    678     cout << Verbose(0) << text;
     678    //Log() << Verbose(0) << "===============================================" << endl;
     679    Log() << Verbose(0) << text;
    679680    cin >> No;
    680681    ion = this->FindAtom(No);
     
    702703 * \param *out output stream
    703704 */
    704 bool molecule::Output(ofstream *out)
     705bool molecule::Output(ofstream * const output)
    705706{
    706707  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
     
    711712    ElementNo[i] = 0;
    712713  }
    713   if (out == NULL) {
     714  if (output == NULL) {
    714715    return false;
    715716  } else {
    716     *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     717    *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
    717718    SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
    718719    int current=1;
     
    721722        ElementNo[i] = current++;
    722723    }
    723     ActOnAllAtoms( &atom::OutputArrayIndexed, (ofstream *)out, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
     724    ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
    724725    return true;
    725726  }
     
    729730 * \param *out output stream
    730731 */
    731 bool molecule::OutputTrajectories(ofstream *out)
     732bool molecule::OutputTrajectories(ofstream * const output)
    732733{
    733734  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    734735  CountElements();
    735736
    736   if (out == NULL) {
     737  if (output == NULL) {
    737738    return false;
    738739  } else {
    739740    for (int step = 0; step < MDSteps; step++) {
    740741      if (step == 0) {
    741         *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     742        *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
    742743      } else {
    743         *out << "# ====== MD step " << step << " =========" << endl;
     744        *output << "# ====== MD step " << step << " =========" << endl;
    744745      }
    745746      for (int i=0;i<MAX_ELEMENTS;++i) {
     
    753754          ElementNo[i] = current++;
    754755      }
    755       ActOnAllAtoms( &atom::OutputTrajectory, out, (const int *)ElementNo, AtomNo, (const int)step );
     756      ActOnAllAtoms( &atom::OutputTrajectory, output, (const int *)ElementNo, AtomNo, (const int)step );
    756757    }
    757758    return true;
     
    762763 * \param *out output stream
    763764 */
    764 void molecule::OutputListOfBonds(ofstream *out) const
    765 {
    766   *out << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;
    767   ActOnAllAtoms (&atom::OutputBondOfAtom, out);
    768   *out << endl;
     765void molecule::OutputListOfBonds() const
     766{
     767  Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;
     768  ActOnAllAtoms (&atom::OutputBondOfAtom );
     769  Log() << Verbose(0) << endl;
    769770};
    770771
     
    772773 * \param *out stream pointer
    773774 */
    774 bool molecule::Checkout(ofstream *out)  const
    775 {
    776   return elemente->Checkout(out, ElementsInMolecule);
     775bool molecule::Checkout(ofstream * const output)  const
     776{
     777  return elemente->Checkout(output, ElementsInMolecule);
    777778};
    778779
     
    780781 * \param *out output stream
    781782 */
    782 bool molecule::OutputTrajectoriesXYZ(ofstream *out)
     783bool molecule::OutputTrajectoriesXYZ(ofstream * const output)
    783784{
    784785  time_t now;
    785786
    786   if (out != NULL) {
     787  if (output != NULL) {
    787788    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    788789    for (int step=0;step<MDSteps;step++) {
    789       *out << AtomCount << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
    790       ActOnAllAtoms( &atom::OutputTrajectoryXYZ, out, step );
     790      *output << AtomCount << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
     791      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
    791792    }
    792793    return true;
     
    798799* \param *out output stream
    799800 */
    800 bool molecule::OutputXYZ(ofstream *out) const
     801bool molecule::OutputXYZ(ofstream * const output) const
    801802{
    802803  time_t now;
    803804
    804   if (out != NULL) {
     805  if (output != NULL) {
    805806    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    806     *out << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
    807     ActOnAllAtoms( &atom::OutputXYZLine, out );
     807    *output << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
     808    ActOnAllAtoms( &atom::OutputXYZLine, output );
    808809    return true;
    809810  } else
     
    814815 * \param *out output stream for debugging
    815816 */
    816 void molecule::CountAtoms(ofstream *out)
     817void molecule::CountAtoms()
    817818{
    818819  int i = 0;
     
    823824  }
    824825  if ((AtomCount == 0) || (i != AtomCount)) {
    825     *out << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
     826    Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
    826827    AtomCount = i;
    827828
     
    839840        Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    840841        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    841         *out << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
     842        Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
    842843        i++;
    843844      }
    844845    } else
    845       *out << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
     846      Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
    846847  }
    847848};
     
    870871  for(int i=MAX_ELEMENTS;i--;) {
    871872    if (ElementsInMolecule[i] != 0) {
    872       //cout << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
     873      //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
    873874      configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);
    874875    }
     
    894895 * \return NULL - not equal, otherwise an allocated (molecule::AtomCount) permutation map of the atom numbers (which corresponds to which)
    895896 */
    896 int * molecule::IsEqualToWithinThreshold(ofstream *out, molecule *OtherMolecule, double threshold)
     897int * molecule::IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold)
    897898{
    898899  int flag;
     
    903904  bool result = true; // status of comparison
    904905
    905   *out << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
     906  Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
    906907  /// first count both their atoms and elements and update lists thereby ...
    907   //*out << Verbose(0) << "Counting atoms, updating list" << endl;
    908   CountAtoms(out);
    909   OtherMolecule->CountAtoms(out);
     908  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     909  CountAtoms();
     910  OtherMolecule->CountAtoms();
    910911  CountElements();
    911912  OtherMolecule->CountElements();
     
    915916  if (result) {
    916917    if (AtomCount != OtherMolecule->AtomCount) {
    917       *out << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     918      Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
    918919      result = false;
    919     } else *out << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     920    } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
    920921  }
    921922  /// -# ElementCount
    922923  if (result) {
    923924    if (ElementCount != OtherMolecule->ElementCount) {
    924       *out << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     925      Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
    925926      result = false;
    926     } else *out << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     927    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
    927928  }
    928929  /// -# ElementsInMolecule
    929930  if (result) {
    930931    for (flag=MAX_ELEMENTS;flag--;) {
    931       //*out << Verbose(5) << "Element " <<  flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl;
     932      //Log() << Verbose(5) << "Element " <<  flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl;
    932933      if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag])
    933934        break;
    934935    }
    935936    if (flag < MAX_ELEMENTS) {
    936       *out << Verbose(4) << "ElementsInMolecule don't match." << endl;
     937      Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;
    937938      result = false;
    938     } else *out << Verbose(4) << "ElementsInMolecule match." << endl;
     939    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
    939940  }
    940941  /// then determine and compare center of gravity for each molecule ...
    941942  if (result) {
    942     *out << Verbose(5) << "Calculating Centers of Gravity" << endl;
     943    Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;
    943944    DeterminePeriodicCenter(CenterOfGravity);
    944945    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    945     *out << Verbose(5) << "Center of Gravity: ";
    946     CenterOfGravity.Output(out);
    947     *out << endl << Verbose(5) << "Other Center of Gravity: ";
    948     OtherCenterOfGravity.Output(out);
    949     *out << endl;
     946    Log() << Verbose(5) << "Center of Gravity: ";
     947    CenterOfGravity.Output();
     948    Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
     949    OtherCenterOfGravity.Output();
     950    Log() << Verbose(0) << endl;
    950951    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    951       *out << Verbose(4) << "Centers of gravity don't match." << endl;
     952      Log() << Verbose(4) << "Centers of gravity don't match." << endl;
    952953      result = false;
    953954    }
     
    956957  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
    957958  if (result) {
    958     *out << Verbose(5) << "Calculating distances" << endl;
     959    Log() << Verbose(5) << "Calculating distances" << endl;
    959960    Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    960961    OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     
    963964
    964965    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    965     *out << Verbose(5) << "Sorting distances" << endl;
     966    Log() << Verbose(5) << "Sorting distances" << endl;
    966967    PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    967968    OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     
    969970    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    970971    PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
    971     *out << Verbose(5) << "Combining Permutation Maps" << endl;
     972    Log() << Verbose(5) << "Combining Permutation Maps" << endl;
    972973    for(int i=AtomCount;i--;)
    973974      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    974975
    975976    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
    976     *out << Verbose(4) << "Comparing distances" << endl;
     977    Log() << Verbose(4) << "Comparing distances" << endl;
    977978    flag = 0;
    978979    for (int i=0;i<AtomCount;i++) {
    979       *out << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl;
     980      Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl;
    980981      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
    981982        flag = 1;
     
    993994  }
    994995  /// return pointer to map if all distances were below \a threshold
    995   *out << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
     996  Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
    996997  if (result) {
    997     *out << Verbose(3) << "Result: Equal." << endl;
     998    Log() << Verbose(3) << "Result: Equal." << endl;
    998999    return PermutationMap;
    9991000  } else {
    1000     *out << Verbose(3) << "Result: Not equal." << endl;
     1001    Log() << Verbose(3) << "Result: Not equal." << endl;
    10011002    return NULL;
    10021003  }
     
    10101011 * \todo make this with a good sort O(n), not O(n^2)
    10111012 */
    1012 int * molecule::GetFatherSonAtomicMap(ofstream *out, molecule *OtherMolecule)
     1013int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10131014{
    10141015  atom *Walker = NULL, *OtherWalker = NULL;
    1015   *out << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
     1016  Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
    10161017  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    10171018  for (int i=AtomCount;i--;)
     
    10201021    for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
    10211022      AtomicMap[i] = i;
    1022     *out << Verbose(4) << "Map is trivial." << endl;
     1023    Log() << Verbose(4) << "Map is trivial." << endl;
    10231024  } else {
    1024     *out << Verbose(4) << "Map is ";
     1025    Log() << Verbose(4) << "Map is ";
    10251026    Walker = start;
    10261027    while (Walker->next != end) {
     
    10341035      //for (int i=0;i<AtomCount;i++) { // search atom
    10351036        //for (int j=0;j<OtherMolecule->AtomCount;j++) {
    1036           //*out << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
     1037          //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
    10371038          if (Walker->father == OtherWalker)
    10381039            AtomicMap[Walker->nr] = OtherWalker->nr;
    10391040        }
    10401041      }
    1041       *out << AtomicMap[Walker->nr] << "\t";
    1042     }
    1043     *out << endl;
    1044   }
    1045   *out << Verbose(3) << "End of GetFatherAtomicMap." << endl;
     1042      Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
     1043    }
     1044    Log() << Verbose(0) << endl;
     1045  }
     1046  Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl;
    10461047  return AtomicMap;
    10471048};
     
    10501051 * We simply use the formula equivaleting temperature and kinetic energy:
    10511052 * \f$k_B T = \sum_i m_i v_i^2\f$
    1052  * \param *out output stream for debugging
     1053 * \param *output output stream of temperature file
    10531054 * \param startstep first MD step in molecule::Trajectories
    10541055 * \param endstep last plus one MD step in molecule::Trajectories
    1055  * \param *output output stream of temperature file
    10561056 * \return file written (true), failure on writing file (false)
    10571057 */
    1058 bool molecule::OutputTemperatureFromTrajectories(ofstream *out, int startstep, int endstep, ofstream *output)
     1058bool molecule::OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep)
    10591059{
    10601060  double temperature;
Note: See TracChangeset for help on using the changeset viewer.