Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r49e1ae ra67d19  
    2323#include "tesselation.hpp"
    2424#include "vector.hpp"
     25#include "World.hpp"
    2526
    2627/************************************* Functions for class molecule *********************************/
     
    4546  for(int i=MAX_ELEMENTS;i--;)
    4647    ElementsInMolecule[i] = 0;
    47   cell_size[0] = cell_size[2] = cell_size[5]= 20.;
    48   cell_size[1] = cell_size[3] = cell_size[4]= 0.;
    49   strcpy(name,"none");
     48  strcpy(name,World::get()->DefaultName);
    5049};
    5150
     
    159158  double *matrix = NULL;
    160159  bond *Binder = NULL;
     160  double * const cell_size = World::get()->cell_size;
    161161
    162162//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     
    194194  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    195195  if (BondRescale == -1) {
    196     eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     196    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    197197    return false;
    198198    BondRescale = bondlength;
     
    237237            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    238238          } else {
    239             eLog() << Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name;
     239            DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name);
    240240          }
    241241        }
     
    274274      bondangle = TopOrigin->type->HBondAngle[1];
    275275      if (bondangle == -1) {
    276         eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     276        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    277277        return false;
    278278        bondangle = 0;
     
    396396      break;
    397397    default:
    398       eLog() << Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl;
     398      DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
    399399      AllWentWell = false;
    400400      break;
     
    429429  input = new istringstream(line);
    430430  *input >> NumberOfAtoms;
    431   Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;
     431  DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
    432432  getline(xyzfile,line,'\n'); // Read comment
    433   Log() << Verbose(1) << "Comment: " << line << endl;
     433  DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
    434434
    435435  if (MDSteps == 0) // no atoms yet present
     
    447447    Walker->type = elemente->FindElement(shorthand);
    448448    if (Walker->type == NULL) {
    449       eLog() << Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.";
     449      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    450450      Walker->type = elemente->FindElement(1);
    451451    }
     
    543543    add(Binder, last);
    544544  } else {
    545     eLog() << Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;
     545    DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl);
    546546  }
    547547  return Binder;
     
    555555bool molecule::RemoveBond(bond *pointer)
    556556{
    557   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     557  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    558558  pointer->leftatom->RegisterBond(pointer);
    559559  pointer->rightatom->RegisterBond(pointer);
     
    569569bool molecule::RemoveBonds(atom *BondPartner)
    570570{
    571   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     571  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    572572  BondList::const_iterator ForeRunner;
    573573  while (!BondPartner->ListOfBonds.empty()) {
     
    603603void molecule::SetBoxDimension(Vector *dim)
    604604{
     605  double * const cell_size = World::get()->cell_size;
    605606  cell_size[0] = dim->x[0];
    606607  cell_size[1] = 0.;
     
    621622    AtomCount--;
    622623  } else
    623     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     624    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    624625  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    625626    ElementCount--;
     
    639640    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    640641  else
    641     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     642    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    642643  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    643644    ElementCount--;
     
    664665    return walker;
    665666  } else {
    666     Log() << Verbose(0) << "Atom not found in list." << endl;
     667    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
    667668    return NULL;
    668669  }
     
    680681    //mol->Output((ofstream *)&cout);
    681682    //Log() << Verbose(0) << "===============================================" << endl;
    682     Log() << Verbose(0) << text;
     683    DoLog(0) && (Log() << Verbose(0) << text);
    683684    cin >> No;
    684685    ion = this->FindAtom(No);
     
    693694bool molecule::CheckBounds(const Vector *x) const
    694695{
     696  double * const cell_size = World::get()->cell_size;
    695697  bool result = true;
    696698  int j =-1;
     
    768770void molecule::OutputListOfBonds() const
    769771{
    770   Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;
     772  DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
    771773  ActOnAllAtoms (&atom::OutputBondOfAtom );
    772   Log() << Verbose(0) << endl;
     774  DoLog(0) && (Log() << Verbose(0) << endl);
    773775};
    774776
     
    827829  }
    828830  if ((AtomCount == 0) || (i != AtomCount)) {
    829     Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
     831    DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    830832    AtomCount = i;
    831833
     
    843845        Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    844846        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    845         Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
     847        DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl);
    846848        i++;
    847849      }
    848850    } else
    849       Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
     851      DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    850852  }
    851853};
     
    907909  bool result = true; // status of comparison
    908910
    909   Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
     911  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
    910912  /// first count both their atoms and elements and update lists thereby ...
    911913  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     
    919921  if (result) {
    920922    if (AtomCount != OtherMolecule->AtomCount) {
    921       Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     923      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
    922924      result = false;
    923925    } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     
    926928  if (result) {
    927929    if (ElementCount != OtherMolecule->ElementCount) {
    928       Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     930      DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl);
    929931      result = false;
    930932    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     
    938940    }
    939941    if (flag < MAX_ELEMENTS) {
    940       Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;
     942      DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
    941943      result = false;
    942944    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
     
    944946  /// then determine and compare center of gravity for each molecule ...
    945947  if (result) {
    946     Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;
     948    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
    947949    DeterminePeriodicCenter(CenterOfGravity);
    948950    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    949     Log() << Verbose(5) << "Center of Gravity: ";
     951    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: ");
    950952    CenterOfGravity.Output();
    951     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
     953    DoLog(0) && (Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ");
    952954    OtherCenterOfGravity.Output();
    953     Log() << Verbose(0) << endl;
     955    DoLog(0) && (Log() << Verbose(0) << endl);
    954956    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    955       Log() << Verbose(4) << "Centers of gravity don't match." << endl;
     957      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
    956958      result = false;
    957959    }
     
    960962  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
    961963  if (result) {
    962     Log() << Verbose(5) << "Calculating distances" << endl;
     964    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    963965    Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    964966    OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     
    967969
    968970    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    969     Log() << Verbose(5) << "Sorting distances" << endl;
     971    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    970972    PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    971973    OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     
    973975    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    974976    PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
    975     Log() << Verbose(5) << "Combining Permutation Maps" << endl;
     977    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    976978    for(int i=AtomCount;i--;)
    977979      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    978980
    979981    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
    980     Log() << Verbose(4) << "Comparing distances" << endl;
     982    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    981983    flag = 0;
    982984    for (int i=0;i<AtomCount;i++) {
    983       Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl;
     985      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    984986      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
    985987        flag = 1;
     
    997999  }
    9981000  /// return pointer to map if all distances were below \a threshold
    999   Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
     1001  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
    10001002  if (result) {
    1001     Log() << Verbose(3) << "Result: Equal." << endl;
     1003    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
    10021004    return PermutationMap;
    10031005  } else {
    1004     Log() << Verbose(3) << "Result: Not equal." << endl;
     1006    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
    10051007    return NULL;
    10061008  }
     
    10171019{
    10181020  atom *Walker = NULL, *OtherWalker = NULL;
    1019   Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
     1021  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    10201022  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    10211023  for (int i=AtomCount;i--;)
     
    10241026    for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
    10251027      AtomicMap[i] = i;
    1026     Log() << Verbose(4) << "Map is trivial." << endl;
     1028    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    10271029  } else {
    1028     Log() << Verbose(4) << "Map is ";
     1030    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    10291031    Walker = start;
    10301032    while (Walker->next != end) {
     
    10431045        }
    10441046      }
    1045       Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
    1046     }
    1047     Log() << Verbose(0) << endl;
    1048   }
    1049   Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl;
     1047      DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1048    }
     1049    DoLog(0) && (Log() << Verbose(0) << endl);
     1050  }
     1051  DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
    10501052  return AtomicMap;
    10511053};
Note: See TracChangeset for help on using the changeset viewer.