- Timestamp:
- Jun 9, 2010, 11:12:08 AM (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, 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:
- 104524
- Parents:
- 8540f0
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
r8540f0 rc78d44 23 23 /** Calculates the pair correlation between given elements. 24 24 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 25 * \param *out output stream for debugging26 25 * \param *molecules list of molecules structure 27 * \param *type1 first element or NULL (if any element) 28 * \param *type2 second element or NULL (if any element) 26 * \param &elements vector of elements to correlate 29 27 * \return Map of doubles with values the pair of the two atoms. 30 28 */ 31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2)29 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements) 32 30 { 33 31 Info FunctionInfo(__func__); 34 32 PairCorrelationMap *outmap = NULL; 35 33 double distance = 0.; 34 double *domain = World::getInstance().getDomain(); 36 35 37 36 if (molecules->ListOfMolecules.empty()) { … … 41 40 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 42 41 (*MolWalker)->doCountAtoms(); 42 43 // create all possible pairs of elements 44 set <pair<element *, element *> > PairsOfElements; 45 if (elements.size() >= 2) { 46 for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 47 for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 48 if (type1 != type2) { 49 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) ); 50 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl); 51 } 52 } else if (elements.size() == 1) { // one to all are valid 53 element *elemental = *elements.begin(); 54 PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) ); 55 PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) ); 56 } else { // all elements valid 57 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); 58 } 59 43 60 outmap = new PairCorrelationMap; 44 61 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ … … 48 65 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 49 66 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 50 if ((type1 == NULL) || ((*iter)->type == type1)){51 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){52 if ((*MolOtherWalker)->ActiveFlag) {53 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);54 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {55 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);56 if ((*iter)->getId() < (*runner)->getId()){57 if (( type2 == NULL) || ((*runner)->type == type2)) {58 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, World::getInstance().getDomain());67 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 68 if ((*MolOtherWalker)->ActiveFlag) { 69 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 70 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 71 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 72 if ((*iter)->getId() < (*runner)->getId()){ 73 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 74 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 75 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, domain); 59 76 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 60 77 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 61 78 } 62 }63 79 } 64 80 } … … 73 89 /** Calculates the pair correlation between given elements. 74 90 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 75 * \param *out output stream for debugging76 91 * \param *molecules list of molecules structure 77 * \param *type1 first element or NULL (if any element) 78 * \param *type2 second element or NULL (if any element) 92 * \param &elements vector of elements to correlate 79 93 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 80 94 * \return Map of doubles with values the pair of the two atoms. 81 95 */ 82 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )96 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ) 83 97 { 84 98 Info FunctionInfo(__func__); … … 98 112 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 99 113 (*MolWalker)->doCountAtoms(); 114 115 // create all possible pairs of elements 116 set <pair<element *, element *> > PairsOfElements; 117 if (elements.size() >= 2) { 118 for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 119 for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 120 if (type1 != type2) { 121 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) ); 122 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl); 123 } 124 } else if (elements.size() == 1) { // one to all are valid 125 element *elemental = *elements.begin(); 126 PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) ); 127 PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) ); 128 } else { // all elements valid 129 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); 130 } 131 100 132 outmap = new PairCorrelationMap; 101 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 133 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 102 134 if ((*MolWalker)->ActiveFlag) { 103 135 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 104 136 double * FullInverseMatrix = InverseMatrix(FullMatrix); 105 137 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 138 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 106 139 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 107 140 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 108 if ((type1 == NULL) || ((*iter)->type == type1)) {109 periodicX = *(*iter)->node;110 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3111 // go through every range in xyz and get distance112 for (n[ 0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)113 for (n[ 1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)114 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {115 checkX = Vector(n[0], n[1], n[2]) + periodicX;116 checkX.MatrixMultiplication(FullMatrix);117 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)118 if ((*MolOtherWalker)->ActiveFlag) {119 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);120 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {121 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);122 if ((*iter)->nr < (*runner)->nr)123 if (( type2 == NULL) || ((*runner)->type == type2)) {141 periodicX = *(*iter)->node; 142 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 143 // go through every range in xyz and get distance 144 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 145 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 146 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 147 checkX = Vector(n[0], n[1], n[2]) + periodicX; 148 checkX.MatrixMultiplication(FullMatrix); 149 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 150 if ((*MolOtherWalker)->ActiveFlag) { 151 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 152 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 153 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 154 if ((*iter)->getId() < (*runner)->getId()){ 155 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 156 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 124 157 periodicOtherX = *(*runner)->node; 125 158 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 … … 135 168 } 136 169 } 170 } 137 171 } 172 } 138 173 } 139 174 } 140 }141 175 } 142 176 delete[](FullMatrix); 143 177 delete[](FullInverseMatrix); 144 178 } 179 } 180 181 // outmap = new PairCorrelationMap; 182 // for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 183 // if ((*MolWalker)->ActiveFlag) { 184 // double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 185 // double * FullInverseMatrix = InverseMatrix(FullMatrix); 186 // DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 187 // for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 188 // DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 189 // if ((type1 == NULL) || ((*iter)->type == type1)) { 190 // periodicX = *(*iter)->node; 191 // periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 192 // // go through every range in xyz and get distance 193 // for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 194 // for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 195 // for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 196 // checkX = Vector(n[0], n[1], n[2]) + periodicX; 197 // checkX.MatrixMultiplication(FullMatrix); 198 // for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 199 // if ((*MolOtherWalker)->ActiveFlag) { 200 // DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 201 // for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 202 // DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 203 // if ((*iter)->nr < (*runner)->nr) 204 // if ((type2 == NULL) || ((*runner)->type == type2)) { 205 // periodicOtherX = *(*runner)->node; 206 // periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 207 // // go through every range in xyz and get distance 208 // for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 209 // for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 210 // for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 211 // checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX; 212 // checkOtherX.MatrixMultiplication(FullMatrix); 213 // distance = checkX.distance(checkOtherX); 214 // //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 215 // outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 216 // } 217 // } 218 // } 219 // } 220 // } 221 // } 222 // } 223 // delete[](FullMatrix); 224 // delete[](FullInverseMatrix); 225 // } 145 226 146 227 return outmap; … … 148 229 149 230 /** Calculates the distance (pair) correlation between a given element and a point. 150 * \param *out output stream for debugging151 231 * \param *molecules list of molecules structure 152 * \param *type element or NULL (if any element)232 * \param &elements vector of elements to correlate with point 153 233 * \param *point vector to the correlation point 154 234 * \return Map of dobules with values as pairs of atom and the vector 155 235 */ 156 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )236 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ) 157 237 { 158 238 Info FunctionInfo(__func__); … … 172 252 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 173 253 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 174 if ((type == NULL) || ((*iter)->type == type)) { 175 distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain()); 176 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 177 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 178 } 254 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 255 if ((*type == NULL) || ((*iter)->type == *type)) { 256 distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain()); 257 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 258 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 259 } 179 260 } 180 261 } … … 184 265 185 266 /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point. 186 * \param *out output stream for debugging187 267 * \param *molecules list of molecules structure 188 * \param *type element or NULL (if any element)268 * \param &elements vector of elements to correlate to point 189 269 * \param *point vector to the correlation point 190 270 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 191 271 * \return Map of dobules with values as pairs of atom and the vector 192 272 */ 193 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )273 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ) 194 274 { 195 275 Info FunctionInfo(__func__); … … 214 294 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 215 295 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 216 if ((type == NULL) || ((*iter)->type == type)) { 217 periodicX = *(*iter)->node; 218 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 219 // go through every range in xyz and get distance 220 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 221 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 222 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 223 checkX = Vector(n[0], n[1], n[2]) + periodicX; 224 checkX.MatrixMultiplication(FullMatrix); 225 distance = checkX.distance(*point); 226 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 227 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 228 } 229 } 296 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 297 if ((*type == NULL) || ((*iter)->type == *type)) { 298 periodicX = *(*iter)->node; 299 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 300 // go through every range in xyz and get distance 301 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 302 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 303 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 304 checkX = Vector(n[0], n[1], n[2]) + periodicX; 305 checkX.MatrixMultiplication(FullMatrix); 306 distance = checkX.distance(*point); 307 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 308 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 309 } 310 } 230 311 } 231 312 delete[](FullMatrix); … … 237 318 238 319 /** Calculates the distance (pair) correlation between a given element and a surface. 239 * \param *out output stream for debugging240 320 * \param *molecules list of molecules structure 241 * \param *type element or NULL (if any element)321 * \param &elements vector of elements to correlate to surface 242 322 * \param *Surface pointer to Tesselation class surface 243 323 * \param *LC LinkedCell structure to quickly find neighbouring atoms 244 324 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 245 325 */ 246 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )326 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 247 327 { 248 328 Info FunctionInfo(__func__); … … 266 346 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 267 347 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl); 268 if ((type == NULL) || ((*iter)->type == type)) { 269 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 270 distance = Intersections.GetSmallestDistance(); 271 triangle = Intersections.GetClosestTriangle(); 272 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 273 } 348 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 349 if ((*type == NULL) || ((*iter)->type == *type)) { 350 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 351 distance = Intersections.GetSmallestDistance(); 352 triangle = Intersections.GetClosestTriangle(); 353 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 354 } 274 355 } 275 356 } else { … … 285 366 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into 286 367 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane(). 287 * \param *out output stream for debugging288 368 * \param *molecules list of molecules structure 289 * \param *type element or NULL (if any element)369 * \param &elements vector of elements to correlate to surface 290 370 * \param *Surface pointer to Tesselation class surface 291 371 * \param *LC LinkedCell structure to quickly find neighbouring atoms … … 293 373 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 294 374 */ 295 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )375 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 296 376 { 297 377 Info FunctionInfo(__func__); … … 320 400 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 321 401 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 322 if ((type == NULL) || ((*iter)->type == type)) { 323 periodicX = *(*iter)->node; 324 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 325 // go through every range in xyz and get distance 326 ShortestDistance = -1.; 327 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 328 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 329 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 330 checkX = Vector(n[0], n[1], n[2]) + periodicX; 331 checkX.MatrixMultiplication(FullMatrix); 332 TriangleIntersectionList Intersections(&checkX,Surface,LC); 333 distance = Intersections.GetSmallestDistance(); 334 triangle = Intersections.GetClosestTriangle(); 335 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 336 ShortestDistance = distance; 337 ShortestTriangle = triangle; 402 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 403 if ((*type == NULL) || ((*iter)->type == *type)) { 404 periodicX = *(*iter)->node; 405 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 406 // go through every range in xyz and get distance 407 ShortestDistance = -1.; 408 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 409 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 410 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 411 checkX = Vector(n[0], n[1], n[2]) + periodicX; 412 checkX.MatrixMultiplication(FullMatrix); 413 TriangleIntersectionList Intersections(&checkX,Surface,LC); 414 distance = Intersections.GetSmallestDistance(); 415 triangle = Intersections.GetClosestTriangle(); 416 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 417 ShortestDistance = distance; 418 ShortestTriangle = triangle; 419 } 338 420 } 339 } 340 // insert 341 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 342 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 343 } 421 // insert 422 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 423 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 424 } 344 425 } 345 426 delete[](FullMatrix); -
src/analysis_correlation.hpp
r8540f0 rc78d44 45 45 /********************************************** declarations *******************************/ 46 46 47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2);48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point );49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] );51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements); 48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ); 49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ); 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ); 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/builder.cpp
r8540f0 rc78d44 1774 1774 const double BinEnd = atof(argv[argptr+6]); 1775 1775 1776 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1777 const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2])); 1776 std::vector<element *> elements; 1777 elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1]))); 1778 elements.push_back(periode->FindElement((const int) atoi(argv[argptr+2]))); 1778 1779 PairCorrelationMap *correlationmap = NULL; 1779 1780 if (periodic) 1780 correlationmap = PeriodicPairCorrelation(molecules, element al, elemental2, ranges);1781 correlationmap = PeriodicPairCorrelation(molecules, elements, ranges); 1781 1782 else 1782 correlationmap = PairCorrelation(molecules, element al, elemental2);1783 correlationmap = PairCorrelation(molecules, elements); 1783 1784 OutputPairCorrelation(&output, correlationmap); 1784 1785 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); … … 1805 1806 const double BinEnd = atof(argv[argptr+8]); 1806 1807 1807 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1808 std::vector<element *> elements; 1809 elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1]))); 1808 1810 Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3])); 1809 1811 CorrelationToPointMap *correlationmap = NULL; 1810 1812 if (periodic) 1811 correlationmap = PeriodicCorrelationToPoint(molecules, element al, Point, ranges);1813 correlationmap = PeriodicCorrelationToPoint(molecules, elements, Point, ranges); 1812 1814 else 1813 correlationmap = CorrelationToPoint(molecules, element al, Point);1815 correlationmap = CorrelationToPoint(molecules, elements, Point); 1814 1816 OutputCorrelationToPoint(&output, correlationmap); 1815 1817 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); … … 1865 1867 } 1866 1868 LCList = new LinkedCell(Boundary, LCWidth); 1867 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1869 std::vector<element *> elements; 1870 elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1]))); 1868 1871 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1869 1872 CorrelationToSurfaceMap *surfacemap = NULL; 1870 1873 if (periodic) 1871 surfacemap = PeriodicCorrelationToSurface( molecules, element al, TesselStruct, LCList, ranges);1874 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges); 1872 1875 else 1873 surfacemap = CorrelationToSurface( molecules, element al, TesselStruct, LCList);1876 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList); 1874 1877 OutputCorrelationToSurface(&output, surfacemap); 1875 1878 // check whether radius was appropriate -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r8540f0 rc78d44 44 44 point = NULL; 45 45 46 // construct molecule (tetraeder of hydrogens) 46 // construct element list 47 std::vector<element *> elements; 47 48 hydrogen = World::getInstance().getPeriode()->FindElement(1); 48 49 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 50 elements.push_back(hydrogen); 51 // construct molecule (tetraeder of hydrogens) 49 52 TestMolecule = World::getInstance().createMolecule(); 50 53 Walker = World::getInstance().createAtom(); … … 76 79 77 80 // init maps 78 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );81 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point ); 79 82 binmap = NULL; 80 83 -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r8540f0 rc78d44 37 37 MoleculeListClass *TestList; 38 38 molecule *TestMolecule; 39 constelement *hydrogen;39 element *hydrogen; 40 40 41 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r8540f0 rc78d44 52 52 LC = NULL; 53 53 54 // prepare element list 55 hydrogen = World::getInstance().getPeriode()->FindElement(1); 56 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 57 elements.clear(); 58 54 59 // construct molecule (tetraeder of hydrogens) base 55 hydrogen = World::getInstance().getPeriode()->FindElement(1);56 60 TestSurfaceMolecule = World::getInstance().createMolecule(); 57 61 … … 151 155 { 152 156 // do the pair correlation 153 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 157 elements.push_back(hydrogen); 158 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 154 159 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 155 160 CPPUNIT_ASSERT( surfacemap != NULL ); … … 160 165 { 161 166 BinPairMap::iterator tester; 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 167 elements.push_back(hydrogen); 168 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 163 169 // put pair correlation into bins and check with no range 164 170 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); … … 175 181 { 176 182 BinPairMap::iterator tester; 177 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 183 elements.push_back(hydrogen); 184 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 178 185 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 179 186 // ... and check with [0., 2.] range … … 193 200 { 194 201 BinPairMap::iterator tester; 195 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 202 elements.push_back(carbon); 203 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 196 204 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 197 205 // put pair correlation into bins and check with no range … … 212 220 { 213 221 BinPairMap::iterator tester; 214 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 222 elements.push_back(carbon); 223 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 215 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 216 225 // ... and check with [0., 2.] range -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r8540f0 rc78d44 45 45 MoleculeListClass *TestList; 46 46 molecule *TestSurfaceMolecule; 47 const element *hydrogen; 48 const element *carbon; 47 element *hydrogen; 48 element *carbon; 49 std::vector<element *> elements; 49 50 50 51 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r8540f0 rc78d44 47 47 binmap = NULL; 48 48 49 // construct element list 50 std::vector<element *> elements; 51 hydrogen = World::getInstance().getPeriode()->FindElement(1); 52 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 53 elements.push_back(hydrogen); 54 elements.push_back(hydrogen); 55 49 56 // construct molecule (tetraeder of hydrogens) 50 hydrogen = World::getInstance().getPeriode()->FindElement(1);51 57 TestMolecule = World::getInstance().createMolecule(); 52 58 Walker = World::getInstance().createAtom(); … … 75 81 76 82 // init maps 77 correlationmap = PairCorrelation( TestList, hydrogen, hydrogen);83 correlationmap = PairCorrelation( TestList, elements); 78 84 binmap = NULL; 79 85 -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r8540f0 rc78d44 37 37 MoleculeListClass *TestList; 38 38 molecule *TestMolecule; 39 constelement *hydrogen;39 element *hydrogen; 40 40 41 41 PairCorrelationMap *correlationmap;
Note:
See TracChangeset
for help on using the changeset viewer.