Changes in src/molecule.cpp [49e1ae:a67d19]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r49e1ae ra67d19 23 23 #include "tesselation.hpp" 24 24 #include "vector.hpp" 25 #include "World.hpp" 25 26 26 27 /************************************* Functions for class molecule *********************************/ … … 45 46 for(int i=MAX_ELEMENTS;i--;) 46 47 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); 50 49 }; 51 50 … … 159 158 double *matrix = NULL; 160 159 bond *Binder = NULL; 160 double * const cell_size = World::get()->cell_size; 161 161 162 162 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 194 194 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 195 195 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); 197 197 return false; 198 198 BondRescale = bondlength; … … 237 237 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin); 238 238 } 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); 240 240 } 241 241 } … … 274 274 bondangle = TopOrigin->type->HBondAngle[1]; 275 275 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); 277 277 return false; 278 278 bondangle = 0; … … 396 396 break; 397 397 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); 399 399 AllWentWell = false; 400 400 break; … … 429 429 input = new istringstream(line); 430 430 *input >> NumberOfAtoms; 431 Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;431 DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl); 432 432 getline(xyzfile,line,'\n'); // Read comment 433 Log() << Verbose(1) << "Comment: " << line << endl;433 DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl); 434 434 435 435 if (MDSteps == 0) // no atoms yet present … … 447 447 Walker->type = elemente->FindElement(shorthand); 448 448 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."); 450 450 Walker->type = elemente->FindElement(1); 451 451 } … … 543 543 add(Binder, last); 544 544 } 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); 546 546 } 547 547 return Binder; … … 555 555 bool molecule::RemoveBond(bond *pointer) 556 556 { 557 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;557 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 558 558 pointer->leftatom->RegisterBond(pointer); 559 559 pointer->rightatom->RegisterBond(pointer); … … 569 569 bool molecule::RemoveBonds(atom *BondPartner) 570 570 { 571 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;571 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 572 572 BondList::const_iterator ForeRunner; 573 573 while (!BondPartner->ListOfBonds.empty()) { … … 603 603 void molecule::SetBoxDimension(Vector *dim) 604 604 { 605 double * const cell_size = World::get()->cell_size; 605 606 cell_size[0] = dim->x[0]; 606 607 cell_size[1] = 0.; … … 621 622 AtomCount--; 622 623 } 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); 624 625 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 625 626 ElementCount--; … … 639 640 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 640 641 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); 642 643 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 643 644 ElementCount--; … … 664 665 return walker; 665 666 } else { 666 Log() << Verbose(0) << "Atom not found in list." << endl;667 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); 667 668 return NULL; 668 669 } … … 680 681 //mol->Output((ofstream *)&cout); 681 682 //Log() << Verbose(0) << "===============================================" << endl; 682 Log() << Verbose(0) << text;683 DoLog(0) && (Log() << Verbose(0) << text); 683 684 cin >> No; 684 685 ion = this->FindAtom(No); … … 693 694 bool molecule::CheckBounds(const Vector *x) const 694 695 { 696 double * const cell_size = World::get()->cell_size; 695 697 bool result = true; 696 698 int j =-1; … … 768 770 void molecule::OutputListOfBonds() const 769 771 { 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); 771 773 ActOnAllAtoms (&atom::OutputBondOfAtom ); 772 Log() << Verbose(0) << endl;774 DoLog(0) && (Log() << Verbose(0) << endl); 773 775 }; 774 776 … … 827 829 } 828 830 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); 830 832 AtomCount = i; 831 833 … … 843 845 Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name"); 844 846 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); 846 848 i++; 847 849 } 848 850 } 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); 850 852 } 851 853 }; … … 907 909 bool result = true; // status of comparison 908 910 909 Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;911 DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl); 910 912 /// first count both their atoms and elements and update lists thereby ... 911 913 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; … … 919 921 if (result) { 920 922 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); 922 924 result = false; 923 925 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl; … … 926 928 if (result) { 927 929 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); 929 931 result = false; 930 932 } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl; … … 938 940 } 939 941 if (flag < MAX_ELEMENTS) { 940 Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;942 DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl); 941 943 result = false; 942 944 } else Log() << Verbose(4) << "ElementsInMolecule match." << endl; … … 944 946 /// then determine and compare center of gravity for each molecule ... 945 947 if (result) { 946 Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;948 DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl); 947 949 DeterminePeriodicCenter(CenterOfGravity); 948 950 OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity); 949 Log() << Verbose(5) << "Center of Gravity: ";951 DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: "); 950 952 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: "); 952 954 OtherCenterOfGravity.Output(); 953 Log() << Verbose(0) << endl;955 DoLog(0) && (Log() << Verbose(0) << endl); 954 956 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); 956 958 result = false; 957 959 } … … 960 962 /// ... then make a list with the euclidian distance to this center for each atom of both molecules 961 963 if (result) { 962 Log() << Verbose(5) << "Calculating distances" << endl;964 DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl); 963 965 Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances"); 964 966 OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances"); … … 967 969 968 970 /// ... 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); 970 972 PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap"); 971 973 OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap"); … … 973 975 gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles); 974 976 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); 976 978 for(int i=AtomCount;i--;) 977 979 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 978 980 979 981 /// ... 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); 981 983 flag = 0; 982 984 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); 984 986 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) 985 987 flag = 1; … … 997 999 } 998 1000 /// 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); 1000 1002 if (result) { 1001 Log() << Verbose(3) << "Result: Equal." << endl;1003 DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl); 1002 1004 return PermutationMap; 1003 1005 } else { 1004 Log() << Verbose(3) << "Result: Not equal." << endl;1006 DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl); 1005 1007 return NULL; 1006 1008 } … … 1017 1019 { 1018 1020 atom *Walker = NULL, *OtherWalker = NULL; 1019 Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;1021 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl); 1020 1022 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap"); 1021 1023 for (int i=AtomCount;i--;) … … 1024 1026 for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence 1025 1027 AtomicMap[i] = i; 1026 Log() << Verbose(4) << "Map is trivial." << endl;1028 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1027 1029 } else { 1028 Log() << Verbose(4) << "Map is ";1030 DoLog(4) && (Log() << Verbose(4) << "Map is "); 1029 1031 Walker = start; 1030 1032 while (Walker->next != end) { … … 1043 1045 } 1044 1046 } 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); 1050 1052 return AtomicMap; 1051 1053 };
Note:
See TracChangeset
for help on using the changeset viewer.