Changeset 47d041 for src/molecule.cpp
- Timestamp:
- Nov 3, 2011, 7:44:01 PM (14 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r50e4e5 r47d041 322 322 bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem) 323 323 { 324 // Info info(__func__); 324 325 bool AllWentWell = true; // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit 325 326 OBSERVE; … … 335 336 bond *Binder = NULL; 336 337 337 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;338 338 // create vector in direction of bond 339 339 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition(); … … 347 347 BG->getMinMaxDistance(TopOrigin,TopReplacement)); 348 348 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 << "."); 352 350 Orthovector1.Zero(); 353 351 for (int i=NDIM;i--;) { … … 360 358 InBondvector -= Orthovector1; // subtract just the additional translation 361 359 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 << "."); 365 361 } // periodic correction finished 366 362 … … 370 366 BondRescale = TopOrigin->getType()->getHBondDistance(TopBond->BondDegree-1); 371 367 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 << "!"); 373 369 return false; 374 370 BondRescale = bondlength; … … 394 390 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom 395 391 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 << "."); 399 393 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1); 400 394 Binder->Cyclic = false; … … 416 410 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin); 417 411 } 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()); 419 413 } 420 414 } … … 426 420 } 427 421 if (FirstOtherAtom != NULL) { // then we just have this double bond and the plane does not matter at all 428 // L og() << 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."); 429 423 430 424 // determine the plane of these two with the *origin … … 433 427 } 434 428 catch(LinearDependenceException &excp){ 435 L og() << Verbose(0) << boost::diagnostic_information(excp);429 LOG(0, boost::diagnostic_information(excp)); 436 430 // TODO: figure out what to do with the Orthovector in this case 437 431 AllWentWell = false; … … 440 434 Orthovector1.GetOneNormalVector(InBondvector); 441 435 } 442 //Log() << Verbose(3)<< "Orthovector1: "; 443 //Orthovector1.Output(out); 444 //Log() << Verbose(0) << endl; 436 //LOG(3, "INFO: Orthovector1: " << Orthovector1 << "."); 445 437 // orthogonal vector and bond vector between origin and replacement form the new plane 446 438 Orthovector1.MakeNormalTo(InBondvector); 447 439 Orthovector1.Normalize(); 448 //L og() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;440 //LOG(3, "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "."); 449 441 450 442 // create the two Hydrogens ... … … 461 453 bondangle = TopOrigin->getType()->getHBondAngle(1); 462 454 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 << "!"); 464 456 return false; 465 457 bondangle = 0; 466 458 } 467 459 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)); 475 462 FirstOtherAtom->Zero(); 476 463 SecondOtherAtom->Zero(); … … 481 468 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance 482 469 SecondOtherAtom->Scale(BondRescale); 483 //L og() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;470 //LOG(3, "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "."); 484 471 *FirstOtherAtom += TopOrigin->getPosition(); 485 472 *SecondOtherAtom += TopOrigin->getPosition(); … … 487 474 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 488 475 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 << "."); 495 478 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1); 496 479 Binder->Cyclic = false; … … 520 503 // we need to vectors orthonormal the InBondvector 521 504 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 << "."); 525 506 try{ 526 507 Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal(); 527 508 } 528 509 catch(LinearDependenceException &excp) { 529 L og() << Verbose(0) << boost::diagnostic_information(excp);510 LOG(0, boost::diagnostic_information(excp)); 530 511 AllWentWell = false; 531 512 } 532 // Log() << Verbose(3) << "Orthovector2: "; 533 // Orthovector2.Output(out); 534 // Log() << Verbose(0) << endl; 513 // LOG(3, "INFO: Orthovector2: " << Orthovector2 << ".") 535 514 536 515 // create correct coordination for the three atoms … … 541 520 f = b/sqrt(3.); // length for Orthvector1 542 521 g = b/2.; // length for Orthvector2 543 // L og() << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;544 // L og() << 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)); 545 524 factors[0] = d; 546 525 factors[1] = f; … … 567 546 AllWentWell = AllWentWell && AddAtom(SecondOtherAtom); 568 547 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 << "."); 578 551 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1); 579 552 Binder->Cyclic = false; … … 587 560 break; 588 561 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!"); 590 563 AllWentWell = false; 591 564 break; 592 565 } 593 566 594 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;595 567 return AllWentWell; 596 568 }; … … 621 593 input = new istringstream(line); 622 594 *input >> NumberOfAtoms; 623 DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);595 LOG(0, "Parsing " << NumberOfAtoms << " atoms in file."); 624 596 getline(xyzfile,line,'\n'); // Read comment 625 DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);597 LOG(1, "Comment: " << line); 626 598 627 599 if (MDSteps == 0) // no atoms yet present … … 632 604 istringstream *item = new istringstream(line); 633 605 //istringstream input(line); 634 //L og() << Verbose(1) << "Reading: " << line << endl;606 //LOG(1, "Reading: " << line); 635 607 *item >> shorthand; 636 608 *item >> x[0]; … … 639 611 Walker->setType(elemente->FindElement(shorthand)); 640 612 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."); 642 614 Walker->setType(1); 643 615 } … … 758 730 bool molecule::RemoveBond(bond *pointer) 759 731 { 760 // DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);732 //ELOG(1, "molecule::RemoveBond: Function not implemented yet."); 761 733 delete(pointer); 762 734 return true; … … 770 742 bool molecule::RemoveBonds(atom *BondPartner) 771 743 { 772 // DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);744 //ELOG(1, "molecule::RemoveBond: Function not implemented yet."); 773 745 BondPartner->removeAllBonds(); 774 746 return false; … … 853 825 break; 854 826 if (iter != end()) { 855 //L og() << Verbose(0) << "Found Atom Nr. " << walker->getNr() << endl;827 //LOG(0, "Found Atom Nr. " << walker->getNr()); 856 828 return (*iter); 857 829 } else { 858 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);830 LOG(0, "Atom not found in list."); 859 831 return NULL; 860 832 } … … 869 841 atom *ion = NULL; 870 842 do { 871 // Log() << Verbose(0) << "============Atom list==========================" <<endl;843 //std::cout << "============Atom list==========================" << std::endl; 872 844 //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; 875 847 cin >> No; 876 848 ion = this->FindAtom(No); … … 1007 979 sstr << (*iter)->getType()->getSymbol() << (*iter)->getNr()+1; 1008 980 (*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() << "."); 1010 982 i++; 1011 983 } … … 1040 1012 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1041 1013 { 1042 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);1014 LOG(3, "Begin of GetFatherAtomicMap."); 1043 1015 int *AtomicMap = new int[getAtomCount()]; 1044 1016 for (int i=getAtomCount();i--;) … … 1047 1019 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence 1048 1020 AtomicMap[i] = i; 1049 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);1021 LOG(4, "Map is trivial."); 1050 1022 } else { 1051 DoLog(4) && (Log() << Verbose(4) << "Map is "); 1023 std::stringstream output; 1024 output << "Map is "; 1052 1025 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1053 1026 if ((*iter)->father == NULL) { … … 1057 1030 //for (int i=0;i<AtomCount;i++) { // search atom 1058 1031 //for (int j=0;j<OtherMolecule->getAtomCount();j++) { 1059 //L og() << 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 << "."); 1060 1033 if ((*iter)->father == (*runner)) 1061 1034 AtomicMap[(*iter)->getNr()] = (*runner)->getNr(); 1062 1035 } 1063 1036 } 1064 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->getNr()] << "\t");1037 output << AtomicMap[(*iter)->getNr()] << "\t"; 1065 1038 } 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."); 1069 1042 return AtomicMap; 1070 1043 };
Note:
See TracChangeset
for help on using the changeset viewer.