- Timestamp:
- Sep 9, 2014, 7:42:32 PM (11 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:
- a090e3
- Parents:
- 2d701e
- git-author:
- Frederik Heber <heber@…> (09/01/14 15:54:02)
- git-committer:
- Frederik Heber <heber@…> (09/09/14 19:42:32)
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FillAction/FillSurfaceAction.cpp
r2d701e r833b15 81 81 82 82 // center filler's tip at origin 83 Vector max; 84 filler->CenterEdge(&max); 83 filler->CenterEdge(); 85 84 86 85 // determine center with respect to alignment axis … … 96 95 { 97 96 Vector translater = -1.*sum; 98 filler->Translate( &translater);97 filler->Translate(translater); 99 98 } 100 99 -
src/Actions/MoleculeAction/CopyAction.cpp
r2d701e r833b15 63 63 iter != World::getInstance().endMoleculeSelection(); ++iter) { 64 64 molecule * const copy = (iter->second)->CopyMolecule(); 65 Vector *Center = (iter->second)->DetermineCenterOfAll();66 *Center *= -1.;67 *Center += params.position.get();65 Vector Center = (iter->second)->DetermineCenterOfAll(); 66 Center *= -1.; 67 Center += params.position.get(); 68 68 copy->Translate(Center); 69 delete(Center);70 69 molecules.push_back(copy->getId()); 71 70 } -
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
r2d701e r833b15 74 74 75 75 // Creation Line that is the rotation axis 76 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 77 LOG(0, "Center of gravity is " << *CenterOfGravity << "."); 78 Line RotationAxis(*CenterOfGravity, params.Axis.get()); 79 delete(CenterOfGravity); 76 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 77 LOG(0, "Center of gravity is " << CenterOfGravity << "."); 78 Line RotationAxis(CenterOfGravity, params.Axis.get()); 80 79 LOG(0, "Rotate " << mol->getName() << " around self by " << params.angle.get() << " radian around axis " << RotationAxis << "."); 81 80 … … 93 92 94 93 BOOST_FOREACH(molecule *mol, state->selectedMolecules) { 95 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 96 LOG(0, "Center of gravity is " << *CenterOfGravity << "."); 97 Line RotationAxis(*CenterOfGravity, state->params.Axis.get()); 98 delete(CenterOfGravity); 94 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 95 LOG(0, "Center of gravity is " <<CenterOfGravity << "."); 96 Line RotationAxis(CenterOfGravity, state->params.Axis.get()); 99 97 LOG(0, "Rotate " << mol->getName() << " around self by " << -state->params.angle.get() << " radian around axis " << RotationAxis << "."); 100 98 … … 111 109 112 110 BOOST_FOREACH(molecule *mol, state->selectedMolecules) { 113 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 114 LOG(0, "Center of gravity is " << *CenterOfGravity << "."); 115 Line RotationAxis(*CenterOfGravity, state->params.Axis.get()); 116 delete(CenterOfGravity); 111 const Vector CenterOfGravity = mol->DetermineCenterOfGravity(); 112 LOG(0, "Center of gravity is " << CenterOfGravity << "."); 113 Line RotationAxis(CenterOfGravity, state->params.Axis.get()); 117 114 LOG(0, "Rotate " << mol->getName() << " around self by " << state->params.angle.get() << " radian around axis " << RotationAxis << "."); 118 115 -
src/Analysis/unittests/CountBondsUnitTest.cpp
r2d701e r833b15 148 148 void CountBondsTest::HydrogenBridgeBondsTest() 149 149 { 150 double *mirror = new double[3];150 double mirror[3]; 151 151 CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles"); 152 152 for (int i=0;i<3;i++) … … 161 161 cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl; 162 162 Translator = Vector(3,0,0); 163 TestMolecule1->Translate( &Translator);163 TestMolecule1->Translate(Translator); 164 164 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 165 165 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 166 166 Translator = Vector(-3,0,0); 167 TestMolecule1->Translate( &Translator);167 TestMolecule1->Translate(Translator); 168 168 169 169 cout << "Case 2: offset of (0,3,0), hence angle are (14.5, 165.5, 90) < 30 (only three, because other 90 is missing due to first H01 only fulfilling H-bond criteria)." << endl; 170 170 Translator = Vector(0,3,0); 171 TestMolecule1->Translate( &Translator);171 TestMolecule1->Translate(Translator); 172 172 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 173 173 Translator = Vector(0,-3,0); 174 TestMolecule1->Translate( &Translator);174 TestMolecule1->Translate(Translator); 175 175 176 176 cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl; 177 177 Translator = Vector(0,-3,0); 178 TestMolecule1->Scale( (const double ** const)&mirror);179 TestMolecule1->Translate( &Translator);178 TestMolecule1->Scale(&mirror[0]); 179 TestMolecule1->Translate(Translator); 180 180 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 181 181 Translator = Vector(0,3,0); 182 TestMolecule1->Translate( &Translator);183 TestMolecule1->Scale( (const double ** const)&mirror);182 TestMolecule1->Translate(Translator); 183 TestMolecule1->Scale(&mirror[0]); 184 184 185 185 cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl; 186 186 Translator = Vector(2,1,0); 187 TestMolecule1->Translate( &Translator);187 TestMolecule1->Translate(Translator); 188 188 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 189 189 Translator = Vector(-2,-1,0); 190 TestMolecule1->Translate( &Translator);190 TestMolecule1->Translate(Translator); 191 191 192 192 cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl; 193 193 Translator = Vector(0,0,3); 194 TestMolecule1->Translate( &Translator);194 TestMolecule1->Translate(Translator); 195 195 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 196 196 Translator = Vector(0,0,-3); 197 TestMolecule1->Translate( &Translator);197 TestMolecule1->Translate(Translator); 198 198 199 199 cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl; 200 200 Translator = Vector(-3,0,0); 201 TestMolecule1->Scale( (const double ** const)&mirror);202 TestMolecule1->Translate( &Translator);201 TestMolecule1->Scale(&mirror[0]); 202 TestMolecule1->Translate(Translator); 203 203 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 204 204 Translator = Vector(3,0,0); 205 TestMolecule1->Translate( &Translator);206 TestMolecule1->Scale( (const double ** const)&mirror);205 TestMolecule1->Translate(Translator); 206 TestMolecule1->Scale(&mirror[0]); 207 207 208 208 cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl; 209 209 Translator = Vector(3,0,0); 210 TestMolecule1->Scale( (const double ** const)&mirror);211 TestMolecule1->Translate( &Translator);210 TestMolecule1->Scale(&mirror[0]); 211 TestMolecule1->Translate(Translator); 212 212 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 213 213 Translator = Vector(-3,0,0); 214 TestMolecule1->Translate( &Translator);215 TestMolecule1->Scale( (const double ** const)&mirror);214 TestMolecule1->Translate(Translator); 215 TestMolecule1->Scale(&mirror[0]); 216 216 217 217 cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl; 218 218 Translator = Vector(0,3,0); 219 TestMolecule1->Scale( (const double ** const)&mirror);220 TestMolecule1->Translate( &Translator);219 TestMolecule1->Scale(&mirror[0]); 220 TestMolecule1->Translate(Translator); 221 221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 222 222 Translator = Vector(0,-3,0); 223 TestMolecule1->Translate(&Translator); 224 TestMolecule1->Scale((const double ** const)&mirror); 225 226 delete[](mirror); 227 }; 223 TestMolecule1->Translate(Translator); 224 TestMolecule1->Scale(&mirror[0]); 225 }; -
src/Tesselation/boundary.cpp
r2d701e r833b15 183 183 LineMap LinesOnBoundary; 184 184 TriangleMap TrianglesOnBoundary; 185 Vector *MolCenter = mol->DetermineCenterOfAll();185 Vector MolCenter = mol->DetermineCenterOfAll(); 186 186 Vector helper; 187 187 BoundariesTestPair BoundaryTestPair; … … 207 207 // Boundaries stores non-const TesselPoint ref, hence we need iterator here 208 208 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 209 ProjectedVector = (*iter)->getPosition() - ( *MolCenter);209 ProjectedVector = (*iter)->getPosition() - (MolCenter); 210 210 ProjectedVector.ProjectOntoPlane(AxisVector); 211 211 … … 233 233 LOG(2, "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "."); 234 234 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 235 helper = (*iter)->getPosition() - ( *MolCenter);235 helper = (*iter)->getPosition() - (MolCenter); 236 236 const double oldhelperNorm = helper.NormSquared(); 237 helper = BoundaryTestPair.first->second.second->getPosition() - ( *MolCenter);237 helper = BoundaryTestPair.first->second.second->getPosition() - (MolCenter); 238 238 if (helper.NormSquared() < oldhelperNorm) { 239 239 BoundaryTestPair.first->second.second = (*iter); … … 289 289 { 290 290 Vector SideA, SideB, SideC, SideH; 291 SideA = left->second.second->getPosition() - ( *MolCenter);291 SideA = left->second.second->getPosition() - (MolCenter); 292 292 SideA.ProjectOntoPlane(AxisVector); 293 293 // LOG(1, "SideA: " << SideA); 294 294 295 SideB = right->second.second->getPosition() -( *MolCenter);295 SideB = right->second.second->getPosition() -(MolCenter); 296 296 SideB.ProjectOntoPlane(AxisVector); 297 297 // LOG(1, "SideB: " << SideB); … … 301 301 // LOG(1, "SideC: " << SideC); 302 302 303 SideH = runner->second.second->getPosition() -( *MolCenter);303 SideH = runner->second.second->getPosition() -(MolCenter); 304 304 SideH.ProjectOntoPlane(AxisVector); 305 305 // LOG(1, "SideH: " << SideH); … … 329 329 } while (flag); 330 330 } 331 delete(MolCenter);332 331 return BoundaryPoints; 333 332 }; … … 726 725 for (int i = 0; i < NDIM; i++) 727 726 BoxLengths[i] = GreatestDiameter[i]; 728 mol->CenterEdge( &BoxLengths);727 mol->CenterEdge(); 729 728 } else { 730 729 BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]); … … 749 748 // set new box dimensions 750 749 LOG(0, "Translating to box with these boundaries."); 751 mol->SetBoxDimension(&BoxLengths); 750 { 751 RealSpaceMatrix domain; 752 for(int i =0; i<NDIM;++i) 753 domain.at(i,i) = BoxLengths[i]; 754 World::getInstance().setDomain(domain); 755 } 752 756 mol->CenterInBox(); 753 757 } 754 758 delete[] GreatestDiameter; 755 759 // update Box of atoms by boundary 756 mol->SetBoxDimension(&BoxLengths); 760 { 761 RealSpaceMatrix domain; 762 for(int i =0; i<NDIM;++i) 763 domain.at(i,i) = BoxLengths[i]; 764 World::getInstance().setDomain(domain); 765 } 757 766 LOG(0, "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3."); 758 767 }; … … 804 813 805 814 // Center filler at origin 806 filler->CenterEdge( &Inserter);815 filler->CenterEdge(); 807 816 const int FillerCount = filler->getAtomCount(); 808 817 LOG(2, "INFO: Filler molecule has the following bonds:"); … … 1099 1108 1100 1109 // Center filler at its center of gravity 1101 Vector *gravity = filler->DetermineCenterOfGravity();1110 const Vector gravity = filler->DetermineCenterOfGravity(); 1102 1111 filler->CenterAtVector(gravity); 1103 delete gravity;1104 1112 //const int FillerCount = filler->getAtomCount(); 1105 1113 LOG(2, "INFO: Filler molecule has the following bonds:"); … … 1165 1173 RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random); 1166 1174 // translation 1167 Filling->Translate( &Inserter);1175 Filling->Translate(Inserter); 1168 1176 // remove out-of-bounds atoms 1169 1177 const bool status = RemoveAtomsOutsideDomain(Filling); … … 1203 1211 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random); 1204 1212 // translation 1205 filler->Translate( &firstInserter);1213 filler->Translate(firstInserter); 1206 1214 // remove out-of-bounds atoms 1207 1215 RemoveAtomsOutsideDomain(filler); … … 1277 1285 1278 1286 // Center filler at origin 1279 filler->CenterEdge( &Inserter);1287 filler->CenterEdge(); 1280 1288 // const int FillerCount = filler->getAtomCount(); 1281 1289 LOG(2, "INFO: Filler molecule has the following bonds:"); … … 1378 1386 RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random); 1379 1387 // translation 1380 Filling->Translate( &Inserter);1388 Filling->Translate(Inserter); 1381 1389 // remove out-of-bounds atoms 1382 1390 const bool status = RemoveAtomsOutsideDomain(Filling); … … 1416 1424 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random); 1417 1425 // translation 1418 filler->Translate( &firstInserter);1426 filler->Translate(firstInserter); 1419 1427 // remove out-of-bounds atoms 1420 1428 RemoveAtomsOutsideDomain(filler); -
src/molecule.cpp
r2d701e r833b15 751 751 }; 752 752 753 /** Sets the molecule::cell_size to the components of \a *dim (rectangular box)754 * \param *dim vector class755 */756 void molecule::SetBoxDimension(Vector *dim)757 {758 RealSpaceMatrix domain;759 for(int i =0; i<NDIM;++i)760 domain.at(i,i) = dim->at(i);761 World::getInstance().setDomain(domain);762 };763 764 753 /** Removes atom from molecule list, but does not delete it. 765 754 * \param *pointer atom to be removed -
src/molecule.hpp
r2d701e r833b15 273 273 bool CenterInBox(); 274 274 bool BoundInBox(); 275 void CenterEdge( Vector *max);275 void CenterEdge(); 276 276 void CenterOrigin(); 277 277 void CenterPeriodic(); 278 void CenterAtVector( Vector *newcenter);279 void Translate(const Vector *x);280 void TranslatePeriodically(const Vector *trans);281 void Mirror(const Vector *x);282 void Align( Vector *n);283 void Scale(const double * * constfactor);278 void CenterAtVector(const Vector &newcenter); 279 void Translate(const Vector &x); 280 void TranslatePeriodically(const Vector &trans); 281 void Mirror(const Vector &x); 282 void Align(const Vector &n); 283 void Scale(const double *factor); 284 284 void DeterminePeriodicCenter(Vector ¢er, const enum HydrogenTreatment _treatment = ExcludeHydrogen); 285 Vector * DetermineCenterOfGravity() const; 286 Vector * DetermineCenterOfAll() const; 287 Vector * DetermineCenterOfBox() const; 285 const Vector DetermineCenterOfGravity() const; 286 const Vector DetermineCenterOfAll() const; 288 287 void SetNameFromFilename(const char *filename); 289 void SetBoxDimension(Vector *dim);290 288 bool ScanForPeriodicCorrection(); 291 289 double VolumeOfConvexEnvelope(bool IsAngstroem); -
src/molecule_geometry.cpp
r2d701e r833b15 58 58 /************************************* Functions for class molecule *********************************/ 59 59 60 /** Returns vector pointing to center of the domain. 61 * \return pointer to center of the domain 62 */ 63 #ifdef HAVE_INLINE 64 inline 65 #else 66 static 67 #endif 68 const Vector DetermineCenterOfBox() 69 { 70 Vector a(0.5,0.5,0.5); 71 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 72 a *= M; 73 return a; 74 } 60 75 61 76 /** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths. … … 65 80 { 66 81 bool status = true; 67 const Vector *Center = DetermineCenterOfAll();68 const Vector *CenterBox = DetermineCenterOfBox();82 const Vector Center = DetermineCenterOfAll(); 83 const Vector CenterBox = DetermineCenterOfBox(); 69 84 Box &domain = World::getInstance().getDomain(); 70 85 71 86 // go through all atoms 72 const Vector difference = *CenterBox - *Center; 73 Translate(&difference); 87 Translate(CenterBox - Center); 74 88 getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1)); 75 89 76 delete(Center);77 delete(CenterBox);78 90 return status; 79 } ;91 } 80 92 81 93 … … 92 104 93 105 return status; 94 } ;106 } 95 107 96 108 /** Centers the edge of the atoms at (0,0,0). 97 * \param *out output stream for debugging 98 * \param *max coordinates of other edge, specifying box dimensions. 99 */ 100 void molecule::CenterEdge(Vector *max) 109 */ 110 void molecule::CenterEdge() 101 111 { 102 112 const_iterator iter = begin(); 103 113 if (iter != end()) { //list not empty? 104 114 Vector min = (*begin())->getPosition(); 105 *max = min;106 115 for (;iter != end(); ++iter) { // continue with second if present 107 116 const Vector ¤tPos = (*iter)->getPosition(); 108 for (size_t i=0;i<NDIM;++i) {117 for (size_t i=0;i<NDIM;++i) 109 118 if (min[i] > currentPos[i]) 110 119 min[i] = currentPos[i]; 111 if ((*max)[i] < currentPos[i]) 112 (*max)[i] = currentPos[i]; 113 } 114 } 115 LOG(1, "INFO: Maximum is " << *max << ", Minimum is " << min << "."); 116 const Vector temp = -1.*min; 117 Translate(&temp); 118 } 119 }; 120 } 121 Translate(-1.*min); 122 } 123 } 120 124 121 125 /** Centers the center of the atoms at (0,0,0). … … 136 140 } 137 141 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 138 Translate( &Center);139 } 140 } ;142 Translate(Center); 143 } 144 } 141 145 142 146 /** Returns vector pointing to center of all atoms. 143 147 * \return pointer to center of all vector 144 148 */ 145 Vector *molecule::DetermineCenterOfAll() const149 const Vector molecule::DetermineCenterOfAll() const 146 150 { 147 151 const_iterator iter = begin(); // start at first in list 148 Vector *a = new Vector();152 Vector a; 149 153 double Num = 0; 150 154 151 a ->Zero();155 a.Zero(); 152 156 153 157 if (iter != end()) { //list not empty? 154 158 for (; iter != end(); ++iter) { // continue with second if present 155 159 Num++; 156 (*a)+= (*iter)->getPosition();157 } 158 a ->Scale(1./(double)Num); // divide through total mass (and sign for direction)160 a += (*iter)->getPosition(); 161 } 162 a.Scale(1./(double)Num); // divide through total mass (and sign for direction) 159 163 } 160 164 return a; 161 }; 162 163 /** Returns vector pointing to center of the domain. 164 * \return pointer to center of the domain 165 */ 166 Vector * molecule::DetermineCenterOfBox() const 167 { 168 Vector *a = new Vector(0.5,0.5,0.5); 169 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 170 (*a) *= M; 171 return a; 172 }; 165 } 166 173 167 174 168 /** Returns vector pointing to center of gravity. … … 176 170 * \return pointer to center of gravity vector 177 171 */ 178 Vector *molecule::DetermineCenterOfGravity() const172 const Vector molecule::DetermineCenterOfGravity() const 179 173 { 180 174 const_iterator iter = begin(); // start at first in list 181 Vector *a = new Vector();175 Vector a; 182 176 Vector tmp; 183 177 double Num = 0; 184 178 185 a ->Zero();179 a.Zero(); 186 180 187 181 if (iter != end()) { //list not empty? … … 189 183 Num += (*iter)->getType()->getMass(); 190 184 tmp = (*iter)->getType()->getMass() * (*iter)->getPosition(); 191 (*a)+= tmp;192 } 193 a ->Scale(1./Num); // divide through total mass194 } 195 LOG(1, "INFO: Resulting center of gravity: " << *a << ".");185 a += tmp; 186 } 187 a.Scale(1./Num); // divide through total mass 188 } 189 LOG(1, "INFO: Resulting center of gravity: " << a << "."); 196 190 return a; 197 } ;191 } 198 192 199 193 /** Centers the center of gravity of the atoms at (0,0,0). … … 205 199 Vector NewCenter; 206 200 DeterminePeriodicCenter(NewCenter); 207 NewCenter *= -1.; 208 Translate(&NewCenter); 209 }; 201 Translate(-1.*NewCenter); 202 } 210 203 211 204 … … 214 207 * \param *center return vector for translation vector 215 208 */ 216 void molecule::CenterAtVector(Vector *newcenter) 217 { 218 const Vector temp = -1.**newcenter; 219 Translate(&temp); 220 }; 209 void molecule::CenterAtVector(const Vector &newcenter) 210 { 211 Translate(-1.*newcenter); 212 } 221 213 222 214 /** Calculate the inertia tensor of a the molecule. … … 227 219 { 228 220 RealSpaceMatrix InertiaTensor; 229 Vector *CenterOfGravity = DetermineCenterOfGravity();221 const Vector CenterOfGravity = DetermineCenterOfGravity(); 230 222 231 223 // reset inertia tensor … … 235 227 for (const_iterator iter = begin(); iter != end(); ++iter) { 236 228 Vector x = (*iter)->getPosition(); 237 x -= *CenterOfGravity;229 x -= CenterOfGravity; 238 230 const double mass = (*iter)->getType()->getMass(); 239 231 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); … … 250 242 LOG(1, "INFO: The inertia tensor of molecule " << getName() << " is:" << InertiaTensor); 251 243 252 delete CenterOfGravity;253 244 return InertiaTensor; 254 245 } … … 261 252 void molecule::RotateToPrincipalAxisSystem(const Vector &Axis) 262 253 { 263 Vector *CenterOfGravity = DetermineCenterOfGravity();254 const Vector CenterOfGravity = DetermineCenterOfGravity(); 264 255 RealSpaceMatrix InertiaTensor = getInertiaTensor(); 265 256 … … 273 264 274 265 // obtain first column, eigenvector to biggest eigenvalue 275 Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent()));266 const Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent())); 276 267 Vector DesiredAxis(Axis.getNormalized()); 277 268 … … 287 278 // and rotate 288 279 for (iterator iter = begin(); iter != end(); ++iter) { 289 *(*iter) -= *CenterOfGravity;280 *(*iter) -= CenterOfGravity; 290 281 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 291 *(*iter) += *CenterOfGravity;282 *(*iter) += CenterOfGravity; 292 283 } 293 284 LOG(0, "STATUS: done."); 294 295 delete CenterOfGravity;296 285 } 297 286 … … 304 293 * x=(**factor) * x (as suggested by comment) 305 294 */ 306 void molecule::Scale(const double * * constfactor)295 void molecule::Scale(const double *factor) 307 296 { 308 297 for (iterator iter = begin(); iter != end(); ++iter) { 309 298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) { 310 299 Vector temp = (*iter)->getPositionAtStep(j); 311 temp.ScaleAll( *factor);300 temp.ScaleAll(factor); 312 301 (*iter)->setPositionAtStep(j,temp); 313 302 } … … 318 307 * \param trans[] translation vector. 319 308 */ 320 void molecule::Translate(const Vector *trans)321 { 322 getAtomSet().translate( *trans);309 void molecule::Translate(const Vector &trans) 310 { 311 getAtomSet().translate(trans); 323 312 }; 324 313 … … 327 316 * TODO treatment of trajectories missing 328 317 */ 329 void molecule::TranslatePeriodically(const Vector *trans)318 void molecule::TranslatePeriodically(const Vector &trans) 330 319 { 331 320 Translate(trans); … … 338 327 * \param n[] normal vector of mirror plane. 339 328 */ 340 void molecule::Mirror(const Vector *n)341 { 342 Plane p( *n,0);329 void molecule::Mirror(const Vector &n) 330 { 331 Plane p(n,0); 343 332 getAtomSet().transformNodes(boost::bind(&Plane::mirrorVector,p,_1)); 344 333 }; … … 356 345 Vector Testvector, Translationvector; 357 346 Vector Center; 358 BondGraph *BG = World::getInstance().getBondGraph();347 const BondGraph * const BG = World::getInstance().getBondGraph(); 359 348 360 349 do { … … 407 396 408 397 Center.Scale(1./static_cast<double>(getAtomCount())); 409 CenterAtVector( &Center);398 CenterAtVector(Center); 410 399 }; 411 400 … … 413 402 * \param n[] alignment vector. 414 403 */ 415 void molecule::Align( Vector *n)404 void molecule::Align(const Vector &n) 416 405 { 417 406 double alpha, tmp; 418 407 Vector z_axis; 408 Vector alignment(n); 419 409 z_axis[0] = 0.; 420 410 z_axis[1] = 0.; … … 423 413 // rotate on z-x plane 424 414 LOG(0, "Begin of Aligning all atoms."); 425 alpha = atan(- n->at(0)/n->at(2));415 alpha = atan(-alignment.at(0)/alignment.at(2)); 426 416 LOG(1, "INFO: Z-X-angle: " << alpha << " ... "); 427 417 for (iterator iter = begin(); iter != end(); ++iter) { … … 437 427 } 438 428 // rotate n vector 439 tmp = n->at(0);440 n->at(0) = cos(alpha) * tmp + sin(alpha) * n->at(2);441 n->at(2) = -sin(alpha) * tmp + cos(alpha) * n->at(2);442 LOG(1, "alignment vector after first rotation: " << n);429 tmp = alignment.at(0); 430 alignment.at(0) = cos(alpha) * tmp + sin(alpha) * alignment.at(2); 431 alignment.at(2) = -sin(alpha) * tmp + cos(alpha) * alignment.at(2); 432 LOG(1, "alignment vector after first rotation: " << alignment); 443 433 444 434 // rotate on z-y plane 445 alpha = atan(- n->at(1)/n->at(2));435 alpha = atan(-alignment.at(1)/alignment.at(2)); 446 436 LOG(1, "INFO: Z-Y-angle: " << alpha << " ... "); 447 437 for (iterator iter = begin(); iter != end(); ++iter) { … … 457 447 } 458 448 // rotate n vector (for consistency check) 459 tmp = n->at(1); 460 n->at(1) = cos(alpha) * tmp + sin(alpha) * n->at(2); 461 n->at(2) = -sin(alpha) * tmp + cos(alpha) * n->at(2); 462 463 464 LOG(1, "alignment vector after second rotation: " << n); 449 tmp = alignment.at(1); 450 alignment.at(1) = cos(alpha) * tmp + sin(alpha) * alignment.at(2); 451 alignment.at(2) = -sin(alpha) * tmp + cos(alpha) * alignment.at(2); 452 453 LOG(1, "alignment vector after second rotation: " << alignment); 465 454 LOG(0, "End of Aligning all atoms."); 466 455 }; -
src/moleculelist.cpp
r2d701e r833b15 229 229 } 230 230 // Center and size 231 Vector *Center = (*ListRunner)->DetermineCenterOfAll(); 232 (*out) << "\t" << *Center << "\t" << sqrt(size) << endl; 233 delete(Center); 231 Vector Center = (*ListRunner)->DetermineCenterOfAll(); 232 (*out) << "\t" << Center << "\t" << sqrt(size) << endl; 234 233 } 235 234 } … … 578 577 // if (BoxDimension[k] < 1.) 579 578 // BoxDimension[k] += 1.; 580 // (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 579 // { 580 // RealSpaceMatrix domain; 581 // for(int i =0; i<NDIM;++i) 582 // domain.at(i,i) = BoxDimension[i]; 583 // World::getInstance().setDomain(domain); 584 // } 581 585 // for (int k = 0; k < NDIM; k++) { 582 586 // BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
Note:
See TracChangeset
for help on using the changeset viewer.