source: src/analysis_correlation.cpp@ 436f04

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
Last change on this file since 436f04 was d10eb6, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Made the ReturnFullMatrixForSymmetric return a Matrix object directely instead of a double array

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