Changeset 8f4df1 for src/molecule.cpp
- Timestamp:
- Aug 7, 2010, 12:07:04 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:
- 2d292d
- Parents:
- 8d6d31 (diff), d74077 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/molecule.cpp (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r8d6d31 r8f4df1 157 157 atomIds.erase( atom->getId() ); 158 158 atoms.remove( atom ); 159 formula-=atom-> type;159 formula-=atom->getType(); 160 160 atom->removeFromMolecule(); 161 161 return iter; … … 169 169 atomIds.erase( key->getId() ); 170 170 atoms.remove( key ); 171 formula-=key-> type;171 formula-=key->getType(); 172 172 key->removeFromMolecule(); 173 173 } … … 191 191 if (res.second) { // push atom if went well 192 192 atoms.push_back(key); 193 formula+=key-> type;193 formula+=key->getType(); 194 194 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 195 195 } else { … … 212 212 if (pointer != NULL) { 213 213 pointer->sort = &pointer->nr; 214 if (pointer-> type!= NULL) {215 formula += pointer-> type;216 if (pointer-> type->Z != 1)214 if (pointer->getType() != NULL) { 215 formula += pointer->getType(); 216 if (pointer->getType()->Z != 1) 217 217 NoNonHydrogen++; 218 218 if(pointer->getName() == "Unknown"){ 219 219 stringstream sstr; 220 sstr << pointer-> type->symbol << pointer->nr+1;220 sstr << pointer->getType()->symbol << pointer->nr+1; 221 221 pointer->setName(sstr.str()); 222 222 } … … 239 239 if (pointer != NULL) { 240 240 atom *walker = pointer->clone(); 241 formula += walker-> type;241 formula += walker->getType(); 242 242 walker->setName(pointer->getName()); 243 243 walker->nr = last_atom++; // increase number within molecule 244 244 insert(walker); 245 if ((pointer-> type != NULL) && (pointer->type->Z != 1))245 if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1)) 246 246 NoNonHydrogen++; 247 247 retval=walker; … … 301 301 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; 302 302 // create vector in direction of bond 303 InBondvector = TopReplacement-> x - TopOrigin->x;303 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition(); 304 304 bondlength = InBondvector.Norm(); 305 305 … … 313 313 Orthovector1.Zero(); 314 314 for (int i=NDIM;i--;) { 315 l = TopReplacement-> x[i] - TopOrigin->x[i];315 l = TopReplacement->at(i) - TopOrigin->at(i); 316 316 if (fabs(l) > BondDistance) { // is component greater than bond distance 317 317 Orthovector1[i] = (l < 0) ? -1. : +1.; … … 328 328 InBondvector.Normalize(); 329 329 // get typical bond length and store as scale factor for later 330 ASSERT(TopOrigin-> type!= NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");331 BondRescale = TopOrigin-> type->HBondDistance[TopBond->BondDegree-1];330 ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 331 BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1]; 332 332 if (BondRescale == -1) { 333 333 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 343 343 case 1: 344 344 FirstOtherAtom = World::getInstance().createAtom(); // new atom 345 FirstOtherAtom-> type = elemente->FindElement(1); // element is Hydrogen346 FirstOtherAtom-> v = TopReplacement->v; // copy velocity345 FirstOtherAtom->setType(1); // element is Hydrogen 346 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 347 347 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 348 if (TopReplacement-> type->Z == 1) { // neither rescale nor replace if it's already hydrogen348 if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen 349 349 FirstOtherAtom->father = TopReplacement; 350 350 BondRescale = bondlength; … … 353 353 } 354 354 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length 355 FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ... 356 FirstOtherAtom->x += InBondvector; // ... and add distance vector to replacement atom 355 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom 357 356 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 358 357 // Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: "; … … 387 386 // determine the plane of these two with the *origin 388 387 try { 389 Orthovector1 =Plane(TopOrigin-> x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();388 Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal(); 390 389 } 391 390 catch(LinearDependenceException &excp){ … … 408 407 FirstOtherAtom = World::getInstance().createAtom(); 409 408 SecondOtherAtom = World::getInstance().createAtom(); 410 FirstOtherAtom-> type = elemente->FindElement(1);411 SecondOtherAtom-> type = elemente->FindElement(1);412 FirstOtherAtom-> v = TopReplacement->v; // copy velocity409 FirstOtherAtom->setType(1); 410 SecondOtherAtom->setType(1); 411 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 413 412 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 414 SecondOtherAtom-> v = TopReplacement->v; // copy velocity413 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 415 414 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 416 415 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 417 416 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father 418 bondangle = TopOrigin-> type->HBondAngle[1];417 bondangle = TopOrigin->getType()->HBondAngle[1]; 419 418 if (bondangle == -1) { 420 419 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 430 429 // Log() << Verbose(0) << endl; 431 430 // Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl; 432 FirstOtherAtom-> x.Zero();433 SecondOtherAtom-> x.Zero();431 FirstOtherAtom->Zero(); 432 SecondOtherAtom->Zero(); 434 433 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction) 435 FirstOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));436 SecondOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));437 } 438 FirstOtherAtom-> x *= BondRescale; // rescale by correct BondDistance439 SecondOtherAtom-> x *= BondRescale;434 FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle))); 435 SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle))); 436 } 437 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance 438 SecondOtherAtom->Scale(BondRescale); 440 439 //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 441 for(int i=NDIM;i--;) { // and make relative to origin atom 442 FirstOtherAtom->x[i] += TopOrigin->x[i]; 443 SecondOtherAtom->x[i] += TopOrigin->x[i]; 444 } 440 *FirstOtherAtom += TopOrigin->getPosition(); 441 *SecondOtherAtom += TopOrigin->getPosition(); 445 442 // ... and add to molecule 446 443 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); … … 464 461 SecondOtherAtom = World::getInstance().createAtom(); 465 462 ThirdOtherAtom = World::getInstance().createAtom(); 466 FirstOtherAtom-> type = elemente->FindElement(1);467 SecondOtherAtom-> type = elemente->FindElement(1);468 ThirdOtherAtom-> type = elemente->FindElement(1);469 FirstOtherAtom-> v = TopReplacement->v; // copy velocity463 FirstOtherAtom->setType(1); 464 SecondOtherAtom->setType(1); 465 ThirdOtherAtom->setType(1); 466 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 470 467 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 471 SecondOtherAtom-> v = TopReplacement->v; // copy velocity468 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 472 469 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 473 ThirdOtherAtom-> v = TopReplacement->v; // copy velocity470 ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 474 471 ThirdOtherAtom->FixedIon = TopReplacement->FixedIon; 475 472 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 494 491 495 492 // create correct coordination for the three atoms 496 alpha = (TopOrigin-> type->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database493 alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database 497 494 l = BondRescale; // desired bond length 498 495 b = 2.*l*sin(alpha); // base length of isosceles triangle … … 505 502 factors[1] = f; 506 503 factors[2] = 0.; 507 FirstOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);504 FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 508 505 factors[1] = -0.5*f; 509 506 factors[2] = g; 510 SecondOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);507 SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 511 508 factors[2] = -g; 512 ThirdOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);509 ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 513 510 514 511 // rescale each to correct BondDistance … … 518 515 519 516 // and relative to *origin atom 520 FirstOtherAtom->x += TopOrigin->x;521 SecondOtherAtom->x += TopOrigin->x;522 ThirdOtherAtom->x += TopOrigin->x;517 *FirstOtherAtom += TopOrigin->getPosition(); 518 *SecondOtherAtom += TopOrigin->getPosition(); 519 *ThirdOtherAtom += TopOrigin->getPosition(); 523 520 524 521 // ... and add to molecule … … 596 593 *item >> x[1]; 597 594 *item >> x[2]; 598 Walker-> type = elemente->FindElement(shorthand);599 if (Walker-> type== NULL) {595 Walker->setType(elemente->FindElement(shorthand)); 596 if (Walker->getType() == NULL) { 600 597 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 601 Walker-> type = elemente->FindElement(1);598 Walker->setType(1); 602 599 } 603 600 if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) { … … 606 603 Walker->Trajectory.F.resize(MDSteps+10); 607 604 } 605 Walker->setPosition(Vector(x)); 608 606 for(j=NDIM;j--;) { 609 Walker->x[j] = x[j];610 607 Walker->Trajectory.R.at(MDSteps-1)[j] = x[j]; 611 608 Walker->Trajectory.U.at(MDSteps-1)[j] = 0; … … 702 699 atom1->RegisterBond(Binder); 703 700 atom2->RegisterBond(Binder); 704 if ((atom1-> type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))701 if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1)) 705 702 NoNonBonds++; 706 703 … … 776 773 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 777 774 OBSERVE; 778 formula-=pointer-> type;775 formula-=pointer->getType(); 779 776 RemoveBonds(pointer); 780 777 erase(pointer); … … 790 787 if (pointer == NULL) 791 788 return false; 792 formula-=pointer-> type;789 formula-=pointer->getType(); 793 790 erase(pointer); 794 791 return true; … … 972 969 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 973 970 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 974 if ((*iter)-> type->Z != 1) // count non-hydrogen atoms whilst at it971 if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it 975 972 NoNonHydrogen++; 976 973 stringstream sstr; 977 sstr << (*iter)-> type->symbol << (*iter)->nr+1;974 sstr << (*iter)->getType()->symbol << (*iter)->nr+1; 978 975 (*iter)->setName(sstr.str()); 979 976 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.
