source: src/analysis_correlation.cpp@ a7b761b

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 Candidate_v1.7.0 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 a7b761b was a7b761b, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'MoleculeStartEndSwitch' into StructureRefactoring

Conflicts:

molecuilder/src/Helpers/Assert.cpp
molecuilder/src/Helpers/Assert.hpp
molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/Patterns/Cacheable.hpp
molecuilder/src/Patterns/Observer.cpp
molecuilder/src/Patterns/Observer.hpp
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule.hpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/ObserverTest.cpp
molecuilder/src/unittests/ObserverTest.hpp

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