source: src/analysis_correlation.hpp@ 7326b2

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 7326b2 was 7ea9e6, checked in by Frederik Heber <heber@…>, 16 years ago

Periodic variants of AnalysisPair...() implemented.

  • BUGFIX: Vector::DistanceToPlane() - we did not check whether sign is 0.
  • NOTE: Due to changes in Vector::DistanceToPlane() with sign, Unit test AnalysisCorrelationToSurfaceUnitTest had to be changed:
    • we now have bin -0.5 filled with 1 (instead of 0.) and -0.288 instead of 0.288
    • find() replaced by lower_bound
  • new functions: PeriodicPairCorrelation(), PeriodicCorrelationToPoint(), PeriodicCorrelationToSurface()
    • each has a ranges[NDIM] argument with specifies the neighbours to scan: [ -ranges[i], ranges[i] ]
    • the atom::node is periodically translated to each periodic cell and the distance calculated.
  • NOTE: make check was broken before due to implementation of Periodic variants as normal ones (yielding more points that expected in unit test).

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * analysis.hpp
3 *
4 * Created on: Oct 13, 2009
5 * Author: heber
6 */
7
8#ifndef ANALYSIS_HPP_
9#define ANALYSIS_HPP_
10
11using namespace std;
12
13/*********************************************** includes ***********************************/
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <fstream>
21
22// STL headers
23#include <map>
24
25#include "defs.hpp"
26
27#include "atom.hpp"
28
29/****************************************** forward declarations *****************************/
30
31class BoundaryTriangleSet;
32class element;
33class LinkedCell;
34class MoleculeListClass;
35class Tesselation;
36class Vector;
37
38/********************************************** definitions *********************************/
39
40typedef multimap<double, pair<atom *, atom *> > PairCorrelationMap;
41typedef multimap<double, pair<atom *, const Vector *> > CorrelationToPointMap;
42typedef multimap<double, pair<atom *, BoundaryTriangleSet *> > CorrelationToSurfaceMap;
43typedef map<double, int> BinPairMap;
44
45/********************************************** declarations *******************************/
46
47PairCorrelationMap *PairCorrelation( ofstream * const out, MoleculeListClass * const &molecules, const element * const type1, const element * const type2 );
48CorrelationToPointMap *CorrelationToPoint( ofstream * const out, MoleculeListClass * const &molecules, const element * const type, const Vector *point );
49CorrelationToSurfaceMap *CorrelationToSurface( ofstream * const out, MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );
50PairCorrelationMap *PeriodicPairCorrelation( ofstream * const out, MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] );
51CorrelationToPointMap *PeriodicCorrelationToPoint( ofstream * const out, MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );
52CorrelationToSurfaceMap *PeriodicCorrelationToSurface( ofstream * const out, MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
53double GetBin ( const double value, const double BinWidth, const double BinStart );
54void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
55void OutputPairCorrelation( ofstream * const file, const BinPairMap * const map );
56void OutputCorrelationToPoint( ofstream * const file, const BinPairMap * const map );
57void OutputCorrelationToSurface( ofstream * const file, const BinPairMap * const map );
58
59
60/** Searches for lowest and highest value in a given map of doubles.
61 * \param *map map of doubles to scan
62 * \param &min minimum on return
63 * \param &max maximum on return
64 */
65template <typename T> void GetMinMax ( T *map, double &min, double &max)
66{
67 min = 0.;
68 max = 0.;
69 bool FirstMinFound = false;
70 bool FirstMaxFound = false;
71
72 if (map == NULL) {
73 cerr << "Nothing to min/max, map is NULL!" << endl;
74 return;
75 }
76
77 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) {
78 if ((min > runner->first) || (!FirstMinFound)) {
79 min = runner->first;
80 FirstMinFound = true;
81 }
82 if ((max < runner->first) || (!FirstMaxFound)) {
83 max = runner->first;
84 FirstMaxFound = true;
85 }
86 }
87};
88
89/** Puts given correlation data into bins of given size (histogramming).
90 * Note that BinStart and BinEnd are desired to fill the complete range, even where Bins are zero. If this is
91 * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater.
92 * Also note that the range is given inclusive, i.e. [ BinStart, BinEnd ].
93 * \param *out output stream for debugging
94 * \param *map map of doubles to count
95 * \param BinWidth desired width of the binds
96 * \param BinStart first bin
97 * \param BinEnd last bin
98 * \return Map of doubles (the bins) with counts as values
99 */
100template <typename T> BinPairMap *BinData ( ofstream *out, T *map, const double BinWidth, const double BinStart, const double BinEnd )
101{
102 BinPairMap *outmap = new BinPairMap;
103 double bin = 0.;
104 double start = 0.;
105 double end = 0.;
106 pair <BinPairMap::iterator, bool > BinPairMapInserter;
107
108 if (map == NULL) {
109 cerr << "Nothing to bin, is NULL!" << endl;
110 return outmap;
111 }
112
113 if (BinStart == BinEnd) { // if same, find range ourselves
114 GetMinMax( map, start, end);
115 } else { // if not, initialise range to zero
116 start = BinStart;
117 end = BinEnd;
118 for (double runner = start; runner <= end; runner += BinWidth)
119 outmap->insert( pair<double, int> (runner, 0) );
120 }
121
122 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) {
123 bin = GetBin (runner->first, BinWidth, start);
124 BinPairMapInserter = outmap->insert ( pair<double, int> (bin, 1) );
125 if (!BinPairMapInserter.second) { // bin already present, increase
126 BinPairMapInserter.first->second += 1;
127 }
128 }
129
130 return outmap;
131};
132
133#endif /* ANALYSIS_HPP_ */
Note: See TracBrowser for help on using the repository browser.