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