source: src/analysis_correlation.cpp@ 2f1a7a

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 2f1a7a was c94eeb, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Replaced several double* that were used as Matrixes with actuall matrix objects

  • Property mode set to 100644
File size: 23.0 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 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
139 Matrix FullMatrix = Matrix(FullMatrix_double);
140 Matrix FullInverseMatrix = FullMatrix.invert();
141 delete[](FullMatrix_double);
142 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
143 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
144 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
145 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
146 periodicX = *(*iter)->node;
147 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
148 // go through every range in xyz and get distance
149 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
150 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
151 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
152 checkX = Vector(n[0], n[1], n[2]) + periodicX;
153 checkX.MatrixMultiplication(FullMatrix);
154 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
155 if ((*MolOtherWalker)->ActiveFlag) {
156 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
157 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
158 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
159 if ((*iter)->getId() < (*runner)->getId()){
160 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
161 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
162 periodicOtherX = *(*runner)->node;
163 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
164 // go through every range in xyz and get distance
165 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
166 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
167 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
168 checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
169 checkOtherX.MatrixMultiplication(FullMatrix);
170 distance = checkX.distance(checkOtherX);
171 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
172 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
173 }
174 }
175 }
176 }
177 }
178 }
179 }
180 }
181 }
182 }
183
184 return outmap;
185};
186
187/** Calculates the distance (pair) correlation between a given element and a point.
188 * \param *molecules list of molecules structure
189 * \param &elements vector of elements to correlate with point
190 * \param *point vector to the correlation point
191 * \return Map of dobules with values as pairs of atom and the vector
192 */
193CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
194{
195 Info FunctionInfo(__func__);
196 CorrelationToPointMap *outmap = NULL;
197 double distance = 0.;
198 double *cell_size = World::getInstance().getDomain();
199
200 if (molecules->ListOfMolecules.empty()) {
201 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
202 return outmap;
203 }
204 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
205 (*MolWalker)->doCountAtoms();
206 outmap = new CorrelationToPointMap;
207 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
208 if ((*MolWalker)->ActiveFlag) {
209 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
210 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
211 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
212 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
213 if ((*type == NULL) || ((*iter)->type == *type)) {
214 distance = (*iter)->node->PeriodicDistance(*point, cell_size);
215 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
216 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
217 }
218 }
219 }
220
221 return outmap;
222};
223
224/** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
225 * \param *molecules list of molecules structure
226 * \param &elements vector of elements to correlate to point
227 * \param *point vector to the correlation point
228 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
229 * \return Map of dobules with values as pairs of atom and the vector
230 */
231CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
232{
233 Info FunctionInfo(__func__);
234 CorrelationToPointMap *outmap = NULL;
235 double distance = 0.;
236 int n[NDIM];
237 Vector periodicX;
238 Vector checkX;
239
240 if (molecules->ListOfMolecules.empty()) {
241 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
242 return outmap;
243 }
244 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
245 (*MolWalker)->doCountAtoms();
246 outmap = new CorrelationToPointMap;
247 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
248 if ((*MolWalker)->ActiveFlag) {
249 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
250 Matrix FullMatrix = Matrix(FullMatrix_double);
251 Matrix FullInverseMatrix = FullMatrix.invert();
252 delete[] FullMatrix_double;
253 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
254 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
255 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
256 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
257 if ((*type == NULL) || ((*iter)->type == *type)) {
258 periodicX = *(*iter)->node;
259 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
260 // go through every range in xyz and get distance
261 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
262 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
263 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
264 checkX = Vector(n[0], n[1], n[2]) + periodicX;
265 checkX.MatrixMultiplication(FullMatrix);
266 distance = checkX.distance(*point);
267 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
268 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
269 }
270 }
271 }
272 }
273
274 return outmap;
275};
276
277/** Calculates the distance (pair) correlation between a given element and a surface.
278 * \param *molecules list of molecules structure
279 * \param &elements vector of elements to correlate to surface
280 * \param *Surface pointer to Tesselation class surface
281 * \param *LC LinkedCell structure to quickly find neighbouring atoms
282 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
283 */
284CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
285{
286 Info FunctionInfo(__func__);
287 CorrelationToSurfaceMap *outmap = NULL;
288 double distance = 0;
289 class BoundaryTriangleSet *triangle = NULL;
290 Vector centroid;
291
292 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
293 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
294 return outmap;
295 }
296 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
297 (*MolWalker)->doCountAtoms();
298 outmap = new CorrelationToSurfaceMap;
299 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
300 if ((*MolWalker)->ActiveFlag) {
301 DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
302 if ((*MolWalker)->empty())
303 DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
304 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
305 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
306 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
307 if ((*type == NULL) || ((*iter)->type == *type)) {
308 TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
309 distance = Intersections.GetSmallestDistance();
310 triangle = Intersections.GetClosestTriangle();
311 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
312 }
313 }
314 } else {
315 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
316 }
317
318 return outmap;
319};
320
321/** Calculates the distance (pair) correlation between a given element, all its periodic images and and a surface.
322 * Note that we also put all periodic images found in the cells given by [ -ranges[i], ranges[i] ] and i=0,...,NDIM-1.
323 * 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
324 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
325 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
326 * \param *molecules list of molecules structure
327 * \param &elements vector of elements to correlate to surface
328 * \param *Surface pointer to Tesselation class surface
329 * \param *LC LinkedCell structure to quickly find neighbouring atoms
330 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
331 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
332 */
333CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
334{
335 Info FunctionInfo(__func__);
336 CorrelationToSurfaceMap *outmap = NULL;
337 double distance = 0;
338 class BoundaryTriangleSet *triangle = NULL;
339 Vector centroid;
340 int n[NDIM];
341 Vector periodicX;
342 Vector checkX;
343
344 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
345 DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
346 return outmap;
347 }
348 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
349 (*MolWalker)->doCountAtoms();
350 outmap = new CorrelationToSurfaceMap;
351 double ShortestDistance = 0.;
352 BoundaryTriangleSet *ShortestTriangle = NULL;
353 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
354 if ((*MolWalker)->ActiveFlag) {
355 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
356 Matrix FullMatrix = Matrix(FullMatrix_double);
357 Matrix FullInverseMatrix = FullMatrix.invert();
358 delete[](FullMatrix_double);
359 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
360 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
361 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
362 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
363 if ((*type == NULL) || ((*iter)->type == *type)) {
364 periodicX = *(*iter)->node;
365 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
366 // go through every range in xyz and get distance
367 ShortestDistance = -1.;
368 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
369 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
370 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
371 checkX = Vector(n[0], n[1], n[2]) + periodicX;
372 checkX.MatrixMultiplication(FullMatrix);
373 TriangleIntersectionList Intersections(&checkX,Surface,LC);
374 distance = Intersections.GetSmallestDistance();
375 triangle = Intersections.GetClosestTriangle();
376 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
377 ShortestDistance = distance;
378 ShortestTriangle = triangle;
379 }
380 }
381 // insert
382 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
383 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
384 }
385 }
386 }
387
388 return outmap;
389};
390
391/** Returns the index of the bin for a given value.
392 * \param value value whose bin to look for
393 * \param BinWidth width of bin
394 * \param BinStart first bin
395 */
396int GetBin ( const double value, const double BinWidth, const double BinStart )
397{
398 Info FunctionInfo(__func__);
399 int bin =(int) (floor((value - BinStart)/BinWidth));
400 return (bin);
401};
402
403
404/** Prints correlation (double, int) pairs to file.
405 * \param *file file to write to
406 * \param *map map to write
407 */
408void OutputCorrelation( ofstream * const file, const BinPairMap * const map )
409{
410 Info FunctionInfo(__func__);
411 *file << "BinStart\tCount" << endl;
412 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
413 *file << setprecision(8) << runner->first << "\t" << runner->second << endl;
414 }
415};
416
417/** Prints correlation (double, (atom*,atom*) ) pairs to file.
418 * \param *file file to write to
419 * \param *map map to write
420 */
421void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
422{
423 Info FunctionInfo(__func__);
424 *file << "BinStart\tAtom1\tAtom2" << endl;
425 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
426 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
427 }
428};
429
430/** Prints correlation (double, int) pairs to file.
431 * \param *file file to write to
432 * \param *map map to write
433 */
434void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map )
435{
436 Info FunctionInfo(__func__);
437 *file << "BinStart\tAtom::x[i]-point.x[i]" << endl;
438 for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
439 *file << runner->first;
440 for (int i=0;i<NDIM;i++)
441 *file << "\t" << setprecision(8) << (runner->second.first->node->at(i) - runner->second.second->at(i));
442 *file << endl;
443 }
444};
445
446/** Prints correlation (double, int) pairs to file.
447 * \param *file file to write to
448 * \param *map map to write
449 */
450void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map )
451{
452 Info FunctionInfo(__func__);
453 *file << "BinStart\tTriangle" << endl;
454 if (!map->empty())
455 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
456 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
457 }
458};
459
Note: See TracBrowser for help on using the repository browser.