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