Changeset 47d041 for src/molecule.cpp


Ignore:
Timestamp:
Nov 3, 2011, 7:44:01 PM (14 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:
41a467
Parents:
50e4e5
git-author:
Frederik Heber <heber@…> (10/27/11 11:53:58)
git-committer:
Frederik Heber <heber@…> (11/03/11 19:44:01)
Message:

HUGE: Removed all calls to Log(), eLog(), replaced by LOG() and ELOG().

  • Replaced DoLog(.) && (Log() << Verbose(.) << ... << std::endl) by Log(., ...).
  • Replaced Log() << Verbose(.) << .. << by Log(., ...)
  • on multiline used stringstream to generate and message which was finally used in LOG(., output.str())
  • there should be no more occurence of Log(). LOG() and ELOG() must be used instead.
  • Eventually, this will allow for storing all errors and re-printing them on program exit which would be very helpful to ascertain error-free runs for the user.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r50e4e5 r47d041  
    322322bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
    323323{
     324//  Info info(__func__);
    324325  bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
    325326  OBSERVE;
     
    335336  bond *Binder = NULL;
    336337
    337 //  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    338338  // create vector in direction of bond
    339339  InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
     
    347347      BG->getMinMaxDistance(TopOrigin,TopReplacement));
    348348  if (!MinMaxBondDistance.isInRange(bondlength)) {
    349 //    Log() << Verbose(4) << "InBondvector is: ";
    350 //    InBondvector.Output(out);
    351 //    Log() << Verbose(0) << endl;
     349//    LOG(4, "InBondvector is: " << InBondvector << ".");
    352350    Orthovector1.Zero();
    353351    for (int i=NDIM;i--;) {
     
    360358    InBondvector -= Orthovector1; // subtract just the additional translation
    361359    bondlength = InBondvector.Norm();
    362 //    Log() << Verbose(4) << "Corrected InBondvector is now: ";
    363 //    InBondvector.Output(out);
    364 //    Log() << Verbose(0) << endl;
     360//    LOG(4, "INFO: Corrected InBondvector is now: " << InBondvector << ".");
    365361  } // periodic correction finished
    366362
     
    370366  BondRescale = TopOrigin->getType()->getHBondDistance(TopBond->BondDegree-1);
    371367  if (BondRescale == -1) {
    372     DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     368    ELOG(1, "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!");
    373369    return false;
    374370    BondRescale = bondlength;
     
    394390      FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
    395391      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    396 //      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    397 //      FirstOtherAtom->x.Output(out);
    398 //      Log() << Verbose(0) << endl;
     392//      LOG(4, "INFO: Added " << *FirstOtherAtom << " at: " << FirstOtherAtom->x << ".");
    399393      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    400394      Binder->Cyclic = false;
     
    416410              SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    417411            } else {
    418               DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName());
     412              ELOG(2, "Detected more than four bonds for atom " << TopOrigin->getName());
    419413            }
    420414          }
     
    426420      }
    427421      if (FirstOtherAtom != NULL) { // then we just have this double bond and the plane does not matter at all
    428 //        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;
     422//        LOG(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.");
    429423
    430424        // determine the plane of these two with the *origin
     
    433427        }
    434428        catch(LinearDependenceException &excp){
    435           Log() << Verbose(0) << boost::diagnostic_information(excp);
     429          LOG(0, boost::diagnostic_information(excp));
    436430          // TODO: figure out what to do with the Orthovector in this case
    437431          AllWentWell = false;
     
    440434        Orthovector1.GetOneNormalVector(InBondvector);
    441435      }
    442       //Log() << Verbose(3)<< "Orthovector1: ";
    443       //Orthovector1.Output(out);
    444       //Log() << Verbose(0) << endl;
     436      //LOG(3, "INFO: Orthovector1: " << Orthovector1 << ".");
    445437      // orthogonal vector and bond vector between origin and replacement form the new plane
    446438      Orthovector1.MakeNormalTo(InBondvector);
    447439      Orthovector1.Normalize();
    448       //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
     440      //LOG(3, "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << ".");
    449441
    450442      // create the two Hydrogens ...
     
    461453      bondangle = TopOrigin->getType()->getHBondAngle(1);
    462454      if (bondangle == -1) {
    463         DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     455        ELOG(1, "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!");
    464456        return false;
    465457        bondangle = 0;
    466458      }
    467459      bondangle *= M_PI/180./2.;
    468 //      Log() << Verbose(3) << "ReScaleCheck: InBondvector ";
    469 //      InBondvector.Output(out);
    470 //      Log() << Verbose(0) << endl;
    471 //      Log() << Verbose(3) << "ReScaleCheck: Orthovector ";
    472 //      Orthovector1.Output(out);
    473 //      Log() << Verbose(0) << endl;
    474 //      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
     460//      LOG(3, "INFO: ReScaleCheck: InBondvector " << InBondvector << ", " << Orthovector1 << ".");
     461//      LOG(3, "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle));
    475462      FirstOtherAtom->Zero();
    476463      SecondOtherAtom->Zero();
     
    481468      FirstOtherAtom->Scale(BondRescale);  // rescale by correct BondDistance
    482469      SecondOtherAtom->Scale(BondRescale);
    483       //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
     470      //LOG(3, "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << ".");
    484471      *FirstOtherAtom += TopOrigin->getPosition();
    485472      *SecondOtherAtom += TopOrigin->getPosition();
     
    487474      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    488475      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
    489 //      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    490 //      FirstOtherAtom->x.Output(out);
    491 //      Log() << Verbose(0) << endl;
    492 //      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
    493 //      SecondOtherAtom->x.Output(out);
    494 //      Log() << Verbose(0) << endl;
     476//      LOG(4, "INFO: Added " << *FirstOtherAtom << " at: " << FirstOtherAtom->x << ".");
     477//      LOG(4, "INFO: Added " << *SecondOtherAtom << " at: " << SecondOtherAtom->x << ".");
    495478      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    496479      Binder->Cyclic = false;
     
    520503      // we need to vectors orthonormal the InBondvector
    521504      AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(InBondvector);
    522 //      Log() << Verbose(3) << "Orthovector1: ";
    523 //      Orthovector1.Output(out);
    524 //      Log() << Verbose(0) << endl;
     505//      LOG(3, "INFO: Orthovector1: " << Orthovector1 << ".");
    525506      try{
    526507        Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal();
    527508      }
    528509      catch(LinearDependenceException &excp) {
    529         Log() << Verbose(0) << boost::diagnostic_information(excp);
     510        LOG(0, boost::diagnostic_information(excp));
    530511        AllWentWell = false;
    531512      }
    532 //      Log() << Verbose(3) << "Orthovector2: ";
    533 //      Orthovector2.Output(out);
    534 //      Log() << Verbose(0) << endl;
     513//      LOG(3, "INFO: Orthovector2: " << Orthovector2 << ".")
    535514
    536515      // create correct coordination for the three atoms
     
    541520      f = b/sqrt(3.);   // length for Orthvector1
    542521      g = b/2.;         // length for Orthvector2
    543 //      Log() << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;
    544 //      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;
     522//      LOG(3, "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", ");
     523//      LOG(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));
    545524      factors[0] = d;
    546525      factors[1] = f;
     
    567546      AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
    568547      AllWentWell = AllWentWell && AddAtom(ThirdOtherAtom);
    569 //      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
    570 //      FirstOtherAtom->x.Output(out);
    571 //      Log() << Verbose(0) << endl;
    572 //      Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
    573 //      SecondOtherAtom->x.Output(out);
    574 //      Log() << Verbose(0) << endl;
    575 //      Log() << Verbose(4) << "Added " << *ThirdOtherAtom << " at: ";
    576 //      ThirdOtherAtom->x.Output(out);
    577 //      Log() << Verbose(0) << endl;
     548//      LOG(4, "INFO: Added " << *FirstOtherAtom << " at: " << FirstOtherAtom->x << ".");
     549//      LOG(4, "INFO: Added " << *SecondOtherAtom << " at: " << SecondOtherAtom->x << ".");
     550//      LOG(4, "INFO: Added " << *ThirdOtherAtom << " at: " << ThirdOtherAtom->x << ".");
    578551      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    579552      Binder->Cyclic = false;
     
    587560      break;
    588561    default:
    589       DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
     562      ELOG(1, "BondDegree does not state single, double or triple bond!");
    590563      AllWentWell = false;
    591564      break;
    592565  }
    593566
    594 //  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
    595567  return AllWentWell;
    596568};
     
    621593  input = new istringstream(line);
    622594  *input >> NumberOfAtoms;
    623   DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
     595  LOG(0, "Parsing " << NumberOfAtoms << " atoms in file.");
    624596  getline(xyzfile,line,'\n'); // Read comment
    625   DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
     597  LOG(1, "Comment: " << line);
    626598
    627599  if (MDSteps == 0) // no atoms yet present
     
    632604    istringstream *item = new istringstream(line);
    633605    //istringstream input(line);
    634     //Log() << Verbose(1) << "Reading: " << line << endl;
     606    //LOG(1, "Reading: " << line);
    635607    *item >> shorthand;
    636608    *item >> x[0];
     
    639611    Walker->setType(elemente->FindElement(shorthand));
    640612    if (Walker->getType() == NULL) {
    641       DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
     613      ELOG(1, "Could not parse the element at line: '" << line << "', setting to H.");
    642614      Walker->setType(1);
    643615    }
     
    758730bool molecule::RemoveBond(bond *pointer)
    759731{
    760   //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
     732  //ELOG(1, "molecule::RemoveBond: Function not implemented yet.");
    761733  delete(pointer);
    762734  return true;
     
    770742bool molecule::RemoveBonds(atom *BondPartner)
    771743{
    772   //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
     744  //ELOG(1, "molecule::RemoveBond: Function not implemented yet.");
    773745  BondPartner->removeAllBonds();
    774746  return false;
     
    853825      break;
    854826  if (iter != end()) {
    855     //Log() << Verbose(0) << "Found Atom Nr. " << walker->getNr() << endl;
     827    //LOG(0, "Found Atom Nr. " << walker->getNr());
    856828    return (*iter);
    857829  } else {
    858     DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
     830    LOG(0, "Atom not found in list.");
    859831    return NULL;
    860832  }
     
    869841  atom *ion = NULL;
    870842  do {
    871     //Log() << Verbose(0) << "============Atom list==========================" << endl;
     843    //std::cout << "============Atom list==========================" << std::endl;
    872844    //mol->Output((ofstream *)&cout);
    873     //Log() << Verbose(0) << "===============================================" << endl;
    874     DoLog(0) && (Log() << Verbose(0) << text);
     845    //std::cout << "===============================================" << std::endl;
     846    std::cout << text;
    875847    cin >> No;
    876848    ion = this->FindAtom(No);
     
    1007979    sstr << (*iter)->getType()->getSymbol() << (*iter)->getNr()+1;
    1008980    (*iter)->setName(sstr.str());
    1009     DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->getNr() << " " << (*iter)->getName() << "." << endl);
     981    LOG(3, "Naming atom nr. " << (*iter)->getNr() << " " << (*iter)->getName() << ".");
    1010982    i++;
    1011983  }
     
    10401012int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10411013{
    1042   DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
     1014  LOG(3, "Begin of GetFatherAtomicMap.");
    10431015  int *AtomicMap = new int[getAtomCount()];
    10441016  for (int i=getAtomCount();i--;)
     
    10471019    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
    10481020      AtomicMap[i] = i;
    1049     DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
     1021    LOG(4, "Map is trivial.");
    10501022  } else {
    1051     DoLog(4) && (Log() << Verbose(4) << "Map is ");
     1023    std::stringstream output;
     1024    output << "Map is ";
    10521025    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    10531026      if ((*iter)->father == NULL) {
     
    10571030      //for (int i=0;i<AtomCount;i++) { // search atom
    10581031        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
    1059           //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
     1032          //LOG(4, "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << ".");
    10601033          if ((*iter)->father == (*runner))
    10611034            AtomicMap[(*iter)->getNr()] = (*runner)->getNr();
    10621035        }
    10631036      }
    1064       DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->getNr()] << "\t");
     1037      output << AtomicMap[(*iter)->getNr()] << "\t";
    10651038    }
    1066     DoLog(0) && (Log() << Verbose(0) << endl);
    1067   }
    1068   DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
     1039    LOG(4, output.str());
     1040  }
     1041  LOG(3, "End of GetFatherAtomicMap.");
    10691042  return AtomicMap;
    10701043};
Note: See TracChangeset for help on using the changeset viewer.