Changeset a67d19 for src/molecule.cpp


Ignore:
Timestamp:
Apr 22, 2010, 2:00:03 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
299554
Parents:
6613ec
Message:

Huge change: Log() << Verbose(.) --> DoLog(.) && (Log() << Verbose(.) << ...);

Most of the files are affected, but this is necessary as if DoLog() says verbosity is not enough, all the stream operators won"t get executed which saves substantial amount of computation time.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r6613ec ra67d19  
    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
     
    665665    return walker;
    666666  } else {
    667     Log() << Verbose(0) << "Atom not found in list." << endl;
     667    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
    668668    return NULL;
    669669  }
     
    681681    //mol->Output((ofstream *)&cout);
    682682    //Log() << Verbose(0) << "===============================================" << endl;
    683     Log() << Verbose(0) << text;
     683    DoLog(0) && (Log() << Verbose(0) << text);
    684684    cin >> No;
    685685    ion = this->FindAtom(No);
     
    770770void molecule::OutputListOfBonds() const
    771771{
    772   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);
    773773  ActOnAllAtoms (&atom::OutputBondOfAtom );
    774   Log() << Verbose(0) << endl;
     774  DoLog(0) && (Log() << Verbose(0) << endl);
    775775};
    776776
     
    829829  }
    830830  if ((AtomCount == 0) || (i != AtomCount)) {
    831     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);
    832832    AtomCount = i;
    833833
     
    845845        Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    846846        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    847         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);
    848848        i++;
    849849      }
    850850    } else
    851       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);
    852852  }
    853853};
     
    909909  bool result = true; // status of comparison
    910910
    911   Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
     911  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
    912912  /// first count both their atoms and elements and update lists thereby ...
    913913  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     
    921921  if (result) {
    922922    if (AtomCount != OtherMolecule->AtomCount) {
    923       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);
    924924      result = false;
    925925    } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     
    928928  if (result) {
    929929    if (ElementCount != OtherMolecule->ElementCount) {
    930       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);
    931931      result = false;
    932932    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     
    940940    }
    941941    if (flag < MAX_ELEMENTS) {
    942       Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;
     942      DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
    943943      result = false;
    944944    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
     
    946946  /// then determine and compare center of gravity for each molecule ...
    947947  if (result) {
    948     Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;
     948    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
    949949    DeterminePeriodicCenter(CenterOfGravity);
    950950    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    951     Log() << Verbose(5) << "Center of Gravity: ";
     951    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: ");
    952952    CenterOfGravity.Output();
    953     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
     953    DoLog(0) && (Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ");
    954954    OtherCenterOfGravity.Output();
    955     Log() << Verbose(0) << endl;
     955    DoLog(0) && (Log() << Verbose(0) << endl);
    956956    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    957       Log() << Verbose(4) << "Centers of gravity don't match." << endl;
     957      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
    958958      result = false;
    959959    }
     
    962962  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
    963963  if (result) {
    964     Log() << Verbose(5) << "Calculating distances" << endl;
     964    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    965965    Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    966966    OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     
    969969
    970970    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    971     Log() << Verbose(5) << "Sorting distances" << endl;
     971    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    972972    PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    973973    OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     
    975975    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    976976    PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
    977     Log() << Verbose(5) << "Combining Permutation Maps" << endl;
     977    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    978978    for(int i=AtomCount;i--;)
    979979      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    980980
    981981    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
    982     Log() << Verbose(4) << "Comparing distances" << endl;
     982    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    983983    flag = 0;
    984984    for (int i=0;i<AtomCount;i++) {
    985       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);
    986986      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
    987987        flag = 1;
     
    999999  }
    10001000  /// return pointer to map if all distances were below \a threshold
    1001   Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
     1001  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
    10021002  if (result) {
    1003     Log() << Verbose(3) << "Result: Equal." << endl;
     1003    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
    10041004    return PermutationMap;
    10051005  } else {
    1006     Log() << Verbose(3) << "Result: Not equal." << endl;
     1006    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
    10071007    return NULL;
    10081008  }
     
    10191019{
    10201020  atom *Walker = NULL, *OtherWalker = NULL;
    1021   Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
     1021  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    10221022  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    10231023  for (int i=AtomCount;i--;)
     
    10261026    for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
    10271027      AtomicMap[i] = i;
    1028     Log() << Verbose(4) << "Map is trivial." << endl;
     1028    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    10291029  } else {
    1030     Log() << Verbose(4) << "Map is ";
     1030    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    10311031    Walker = start;
    10321032    while (Walker->next != end) {
     
    10451045        }
    10461046      }
    1047       Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
    1048     }
    1049     Log() << Verbose(0) << endl;
    1050   }
    1051   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);
    10521052  return AtomicMap;
    10531053};
Note: See TracChangeset for help on using the changeset viewer.