Changeset 99593f
- Timestamp:
- Nov 4, 2009, 5:34:05 PM (16 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:
- 7ea9e6
- Parents:
- c9bce3e
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
rc9bce3e r99593f 52 52 if (Walker->nr < OtherWalker->nr) 53 53 if ((type2 == NULL) || (OtherWalker->type == type2)) { 54 distance = Walker->node-> Distance(OtherWalker->node);54 distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size); 55 55 //*out << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl; 56 56 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) ); … … 90 90 *out << Verbose(3) << "Current atom is " << *Walker << "." << endl; 91 91 if ((type == NULL) || (Walker->type == type)) { 92 distance = Walker->node-> Distance(point);92 distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size); 93 93 *out << Verbose(4) << "Current distance is " << distance << "." << endl; 94 94 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); … … 111 111 { 112 112 CorrelationToSurfaceMap *outmap = NULL; 113 double distance = 0 .;113 double distance = 0; 114 114 class BoundaryTriangleSet *triangle = NULL; 115 115 Vector centroid; 116 int ranges[NDIM] = {1, 1, 1}; 117 int n[NDIM]; 118 Vector periodicX; 119 Vector checkX; 116 120 117 121 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { … … 122 126 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 123 127 if ((*MolWalker)->ActiveFlag) { 128 const double * const FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size); 129 const double * const FullInverseMatrix = InverseMatrix(FullMatrix); 124 130 *out << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 125 131 atom *Walker = (*MolWalker)->start; … … 128 134 *out << Verbose(3) << "Current atom is " << *Walker << "." << endl; 129 135 if ((type == NULL) || (Walker->type == type)) { 130 triangle = Surface->FindClosestTriangleToPoint(out, Walker->node, LC ); 131 if (triangle != NULL) { 132 distance = DistanceToTrianglePlane(out, Walker->node, triangle); 133 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 136 periodicX.CopyVector(Walker->node); 137 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 138 // go through every range in xyz and get distance 139 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 140 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 141 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 142 checkX.Init(n[0], n[1], n[2]); 143 checkX.AddVector(&periodicX); 144 checkX.MatrixMultiplication(FullMatrix); 145 triangle = Surface->FindClosestTriangleToPoint(out, &checkX, LC ); 146 if (triangle != NULL) { 147 distance = DistanceToTrianglePlane(out, &checkX, triangle); 148 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 149 } 134 150 } 135 151 } -
src/atom_bondedparticle.cpp
rc9bce3e r99593f 126 126 bond *CandidateBond = NULL; 127 127 128 *out << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;128 //*out << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 129 129 NoBonds = CountBonds(); 130 130 if ((int)(type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch … … 132 132 OtherWalker = (*Runner)->GetOtherAtom(this); 133 133 OtherNoBonds = OtherWalker->CountBonds(); 134 *out << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;134 //*out << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 135 135 if ((int)(OtherWalker->type->NoValenceOrbitals) > NoBonds) { // check if possible candidate 136 136 if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first 137 137 CandidateBond = (*Runner); 138 *out << Verbose(3) << "New candidate is " << *CandidateBond << "." << endl;138 //*out << Verbose(3) << "New candidate is " << *CandidateBond << "." << endl; 139 139 } 140 140 } … … 144 144 *out << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl; 145 145 } else { 146 *out << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;146 //*out << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl; 147 147 FalseBondDegree++; 148 148 } -
src/helpers.cpp
rc9bce3e r99593f 133 133 * \return allocated NDIM*NDIM array with the symmetric matrix 134 134 */ 135 double * ReturnFullMatrixforSymmetric( double *symm)135 double * ReturnFullMatrixforSymmetric(const double * const symm) 136 136 { 137 137 double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix"); … … 148 148 }; 149 149 150 /** Calculate the inverse of a 3x3 matrix. 151 * \param *matrix NDIM_NDIM array 152 */ 153 double * InverseMatrix( const double * const A) 154 { 155 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B"); 156 double detA = RDET3(A); 157 double detAReci; 158 159 for (int i=0;i<NDIM*NDIM;++i) 160 B[i] = 0.; 161 // calculate the inverse B 162 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular 163 detAReci = 1./detA; 164 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11 165 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12 166 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13 167 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21 168 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22 169 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23 170 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31 171 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32 172 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 173 } 174 return B; 175 }; 176 177 /** hard-coded determinant of a 3x3 matrix. 178 * \param a[9] matrix 179 * \return \f$det(a)\f$ 180 */ 181 double RDET3(const double a[NDIM*NDIM]) 182 { 183 return ((a)[0]*(a)[4]*(a)[8] + (a)[3]*(a)[7]*(a)[2] + (a)[6]*(a)[1]*(a)[5] - (a)[2]*(a)[4]*(a)[6] - (a)[5]*(a)[7]*(a)[0] - (a)[8]*(a)[1]*(a)[3]); 184 }; 185 186 /** hard-coded determinant of a 2x2 matrix. 187 * \param a[4] matrix 188 * \return \f$det(a)\f$ 189 */ 190 double RDET2(const double a[4]) 191 { 192 return ((a[0])*(a[3])-(a[1])*(a[2])); 193 }; 194 195 /** hard-coded determinant of a 2x2 matrix. 196 * \param a0 (0,0) entry of matrix 197 * \param a1 (0,1) entry of matrix 198 * \param a2 (1,0) entry of matrix 199 * \param a3 (1,1) entry of matrix 200 * \return \f$det(a)\f$ 201 */ 202 double RDET2(const double a0, const double a1, const double a2, const double a3) 203 { 204 return ((a0)*(a3)-(a1)*(a2)); 205 }; 206 150 207 /** Comparison function for GSL heapsort on distances in two molecules. 151 208 * \param *a -
src/helpers.hpp
rc9bce3e r99593f 18 18 #include <fstream> 19 19 20 #include "defs.hpp" 20 21 #include "memoryallocator.hpp" 22 23 /********************************************** definitions *********************************/ 24 25 // some algebraic matrix stuff 26 double RDET3(const double a[NDIM*NDIM]); 27 double RDET2(const double a[4]); 28 double RDET2(const double a0, const double a1, const double a2, const double a3); 21 29 22 30 /********************************************** helpful functions *********************************/ … … 49 57 bool IsValidNumber( const char *string); 50 58 int CompareDoubles (const void * a, const void * b); 51 double * ReturnFullMatrixforSymmetric(double *cell_size); 59 double * ReturnFullMatrixforSymmetric(const double * const cell_size); 60 double * InverseMatrix(const double * const A); 52 61 void performCriticalExit(); 53 62 -
src/molecule_geometry.cpp
rc9bce3e r99593f 24 24 { 25 25 bool status = true; 26 Vector x;27 26 const Vector *Center = DetermineCenterOfAll(out); 28 27 double *M = ReturnFullMatrixforSymmetric(cell_size); 29 double *Minv = x.InverseMatrix(M);28 double *Minv = InverseMatrix(M); 30 29 31 30 // go through all atoms … … 46 45 { 47 46 bool status = true; 48 Vector x;49 47 double *M = ReturnFullMatrixforSymmetric(cell_size); 50 double *Minv = x.InverseMatrix(M);48 double *Minv = InverseMatrix(M); 51 49 52 50 // go through all atoms … … 231 229 void molecule::TranslatePeriodically(const Vector *trans) 232 230 { 233 Vector x;234 231 double *M = ReturnFullMatrixforSymmetric(cell_size); 235 double *Minv = x.InverseMatrix(M);232 double *Minv = InverseMatrix(M); 236 233 237 234 // go through all atoms -
src/molecule_graph.cpp
rc9bce3e r99593f 221 221 int molecule::CorrectBondDegree(ofstream *out) const 222 222 { 223 int No = 0 ;223 int No = 0, OldNo = -1; 224 224 225 225 if (BondCount != 0) { 226 226 *out << Verbose(1) << "Correcting Bond degree of each bond ... " << endl; 227 227 do { 228 OldNo = No; 228 229 No = SumPerAtom(&atom::CorrectBondDegree, out); 229 } while ( No);230 } while (OldNo != No); 230 231 *out << " done." << endl; 231 232 } else { … … 418 419 if (!DFS.BackStepping) { // coming from (8) want to go to (3) 419 420 // (9) remove all from stack till Walker (including), these and Root form a component 420 DFS.AtomStack->Output(out);421 //DFS.AtomStack->Output(out); 421 422 mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber); 422 423 *out << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl; … … 881 882 InitializeBFSAccounting(out, BFS, AtomCount); 882 883 883 *out << Verbose(1) << "Back edge list - ";884 BackEdgeStack->Output(out);884 //*out << Verbose(1) << "Back edge list - "; 885 //BackEdgeStack->Output(out); 885 886 886 887 *out << Verbose(1) << "Analysing cycles ... " << endl; -
src/tesselation.cpp
rc9bce3e r99593f 2538 2538 } else { 2539 2539 list<TesselPoint*> *connectedClosestPoints = GetCircleOfConnectedPoints(out, trianglePoints[0], x); 2540 trianglePoints[1] = connectedClosestPoints->front(); 2541 trianglePoints[2] = connectedClosestPoints->back(); 2542 for (int i=0;i<3;i++) { 2543 if (trianglePoints[i] == NULL) { 2544 *out << Verbose(1) << "ERROR: IsInnerPoint encounters serious error, point " << i << " not found." << endl; 2540 if (connectedClosestPoints != NULL) { 2541 trianglePoints[1] = connectedClosestPoints->front(); 2542 trianglePoints[2] = connectedClosestPoints->back(); 2543 for (int i=0;i<3;i++) { 2544 if (trianglePoints[i] == NULL) { 2545 *out << Verbose(1) << "ERROR: IsInnerPoint encounters serious error, point " << i << " not found." << endl; 2546 } 2547 //*out << Verbose(2) << "List of triangle points:" << endl; 2548 //*out << Verbose(3) << *trianglePoints[i] << endl; 2545 2549 } 2546 //*out << Verbose(2) << "List of triangle points:" << endl; 2547 //*out << Verbose(3) << *trianglePoints[i] << endl; 2548 } 2549 2550 triangles = FindTriangles(trianglePoints); 2551 *out << Verbose(2) << "List of possible triangles:" << endl; 2552 for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 2553 *out << Verbose(3) << **Runner << endl; 2554 2555 delete(connectedClosestPoints); 2550 2551 triangles = FindTriangles(trianglePoints); 2552 *out << Verbose(2) << "List of possible triangles:" << endl; 2553 for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 2554 *out << Verbose(3) << **Runner << endl; 2555 2556 delete(connectedClosestPoints); 2557 } else { 2558 triangles = NULL; 2559 *out << Verbose(1) << "There is no circle of connected points!" << endl; 2560 } 2556 2561 } 2557 2562 2558 if ( triangles->empty()) {2563 if ((triangles == NULL) || (triangles->empty())) { 2559 2564 *out << Verbose(0) << "ERROR: There is no nearest triangle. Please check the tesselation structure."; 2560 2565 delete(triangles); … … 2724 2729 Vector helper; 2725 2730 2731 if (connectedPoints == NULL) { 2732 *out << Verbose(2) << "Could not find any connected points!" << endl; 2733 delete(connectedCircle); 2734 return NULL; 2735 } 2726 2736 *out << Verbose(2) << "Begin of GetCircleOfConnectedPoints" << endl; 2727 2737 -
src/vector.cpp
rc9bce3e r99593f 275 275 temp.AddVector(this); 276 276 temp.SubtractVector(PlaneOffset); 277 278 return temp.Norm(); 277 double sign = temp.ScalarProduct(PlaneNormal); 278 sign /= fabs(sign); 279 280 return (temp.Norm()*sign); 279 281 }; 280 282 … … 713 715 for (int i=NDIM;i--;) 714 716 x[i] = C.x[i]; 715 };716 717 /** Calculate the inverse of a 3x3 matrix.718 * \param *matrix NDIM_NDIM array719 */720 double * Vector::InverseMatrix( const double * const A)721 {722 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");723 double detA = RDET3(A);724 double detAReci;725 726 for (int i=0;i<NDIM*NDIM;++i)727 B[i] = 0.;728 // calculate the inverse B729 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular730 detAReci = 1./detA;731 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11732 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12733 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13734 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21735 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22736 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23737 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31738 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32739 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33740 }741 return B;742 717 }; 743 718 -
src/vector.hpp
rc9bce3e r99593f 62 62 void Scale(const double factor); 63 63 void MatrixMultiplication(const double * const M); 64 double * InverseMatrix(const double * const A);65 64 void InverseMatrixMultiplication(const double * const M); 66 65 void KeepPeriodic(ofstream *out, const double * const matrix); … … 91 90 Vector& operator-(const Vector& a, const Vector& b); 92 91 93 // some algebraic matrix stuff94 #define RDET3(a) ((a)[0]*(a)[4]*(a)[8] + (a)[3]*(a)[7]*(a)[2] + (a)[6]*(a)[1]*(a)[5] - (a)[2]*(a)[4]*(a)[6] - (a)[5]*(a)[7]*(a)[0] - (a)[8]*(a)[1]*(a)[3]) //!< hard-coded determinant of a 3x3 matrix95 #define RDET2(a0,a1,a2,a3) ((a0)*(a3)-(a1)*(a2)) //!< hard-coded determinant of a 2x2 matrix96 97 98 92 99 93 #endif /*VECTOR_HPP_*/
Note:
See TracChangeset
for help on using the changeset viewer.