| [c4d4df] | 1 | /*
|
|---|
| 2 | * analysis.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Oct 13, 2009
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include <iostream>
|
|---|
| 9 |
|
|---|
| 10 | #include "analysis_correlation.hpp"
|
|---|
| 11 | #include "element.hpp"
|
|---|
| [e138de] | 12 | #include "log.hpp"
|
|---|
| [c4d4df] | 13 | #include "molecule.hpp"
|
|---|
| 14 | #include "tesselation.hpp"
|
|---|
| 15 | #include "tesselationhelpers.hpp"
|
|---|
| 16 | #include "vector.hpp"
|
|---|
| [a5551b] | 17 | #include "verbose.hpp"
|
|---|
| [c4d4df] | 18 |
|
|---|
| 19 |
|
|---|
| 20 | /** Calculates the pair correlation between given elements.
|
|---|
| 21 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| 22 | * \param *out output stream for debugging
|
|---|
| [a5551b] | 23 | * \param *molecules list of molecules structure
|
|---|
| [c4d4df] | 24 | * \param *type1 first element or NULL (if any element)
|
|---|
| 25 | * \param *type2 second element or NULL (if any element)
|
|---|
| 26 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 27 | */
|
|---|
| [e138de] | 28 | PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 )
|
|---|
| [c4d4df] | 29 | {
|
|---|
| 30 | PairCorrelationMap *outmap = NULL;
|
|---|
| 31 | double distance = 0.;
|
|---|
| 32 |
|
|---|
| [a5551b] | 33 | if (molecules->ListOfMolecules.empty()) {
|
|---|
| [e138de] | 34 | eLog() << Verbose(1) <<"No molecule given." << endl;
|
|---|
| [c4d4df] | 35 | return outmap;
|
|---|
| 36 | }
|
|---|
| 37 | outmap = new PairCorrelationMap;
|
|---|
| [a5551b] | 38 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 39 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| [e138de] | 40 | eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [a5551b] | 41 | atom *Walker = (*MolWalker)->start;
|
|---|
| 42 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 43 | Walker = Walker->next;
|
|---|
| [e138de] | 44 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [a5551b] | 45 | if ((type1 == NULL) || (Walker->type == type1)) {
|
|---|
| 46 | for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
|
|---|
| 47 | if ((*MolOtherWalker)->ActiveFlag) {
|
|---|
| [e138de] | 48 | Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
|
|---|
| [a5551b] | 49 | atom *OtherWalker = (*MolOtherWalker)->start;
|
|---|
| 50 | while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
|
|---|
| 51 | OtherWalker = OtherWalker->next;
|
|---|
| [e138de] | 52 | Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
|
|---|
| [a5551b] | 53 | if (Walker->nr < OtherWalker->nr)
|
|---|
| 54 | if ((type2 == NULL) || (OtherWalker->type == type2)) {
|
|---|
| [99593f] | 55 | distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
|
|---|
| [e138de] | 56 | //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
|
|---|
| [a5551b] | 57 | outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| [c4d4df] | 60 | }
|
|---|
| [a5551b] | 61 | }
|
|---|
| [c4d4df] | 62 | }
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | return outmap;
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| [7ea9e6] | 68 | /** Calculates the pair correlation between given elements.
|
|---|
| 69 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| 70 | * \param *out output stream for debugging
|
|---|
| 71 | * \param *molecules list of molecules structure
|
|---|
| 72 | * \param *type1 first element or NULL (if any element)
|
|---|
| 73 | * \param *type2 second element or NULL (if any element)
|
|---|
| 74 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 75 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 76 | */
|
|---|
| [e138de] | 77 | PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 78 | {
|
|---|
| 79 | PairCorrelationMap *outmap = NULL;
|
|---|
| 80 | double distance = 0.;
|
|---|
| 81 | int n[NDIM];
|
|---|
| 82 | Vector checkX;
|
|---|
| 83 | Vector periodicX;
|
|---|
| 84 | int Othern[NDIM];
|
|---|
| 85 | Vector checkOtherX;
|
|---|
| 86 | Vector periodicOtherX;
|
|---|
| 87 |
|
|---|
| 88 | if (molecules->ListOfMolecules.empty()) {
|
|---|
| [e138de] | 89 | eLog() << Verbose(1) <<"No molecule given." << endl;
|
|---|
| [7ea9e6] | 90 | return outmap;
|
|---|
| 91 | }
|
|---|
| 92 | outmap = new PairCorrelationMap;
|
|---|
| 93 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 94 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| 95 | const double * const FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
|
|---|
| 96 | const double * const FullInverseMatrix = InverseMatrix(FullMatrix);
|
|---|
| [e138de] | 97 | eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [7ea9e6] | 98 | atom *Walker = (*MolWalker)->start;
|
|---|
| 99 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 100 | Walker = Walker->next;
|
|---|
| [e138de] | 101 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [7ea9e6] | 102 | if ((type1 == NULL) || (Walker->type == type1)) {
|
|---|
| 103 | periodicX.CopyVector(Walker->node);
|
|---|
| 104 | periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
|
|---|
| 105 | // go through every range in xyz and get distance
|
|---|
| 106 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 107 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 108 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 109 | checkX.Init(n[0], n[1], n[2]);
|
|---|
| 110 | checkX.AddVector(&periodicX);
|
|---|
| 111 | checkX.MatrixMultiplication(FullMatrix);
|
|---|
| 112 | for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
|
|---|
| 113 | if ((*MolOtherWalker)->ActiveFlag) {
|
|---|
| [e138de] | 114 | Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
|
|---|
| [7ea9e6] | 115 | atom *OtherWalker = (*MolOtherWalker)->start;
|
|---|
| 116 | while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
|
|---|
| 117 | OtherWalker = OtherWalker->next;
|
|---|
| [e138de] | 118 | Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
|
|---|
| [7ea9e6] | 119 | if (Walker->nr < OtherWalker->nr)
|
|---|
| 120 | if ((type2 == NULL) || (OtherWalker->type == type2)) {
|
|---|
| 121 | periodicOtherX.CopyVector(OtherWalker->node);
|
|---|
| 122 | periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
|
|---|
| 123 | // go through every range in xyz and get distance
|
|---|
| 124 | for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
|
|---|
| 125 | for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
|
|---|
| 126 | for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
|
|---|
| 127 | checkOtherX.Init(Othern[0], Othern[1], Othern[2]);
|
|---|
| 128 | checkOtherX.AddVector(&periodicOtherX);
|
|---|
| 129 | checkOtherX.MatrixMultiplication(FullMatrix);
|
|---|
| 130 | distance = checkX.Distance(&checkOtherX);
|
|---|
| [e138de] | 131 | //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
|
|---|
| [7ea9e6] | 132 | outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
|
|---|
| 133 | }
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 | }
|
|---|
| 138 | }
|
|---|
| 139 | }
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | return outmap;
|
|---|
| 143 | };
|
|---|
| 144 |
|
|---|
| [c4d4df] | 145 | /** Calculates the distance (pair) correlation between a given element and a point.
|
|---|
| 146 | * \param *out output stream for debugging
|
|---|
| [a5551b] | 147 | * \param *molecules list of molecules structure
|
|---|
| [c4d4df] | 148 | * \param *type element or NULL (if any element)
|
|---|
| 149 | * \param *point vector to the correlation point
|
|---|
| 150 | * \return Map of dobules with values as pairs of atom and the vector
|
|---|
| 151 | */
|
|---|
| [e138de] | 152 | CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )
|
|---|
| [c4d4df] | 153 | {
|
|---|
| 154 | CorrelationToPointMap *outmap = NULL;
|
|---|
| 155 | double distance = 0.;
|
|---|
| 156 |
|
|---|
| [a5551b] | 157 | if (molecules->ListOfMolecules.empty()) {
|
|---|
| [e138de] | 158 | Log() << Verbose(1) <<"No molecule given." << endl;
|
|---|
| [c4d4df] | 159 | return outmap;
|
|---|
| 160 | }
|
|---|
| 161 | outmap = new CorrelationToPointMap;
|
|---|
| [a5551b] | 162 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 163 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| [e138de] | 164 | Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [a5551b] | 165 | atom *Walker = (*MolWalker)->start;
|
|---|
| 166 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 167 | Walker = Walker->next;
|
|---|
| [e138de] | 168 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [a5551b] | 169 | if ((type == NULL) || (Walker->type == type)) {
|
|---|
| [99593f] | 170 | distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
|
|---|
| [e138de] | 171 | Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
|
|---|
| [a5551b] | 172 | outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
|
|---|
| 173 | }
|
|---|
| 174 | }
|
|---|
| [c4d4df] | 175 | }
|
|---|
| 176 |
|
|---|
| 177 | return outmap;
|
|---|
| 178 | };
|
|---|
| 179 |
|
|---|
| [7ea9e6] | 180 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
|
|---|
| 181 | * \param *out output stream for debugging
|
|---|
| 182 | * \param *molecules list of molecules structure
|
|---|
| 183 | * \param *type element or NULL (if any element)
|
|---|
| 184 | * \param *point vector to the correlation point
|
|---|
| 185 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 186 | * \return Map of dobules with values as pairs of atom and the vector
|
|---|
| 187 | */
|
|---|
| [e138de] | 188 | CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 189 | {
|
|---|
| 190 | CorrelationToPointMap *outmap = NULL;
|
|---|
| 191 | double distance = 0.;
|
|---|
| 192 | int n[NDIM];
|
|---|
| 193 | Vector periodicX;
|
|---|
| 194 | Vector checkX;
|
|---|
| 195 |
|
|---|
| 196 | if (molecules->ListOfMolecules.empty()) {
|
|---|
| [e138de] | 197 | Log() << Verbose(1) <<"No molecule given." << endl;
|
|---|
| [7ea9e6] | 198 | return outmap;
|
|---|
| 199 | }
|
|---|
| 200 | outmap = new CorrelationToPointMap;
|
|---|
| 201 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 202 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| 203 | const double * const FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
|
|---|
| 204 | const double * const FullInverseMatrix = InverseMatrix(FullMatrix);
|
|---|
| [e138de] | 205 | Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [7ea9e6] | 206 | atom *Walker = (*MolWalker)->start;
|
|---|
| 207 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 208 | Walker = Walker->next;
|
|---|
| [e138de] | 209 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [7ea9e6] | 210 | if ((type == NULL) || (Walker->type == type)) {
|
|---|
| 211 | periodicX.CopyVector(Walker->node);
|
|---|
| 212 | periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
|
|---|
| 213 | // go through every range in xyz and get distance
|
|---|
| 214 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 215 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 216 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 217 | checkX.Init(n[0], n[1], n[2]);
|
|---|
| 218 | checkX.AddVector(&periodicX);
|
|---|
| 219 | checkX.MatrixMultiplication(FullMatrix);
|
|---|
| 220 | distance = checkX.Distance(point);
|
|---|
| [e138de] | 221 | Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
|
|---|
| [7ea9e6] | 222 | outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
|
|---|
| 223 | }
|
|---|
| 224 | }
|
|---|
| 225 | }
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | return outmap;
|
|---|
| 229 | };
|
|---|
| 230 |
|
|---|
| [c4d4df] | 231 | /** Calculates the distance (pair) correlation between a given element and a surface.
|
|---|
| 232 | * \param *out output stream for debugging
|
|---|
| [a5551b] | 233 | * \param *molecules list of molecules structure
|
|---|
| [c4d4df] | 234 | * \param *type element or NULL (if any element)
|
|---|
| 235 | * \param *Surface pointer to Tesselation class surface
|
|---|
| 236 | * \param *LC LinkedCell structure to quickly find neighbouring atoms
|
|---|
| 237 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
|
|---|
| 238 | */
|
|---|
| [e138de] | 239 | CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
|
|---|
| [c4d4df] | 240 | {
|
|---|
| 241 | CorrelationToSurfaceMap *outmap = NULL;
|
|---|
| [99593f] | 242 | double distance = 0;
|
|---|
| [c4d4df] | 243 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 244 | Vector centroid;
|
|---|
| [7ea9e6] | 245 |
|
|---|
| 246 | if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
|
|---|
| [e138de] | 247 | Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
|
|---|
| [7ea9e6] | 248 | return outmap;
|
|---|
| 249 | }
|
|---|
| 250 | outmap = new CorrelationToSurfaceMap;
|
|---|
| 251 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 252 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| [e138de] | 253 | Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [7ea9e6] | 254 | atom *Walker = (*MolWalker)->start;
|
|---|
| 255 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 256 | Walker = Walker->next;
|
|---|
| [e138de] | 257 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [7ea9e6] | 258 | if ((type == NULL) || (Walker->type == type)) {
|
|---|
| [e138de] | 259 | triangle = Surface->FindClosestTriangleToPoint(Walker->node, LC );
|
|---|
| [7ea9e6] | 260 | if (triangle != NULL) {
|
|---|
| [e138de] | 261 | distance = DistanceToTrianglePlane(Walker->node, triangle);
|
|---|
| [7ea9e6] | 262 | outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
|
|---|
| 263 | }
|
|---|
| 264 | }
|
|---|
| 265 | }
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | return outmap;
|
|---|
| 269 | };
|
|---|
| 270 |
|
|---|
| 271 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and and a surface.
|
|---|
| 272 | * Note that we also put all periodic images found in the cells given by [ -ranges[i], ranges[i] ] and i=0,...,NDIM-1.
|
|---|
| 273 | * I.e. We multiply the atom::node with the inverse of the domain matrix, i.e. transform it to \f$[0,0^3\f$, then add per
|
|---|
| 274 | * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
|
|---|
| 275 | * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
|
|---|
| 276 | * \param *out output stream for debugging
|
|---|
| 277 | * \param *molecules list of molecules structure
|
|---|
| 278 | * \param *type element or NULL (if any element)
|
|---|
| 279 | * \param *Surface pointer to Tesselation class surface
|
|---|
| 280 | * \param *LC LinkedCell structure to quickly find neighbouring atoms
|
|---|
| 281 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 282 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
|
|---|
| 283 | */
|
|---|
| [e138de] | 284 | CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 285 | {
|
|---|
| 286 | CorrelationToSurfaceMap *outmap = NULL;
|
|---|
| 287 | double distance = 0;
|
|---|
| 288 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 289 | Vector centroid;
|
|---|
| [99593f] | 290 | int n[NDIM];
|
|---|
| 291 | Vector periodicX;
|
|---|
| 292 | Vector checkX;
|
|---|
| [c4d4df] | 293 |
|
|---|
| [a5551b] | 294 | if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
|
|---|
| [e138de] | 295 | Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
|
|---|
| [c4d4df] | 296 | return outmap;
|
|---|
| 297 | }
|
|---|
| 298 | outmap = new CorrelationToSurfaceMap;
|
|---|
| [a5551b] | 299 | for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
|
|---|
| 300 | if ((*MolWalker)->ActiveFlag) {
|
|---|
| [99593f] | 301 | const double * const FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
|
|---|
| 302 | const double * const FullInverseMatrix = InverseMatrix(FullMatrix);
|
|---|
| [e138de] | 303 | Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
|
|---|
| [a5551b] | 304 | atom *Walker = (*MolWalker)->start;
|
|---|
| 305 | while (Walker->next != (*MolWalker)->end) {
|
|---|
| 306 | Walker = Walker->next;
|
|---|
| [e138de] | 307 | Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
|
|---|
| [a5551b] | 308 | if ((type == NULL) || (Walker->type == type)) {
|
|---|
| [99593f] | 309 | periodicX.CopyVector(Walker->node);
|
|---|
| 310 | periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
|
|---|
| 311 | // go through every range in xyz and get distance
|
|---|
| 312 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 313 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 314 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 315 | checkX.Init(n[0], n[1], n[2]);
|
|---|
| 316 | checkX.AddVector(&periodicX);
|
|---|
| 317 | checkX.MatrixMultiplication(FullMatrix);
|
|---|
| [e138de] | 318 | triangle = Surface->FindClosestTriangleToPoint(&checkX, LC );
|
|---|
| [99593f] | 319 | if (triangle != NULL) {
|
|---|
| [e138de] | 320 | distance = DistanceToTrianglePlane(&checkX, triangle);
|
|---|
| [99593f] | 321 | outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
|
|---|
| 322 | }
|
|---|
| [a5551b] | 323 | }
|
|---|
| 324 | }
|
|---|
| [c4d4df] | 325 | }
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | return outmap;
|
|---|
| 329 | };
|
|---|
| 330 |
|
|---|
| 331 | /** Returns the start of the bin for a given value.
|
|---|
| 332 | * \param value value whose bin to look for
|
|---|
| 333 | * \param BinWidth width of bin
|
|---|
| 334 | * \param BinStart first bin
|
|---|
| 335 | */
|
|---|
| [776b64] | 336 | double GetBin ( const double value, const double BinWidth, const double BinStart )
|
|---|
| [c4d4df] | 337 | {
|
|---|
| 338 | double bin =(double) (floor((value - BinStart)/BinWidth));
|
|---|
| 339 | return (bin*BinWidth+BinStart);
|
|---|
| 340 | };
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 | /** Prints correlation (double, int) pairs to file.
|
|---|
| 344 | * \param *file file to write to
|
|---|
| 345 | * \param *map map to write
|
|---|
| 346 | */
|
|---|
| [a5551b] | 347 | void OutputCorrelation( ofstream * const file, const BinPairMap * const map )
|
|---|
| [c4d4df] | 348 | {
|
|---|
| 349 | *file << "# BinStart\tCount" << endl;
|
|---|
| [776b64] | 350 | for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
|
|---|
| [c4d4df] | 351 | *file << runner->first << "\t" << runner->second << endl;
|
|---|
| 352 | }
|
|---|
| 353 | };
|
|---|
| [b1f254] | 354 |
|
|---|
| 355 | /** Prints correlation (double, (atom*,atom*) ) pairs to file.
|
|---|
| 356 | * \param *file file to write to
|
|---|
| 357 | * \param *map map to write
|
|---|
| 358 | */
|
|---|
| [a5551b] | 359 | void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
|
|---|
| [b1f254] | 360 | {
|
|---|
| 361 | *file << "# BinStart\tAtom1\tAtom2" << endl;
|
|---|
| [776b64] | 362 | for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
|
|---|
| [b1f254] | 363 | *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
|
|---|
| 364 | }
|
|---|
| 365 | };
|
|---|
| 366 |
|
|---|
| 367 | /** Prints correlation (double, int) pairs to file.
|
|---|
| 368 | * \param *file file to write to
|
|---|
| 369 | * \param *map map to write
|
|---|
| 370 | */
|
|---|
| [a5551b] | 371 | void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map )
|
|---|
| [b1f254] | 372 | {
|
|---|
| 373 | *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl;
|
|---|
| [776b64] | 374 | for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
|
|---|
| [b1f254] | 375 | *file << runner->first;
|
|---|
| 376 | for (int i=0;i<NDIM;i++)
|
|---|
| 377 | *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);
|
|---|
| 378 | *file << endl;
|
|---|
| 379 | }
|
|---|
| 380 | };
|
|---|
| 381 |
|
|---|
| 382 | /** Prints correlation (double, int) pairs to file.
|
|---|
| 383 | * \param *file file to write to
|
|---|
| 384 | * \param *map map to write
|
|---|
| 385 | */
|
|---|
| [a5551b] | 386 | void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map )
|
|---|
| [b1f254] | 387 | {
|
|---|
| 388 | *file << "# BinStart\tTriangle" << endl;
|
|---|
| [776b64] | 389 | for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
|
|---|
| [b1f254] | 390 | *file << runner->first << "\t" << *(runner->second.second) << endl;
|
|---|
| 391 | }
|
|---|
| 392 | };
|
|---|
| 393 |
|
|---|