Changeset d74077 for src/molecule.cpp
- Timestamp:
- Jul 31, 2010, 3:23:10 PM (15 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, Candidate_v1.7.0, 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:
- 8f4df1
- Parents:
- 5fbaeb
- File:
-
- 1 edited
-
src/molecule.cpp (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r5fbaeb rd74077 206 206 if (pointer != NULL) { 207 207 pointer->sort = &pointer->nr; 208 if (pointer-> type!= NULL) {209 formula += pointer-> type;210 if (pointer-> type->Z != 1)208 if (pointer->getType() != NULL) { 209 formula += pointer->getType(); 210 if (pointer->getType()->Z != 1) 211 211 NoNonHydrogen++; 212 212 if(pointer->getName() == "Unknown"){ 213 213 stringstream sstr; 214 sstr << pointer-> type->symbol << pointer->nr+1;214 sstr << pointer->getType()->symbol << pointer->nr+1; 215 215 pointer->setName(sstr.str()); 216 216 } … … 236 236 walker->nr = last_atom++; // increase number within molecule 237 237 insert(walker); 238 if ((pointer-> type != NULL) && (pointer->type->Z != 1))238 if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1)) 239 239 NoNonHydrogen++; 240 240 retval=walker; … … 294 294 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; 295 295 // create vector in direction of bond 296 InBondvector = TopReplacement-> x - TopOrigin->x;296 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition(); 297 297 bondlength = InBondvector.Norm(); 298 298 … … 306 306 Orthovector1.Zero(); 307 307 for (int i=NDIM;i--;) { 308 l = TopReplacement-> x[i] - TopOrigin->x[i];308 l = TopReplacement->at(i) - TopOrigin->at(i); 309 309 if (fabs(l) > BondDistance) { // is component greater than bond distance 310 310 Orthovector1[i] = (l < 0) ? -1. : +1.; … … 321 321 InBondvector.Normalize(); 322 322 // get typical bond length and store as scale factor for later 323 ASSERT(TopOrigin-> type!= NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");324 BondRescale = TopOrigin-> type->HBondDistance[TopBond->BondDegree-1];323 ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 324 BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1]; 325 325 if (BondRescale == -1) { 326 326 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 336 336 case 1: 337 337 FirstOtherAtom = World::getInstance().createAtom(); // new atom 338 FirstOtherAtom-> type = elemente->FindElement(1); // element is Hydrogen339 FirstOtherAtom-> v = TopReplacement->v; // copy velocity338 FirstOtherAtom->setType(1); // element is Hydrogen 339 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 340 340 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 341 if (TopReplacement-> type->Z == 1) { // neither rescale nor replace if it's already hydrogen341 if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen 342 342 FirstOtherAtom->father = TopReplacement; 343 343 BondRescale = bondlength; … … 346 346 } 347 347 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length 348 FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ... 349 FirstOtherAtom->x += InBondvector; // ... and add distance vector to replacement atom 348 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom 350 349 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 351 350 // Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: "; … … 380 379 // determine the plane of these two with the *origin 381 380 try { 382 Orthovector1 =Plane(TopOrigin-> x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();381 Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal(); 383 382 } 384 383 catch(LinearDependenceException &excp){ … … 401 400 FirstOtherAtom = World::getInstance().createAtom(); 402 401 SecondOtherAtom = World::getInstance().createAtom(); 403 FirstOtherAtom-> type = elemente->FindElement(1);404 SecondOtherAtom-> type = elemente->FindElement(1);405 FirstOtherAtom-> v = TopReplacement->v; // copy velocity402 FirstOtherAtom->setType(1); 403 SecondOtherAtom->setType(1); 404 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 406 405 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 407 SecondOtherAtom-> v = TopReplacement->v; // copy velocity406 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 408 407 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 409 408 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 410 409 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father 411 bondangle = TopOrigin-> type->HBondAngle[1];410 bondangle = TopOrigin->getType()->HBondAngle[1]; 412 411 if (bondangle == -1) { 413 412 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 423 422 // Log() << Verbose(0) << endl; 424 423 // Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl; 425 FirstOtherAtom-> x.Zero();426 SecondOtherAtom-> x.Zero();424 FirstOtherAtom->Zero(); 425 SecondOtherAtom->Zero(); 427 426 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction) 428 FirstOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));429 SecondOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));430 } 431 FirstOtherAtom-> x *= BondRescale; // rescale by correct BondDistance432 SecondOtherAtom-> x *= BondRescale;427 FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle))); 428 SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle))); 429 } 430 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance 431 SecondOtherAtom->Scale(BondRescale); 433 432 //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 434 for(int i=NDIM;i--;) { // and make relative to origin atom 435 FirstOtherAtom->x[i] += TopOrigin->x[i]; 436 SecondOtherAtom->x[i] += TopOrigin->x[i]; 437 } 433 *FirstOtherAtom += TopOrigin->getPosition(); 434 *SecondOtherAtom += TopOrigin->getPosition(); 438 435 // ... and add to molecule 439 436 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); … … 457 454 SecondOtherAtom = World::getInstance().createAtom(); 458 455 ThirdOtherAtom = World::getInstance().createAtom(); 459 FirstOtherAtom-> type = elemente->FindElement(1);460 SecondOtherAtom-> type = elemente->FindElement(1);461 ThirdOtherAtom-> type = elemente->FindElement(1);462 FirstOtherAtom-> v = TopReplacement->v; // copy velocity456 FirstOtherAtom->setType(1); 457 SecondOtherAtom->setType(1); 458 ThirdOtherAtom->setType(1); 459 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 463 460 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 464 SecondOtherAtom-> v = TopReplacement->v; // copy velocity461 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 465 462 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 466 ThirdOtherAtom-> v = TopReplacement->v; // copy velocity463 ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 467 464 ThirdOtherAtom->FixedIon = TopReplacement->FixedIon; 468 465 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 487 484 488 485 // create correct coordination for the three atoms 489 alpha = (TopOrigin-> type->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database486 alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database 490 487 l = BondRescale; // desired bond length 491 488 b = 2.*l*sin(alpha); // base length of isosceles triangle … … 498 495 factors[1] = f; 499 496 factors[2] = 0.; 500 FirstOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);497 FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 501 498 factors[1] = -0.5*f; 502 499 factors[2] = g; 503 SecondOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);500 SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 504 501 factors[2] = -g; 505 ThirdOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);502 ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 506 503 507 504 // rescale each to correct BondDistance … … 511 508 512 509 // and relative to *origin atom 513 FirstOtherAtom->x += TopOrigin->x;514 SecondOtherAtom->x += TopOrigin->x;515 ThirdOtherAtom->x += TopOrigin->x;510 *FirstOtherAtom += TopOrigin->getPosition(); 511 *SecondOtherAtom += TopOrigin->getPosition(); 512 *ThirdOtherAtom += TopOrigin->getPosition(); 516 513 517 514 // ... and add to molecule … … 589 586 *item >> x[1]; 590 587 *item >> x[2]; 591 Walker-> type = elemente->FindElement(shorthand);592 if (Walker-> type== NULL) {588 Walker->setType(elemente->FindElement(shorthand)); 589 if (Walker->getType() == NULL) { 593 590 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 594 Walker-> type = elemente->FindElement(1);591 Walker->setType(1); 595 592 } 596 593 if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) { … … 599 596 Walker->Trajectory.F.resize(MDSteps+10); 600 597 } 598 Walker->setPosition(Vector(x)); 601 599 for(j=NDIM;j--;) { 602 Walker->x[j] = x[j];603 600 Walker->Trajectory.R.at(MDSteps-1)[j] = x[j]; 604 601 Walker->Trajectory.U.at(MDSteps-1)[j] = 0; … … 694 691 atom1->RegisterBond(Binder); 695 692 atom2->RegisterBond(Binder); 696 if ((atom1-> type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))693 if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1)) 697 694 NoNonBonds++; 698 695 … … 768 765 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 769 766 OBSERVE; 770 formula-=pointer-> type;767 formula-=pointer->getType(); 771 768 RemoveBonds(pointer); 772 769 erase(pointer); … … 782 779 if (pointer == NULL) 783 780 return false; 784 formula-=pointer-> type;781 formula-=pointer->getType(); 785 782 erase(pointer); 786 783 return true; … … 969 966 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 970 967 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 971 if ((*iter)-> type->Z != 1) // count non-hydrogen atoms whilst at it968 if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it 972 969 NoNonHydrogen++; 973 970 stringstream sstr; 974 sstr << (*iter)-> type->symbol << (*iter)->nr+1;971 sstr << (*iter)->getType()->symbol << (*iter)->nr+1; 975 972 (*iter)->setName(sstr.str()); 976 973 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.
