| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | /* | 
|---|
| 9 | * analysis.cpp | 
|---|
| 10 | * | 
|---|
| 11 | *  Created on: Oct 13, 2009 | 
|---|
| 12 | *      Author: heber | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | // include config.h | 
|---|
| 16 | #ifdef HAVE_CONFIG_H | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | #include "CodePatterns/MemDebug.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | #include <iostream> | 
|---|
| 23 | #include <iomanip> | 
|---|
| 24 | #include <limits> | 
|---|
| 25 |  | 
|---|
| 26 | #include "Atom/atom.hpp" | 
|---|
| 27 | #include "Bond/bond.hpp" | 
|---|
| 28 | #include "Tesselation/BoundaryTriangleSet.hpp" | 
|---|
| 29 | #include "Box.hpp" | 
|---|
| 30 | #include "Element/element.hpp" | 
|---|
| 31 | #include "CodePatterns/Info.hpp" | 
|---|
| 32 | #include "CodePatterns/Log.hpp" | 
|---|
| 33 | #include "CodePatterns/Verbose.hpp" | 
|---|
| 34 | #include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp" | 
|---|
| 35 | #include "Descriptors/MoleculeFormulaDescriptor.hpp" | 
|---|
| 36 | #include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp" | 
|---|
| 37 | #include "Formula.hpp" | 
|---|
| 38 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| 39 | #include "LinearAlgebra/RealSpaceMatrix.hpp" | 
|---|
| 40 | #include "molecule.hpp" | 
|---|
| 41 | #include "Tesselation/tesselation.hpp" | 
|---|
| 42 | #include "Tesselation/tesselationhelpers.hpp" | 
|---|
| 43 | #include "Tesselation/triangleintersectionlist.hpp" | 
|---|
| 44 | #include "World.hpp" | 
|---|
| 45 | #include "WorldTime.hpp" | 
|---|
| 46 |  | 
|---|
| 47 | #include "analysis_correlation.hpp" | 
|---|
| 48 |  | 
|---|
| 49 | /** Calculates the dipole vector of a given atomSet. | 
|---|
| 50 | * | 
|---|
| 51 | *  Note that we use the following procedure as rule of thumb: | 
|---|
| 52 | *   -# go through every bond of the atom | 
|---|
| 53 | *   -# calculate the difference of electronegativities \f$\Delta\mathrm{EN}\f$ | 
|---|
| 54 | *   -# if \f$\Delta\mathrm{EN} > 0.5\f$, we align the bond vector in direction of the more negative element | 
|---|
| 55 | *   -# sum up all vectors | 
|---|
| 56 | *   -# finally, divide by the number of summed vectors | 
|---|
| 57 | * | 
|---|
| 58 | * @param atomsbegin begin iterator of atomSet | 
|---|
| 59 | * @param atomsend end iterator of atomset | 
|---|
| 60 | * @return dipole vector | 
|---|
| 61 | */ | 
|---|
| 62 | Vector getDipole(molecule::const_iterator atomsbegin, molecule::const_iterator atomsend) | 
|---|
| 63 | { | 
|---|
| 64 | Vector DipoleVector; | 
|---|
| 65 | size_t SumOfVectors = 0; | 
|---|
| 66 | // go through all atoms | 
|---|
| 67 | for (molecule::const_iterator atomiter = atomsbegin; | 
|---|
| 68 | atomiter != atomsend; | 
|---|
| 69 | ++atomiter) { | 
|---|
| 70 | // go through all bonds | 
|---|
| 71 | const BondList& ListOfBonds = (*atomiter)->getListOfBonds(); | 
|---|
| 72 | ASSERT(ListOfBonds.begin() != ListOfBonds.end(), | 
|---|
| 73 | "getDipole() - no bonds in molecule!"); | 
|---|
| 74 | for (BondList::const_iterator bonditer = ListOfBonds.begin(); | 
|---|
| 75 | bonditer != ListOfBonds.end(); | 
|---|
| 76 | ++bonditer) { | 
|---|
| 77 | const atom * Otheratom = (*bonditer)->GetOtherAtom(*atomiter); | 
|---|
| 78 | if (Otheratom->getId() > (*atomiter)->getId()) { | 
|---|
| 79 | const double DeltaEN = (*atomiter)->getType()->getElectronegativity() | 
|---|
| 80 | -Otheratom->getType()->getElectronegativity(); | 
|---|
| 81 | Vector BondDipoleVector = (*atomiter)->getPosition() - Otheratom->getPosition(); | 
|---|
| 82 | // DeltaEN is always positive, gives correct orientation of vector | 
|---|
| 83 | BondDipoleVector.Normalize(); | 
|---|
| 84 | BondDipoleVector *= DeltaEN; | 
|---|
| 85 | LOG(3,"INFO: Dipole vector from bond " << **bonditer << " is " << BondDipoleVector); | 
|---|
| 86 | DipoleVector += BondDipoleVector; | 
|---|
| 87 | SumOfVectors++; | 
|---|
| 88 | } | 
|---|
| 89 | } | 
|---|
| 90 | } | 
|---|
| 91 | LOG(3,"INFO: Sum over all bond dipole vectors is " | 
|---|
| 92 | << DipoleVector << " with " << SumOfVectors << " in total."); | 
|---|
| 93 | if (SumOfVectors != 0) | 
|---|
| 94 | DipoleVector *= 1./(double)SumOfVectors; | 
|---|
| 95 | LOG(2, "INFO: Resulting dipole vector is " << DipoleVector); | 
|---|
| 96 |  | 
|---|
| 97 | return DipoleVector; | 
|---|
| 98 | }; | 
|---|
| 99 |  | 
|---|
| 100 | /** Calculate minimum and maximum amount of trajectory steps by going through given atomic trajectories. | 
|---|
| 101 | * \param vector of atoms whose trajectories to check for [min,max] | 
|---|
| 102 | * \return range with [min, max] | 
|---|
| 103 | */ | 
|---|
| 104 | range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms) | 
|---|
| 105 | { | 
|---|
| 106 | // get highest trajectory size | 
|---|
| 107 | LOG(0,"STATUS: Retrieving maximum amount of time steps ..."); | 
|---|
| 108 | if (atoms.size() == 0) | 
|---|
| 109 | return range<size_t>(0,0); | 
|---|
| 110 | size_t max_timesteps = std::numeric_limits<size_t>::min(); | 
|---|
| 111 | size_t min_timesteps = std::numeric_limits<size_t>::max(); | 
|---|
| 112 | BOOST_FOREACH(atom *_atom, atoms) { | 
|---|
| 113 | if (_atom->getTrajectorySize() > max_timesteps) | 
|---|
| 114 | max_timesteps  = _atom->getTrajectorySize(); | 
|---|
| 115 | if (_atom->getTrajectorySize() < min_timesteps) | 
|---|
| 116 | min_timesteps = _atom->getTrajectorySize(); | 
|---|
| 117 | } | 
|---|
| 118 | LOG(1,"INFO: Minimum number of time steps found is " << min_timesteps); | 
|---|
| 119 | LOG(1,"INFO: Maximum number of time steps found is " << max_timesteps); | 
|---|
| 120 |  | 
|---|
| 121 | return range<size_t>(min_timesteps, max_timesteps); | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | /** Calculates the angular dipole zero orientation from current time step. | 
|---|
| 125 | * \param molecules vector of molecules to calculate dipoles of | 
|---|
| 126 | * \return map with orientation vector for each atomic id given in \a atoms. | 
|---|
| 127 | */ | 
|---|
| 128 | std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules) | 
|---|
| 129 | { | 
|---|
| 130 | // get zero orientation for each molecule. | 
|---|
| 131 | LOG(0,"STATUS: Calculating dipoles for current time step ..."); | 
|---|
| 132 | std::map<atomId_t, Vector> ZeroVector; | 
|---|
| 133 | BOOST_FOREACH(molecule *_mol, molecules) { | 
|---|
| 134 | const Vector Dipole = getDipole(_mol->begin(), _mol->end()); | 
|---|
| 135 | for(molecule::const_iterator iter = _mol->begin(); iter != _mol->end(); ++iter) | 
|---|
| 136 | ZeroVector[(*iter)->getId()] = Dipole; | 
|---|
| 137 | LOG(2,"INFO: Zero alignment for molecule " << _mol->getId() << " is " << Dipole); | 
|---|
| 138 | } | 
|---|
| 139 | LOG(1,"INFO: We calculated zero orientation for a total of " << molecules.size() << " molecule(s)."); | 
|---|
| 140 |  | 
|---|
| 141 | return ZeroVector; | 
|---|
| 142 | } | 
|---|
| 143 |  | 
|---|
| 144 | /** Calculates the dipole angular correlation for given molecule type. | 
|---|
| 145 | * Calculate the change of the dipole orientation angle over time. | 
|---|
| 146 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) | 
|---|
| 147 | * Angles are given in degrees. | 
|---|
| 148 | * \param &atoms list of atoms of the molecules taking part (Note: molecules may | 
|---|
| 149 | * change over time as bond structure is recalculated, hence we need the atoms) | 
|---|
| 150 | * \param timestep time step to calculate angular correlation for (relative to | 
|---|
| 151 | *  \a ZeroVector) | 
|---|
| 152 | * \param ZeroVector map with Zero orientation vector for each atom in \a atoms. | 
|---|
| 153 | * \param DontResetTime don't reset time to old value (triggers re-creation of bond system) | 
|---|
| 154 | * \return Map of doubles with values the pair of the two atoms. | 
|---|
| 155 | */ | 
|---|
| 156 | DipoleAngularCorrelationMap *DipoleAngularCorrelation( | 
|---|
| 157 | const Formula &DipoleFormula, | 
|---|
| 158 | const size_t timestep, | 
|---|
| 159 | const std::map<atomId_t, Vector> &ZeroVector, | 
|---|
| 160 | const enum ResetWorldTime DoTimeReset | 
|---|
| 161 | ) | 
|---|
| 162 | { | 
|---|
| 163 | Info FunctionInfo(__func__); | 
|---|
| 164 | DipoleAngularCorrelationMap *outmap = new DipoleAngularCorrelationMap; | 
|---|
| 165 |  | 
|---|
| 166 | unsigned int oldtime = 0; | 
|---|
| 167 | if (DoTimeReset == DoResetTime) { | 
|---|
| 168 | // store original time step | 
|---|
| 169 | oldtime = WorldTime::getTime(); | 
|---|
| 170 | } | 
|---|
| 171 |  | 
|---|
| 172 | // set time step | 
|---|
| 173 | LOG(0,"STATUS: Stepping onto to time step " << timestep << "."); | 
|---|
| 174 | World::getInstance().setTime(timestep); | 
|---|
| 175 |  | 
|---|
| 176 | // get all molecules for this time step | 
|---|
| 177 | World::getInstance().clearMoleculeSelection(); | 
|---|
| 178 | World::getInstance().selectAllMolecules(MoleculeByFormula(DipoleFormula)); | 
|---|
| 179 | std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules(); | 
|---|
| 180 | LOG(1,"INFO: There are " << molecules.size() << " molecules for time step " << timestep << "."); | 
|---|
| 181 |  | 
|---|
| 182 | // calculate dipoles for each | 
|---|
| 183 | LOG(0,"STATUS: Calculating dipoles for time step " << timestep << " ..."); | 
|---|
| 184 | size_t i=0; | 
|---|
| 185 | size_t Counter_rejections = 0; | 
|---|
| 186 | BOOST_FOREACH(molecule *_mol, molecules) { | 
|---|
| 187 | const Vector Dipole = getDipole(_mol->begin(), _mol->end()); | 
|---|
| 188 | LOG(3,"INFO: Dipole vector at time step " << timestep << " for for molecule " | 
|---|
| 189 | << _mol->getId() << " is " << Dipole); | 
|---|
| 190 | // check that all atoms are valid (zeroVector known) | 
|---|
| 191 | molecule::const_iterator iter = _mol->begin(); | 
|---|
| 192 | for(; iter != _mol->end(); ++iter) { | 
|---|
| 193 | if (!ZeroVector.count((*iter)->getId())) | 
|---|
| 194 | break; | 
|---|
| 195 | } | 
|---|
| 196 | if (iter != _mol->end()) { | 
|---|
| 197 | ELOG(2, "Skipping molecule " << _mol->getName() << " as not all atoms have a valid zeroVector."); | 
|---|
| 198 | ++Counter_rejections; | 
|---|
| 199 | continue; | 
|---|
| 200 | } else | 
|---|
| 201 | iter = _mol->begin(); | 
|---|
| 202 | std::map<atomId_t, Vector>::const_iterator zeroValue = ZeroVector.find((*iter)->getId()); //due to iter is const | 
|---|
| 203 | double angle = 0.; | 
|---|
| 204 | LOG(2, "INFO: ZeroVector of first atom " << **iter << " is " | 
|---|
| 205 | << zeroValue->second << "."); | 
|---|
| 206 | LOG(4, "INFO: Squared norm of difference vector is " | 
|---|
| 207 | << (zeroValue->second - Dipole).NormSquared() << "."); | 
|---|
| 208 | if ((zeroValue->second - Dipole).NormSquared() > MYEPSILON) | 
|---|
| 209 | angle = Dipole.Angle(zeroValue->second) * (180./M_PI); | 
|---|
| 210 | else | 
|---|
| 211 | LOG(2, "INFO: Both vectors (almost) coincide, numerically unstable, angle set to zero."); | 
|---|
| 212 | LOG(1,"INFO: Resulting relative angle for molecule " << _mol->getName() | 
|---|
| 213 | << " is " << angle << "."); | 
|---|
| 214 | outmap->insert ( std::make_pair (angle, *iter ) ); | 
|---|
| 215 | ++i; | 
|---|
| 216 | } | 
|---|
| 217 | ASSERT(Counter_rejections <= molecules.size(), | 
|---|
| 218 | "DipoleAngularCorrelation() - more rejections ("+toString(Counter_rejections) | 
|---|
| 219 | +") than there are molecules ("+toString(molecules.size())+")."); | 
|---|
| 220 | LOG(1,"INFO: " << Counter_rejections << " molecules have been rejected in time step " << timestep << "."); | 
|---|
| 221 |  | 
|---|
| 222 | LOG(0,"STATUS: Done with calculating dipoles."); | 
|---|
| 223 |  | 
|---|
| 224 | if (DoTimeReset == DoResetTime) { | 
|---|
| 225 | // re-set to original time step again | 
|---|
| 226 | World::getInstance().setTime(oldtime); | 
|---|
| 227 | } | 
|---|
| 228 |  | 
|---|
| 229 | // and return results | 
|---|
| 230 | return outmap; | 
|---|
| 231 | }; | 
|---|
| 232 |  | 
|---|
| 233 | /** Calculates the dipole correlation for given molecule type. | 
|---|
| 234 | * I.e. we calculate how the angle between any two given dipoles in the | 
|---|
| 235 | * systems behaves. Sort of pair correlation but distance is replaced by | 
|---|
| 236 | * the orientation distance, i.e. an angle. | 
|---|
| 237 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) | 
|---|
| 238 | * Angles are given in degrees. | 
|---|
| 239 | * \param *molecules vector of molecules | 
|---|
| 240 | * \return Map of doubles with values the pair of the two atoms. | 
|---|
| 241 | */ | 
|---|
| 242 | DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules) | 
|---|
| 243 | { | 
|---|
| 244 | Info FunctionInfo(__func__); | 
|---|
| 245 | DipoleCorrelationMap *outmap = new DipoleCorrelationMap; | 
|---|
| 246 | //  double distance = 0.; | 
|---|
| 247 | //  Box &domain = World::getInstance().getDomain(); | 
|---|
| 248 | // | 
|---|
| 249 | if (molecules.empty()) { | 
|---|
| 250 | ELOG(1, "No molecule given."); | 
|---|
| 251 | return outmap; | 
|---|
| 252 | } | 
|---|
| 253 |  | 
|---|
| 254 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); | 
|---|
| 255 | MolWalker != molecules.end(); ++MolWalker) { | 
|---|
| 256 | LOG(2, "INFO: Current molecule is " << (*MolWalker)->getId() << "."); | 
|---|
| 257 | const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end()); | 
|---|
| 258 | std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; | 
|---|
| 259 | for (++MolOtherWalker; | 
|---|
| 260 | MolOtherWalker != molecules.end(); | 
|---|
| 261 | ++MolOtherWalker) { | 
|---|
| 262 | LOG(2, "INFO: Current other molecule is " << (*MolOtherWalker)->getId() << "."); | 
|---|
| 263 | const Vector OtherDipole = getDipole((*MolOtherWalker)->begin(), (*MolOtherWalker)->end()); | 
|---|
| 264 | const double angle = Dipole.Angle(OtherDipole) * (180./M_PI); | 
|---|
| 265 | LOG(1, "Angle is " << angle << "."); | 
|---|
| 266 | outmap->insert ( make_pair (angle, make_pair ((*MolWalker), (*MolOtherWalker)) ) ); | 
|---|
| 267 | } | 
|---|
| 268 | } | 
|---|
| 269 | return outmap; | 
|---|
| 270 | }; | 
|---|
| 271 |  | 
|---|
| 272 |  | 
|---|
| 273 | /** Calculates the pair correlation between given elements. | 
|---|
| 274 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) | 
|---|
| 275 | * \param *molecules vector of molecules | 
|---|
| 276 | * \param &elements vector of elements to correlate | 
|---|
| 277 | * \return Map of doubles with values the pair of the two atoms. | 
|---|
| 278 | */ | 
|---|
| 279 | PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements) | 
|---|
| 280 | { | 
|---|
| 281 | Info FunctionInfo(__func__); | 
|---|
| 282 | PairCorrelationMap *outmap = new PairCorrelationMap; | 
|---|
| 283 | double distance = 0.; | 
|---|
| 284 | Box &domain = World::getInstance().getDomain(); | 
|---|
| 285 |  | 
|---|
| 286 | if (molecules.empty()) { | 
|---|
| 287 | ELOG(1, "No molecule given."); | 
|---|
| 288 | return outmap; | 
|---|
| 289 | } | 
|---|
| 290 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 291 | (*MolWalker)->doCountAtoms(); | 
|---|
| 292 |  | 
|---|
| 293 | // create all possible pairs of elements | 
|---|
| 294 | set <pair<const element *,const element *> > PairsOfElements; | 
|---|
| 295 | if (elements.size() >= 2) { | 
|---|
| 296 | for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) | 
|---|
| 297 | for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) | 
|---|
| 298 | if (type1 != type2) { | 
|---|
| 299 | PairsOfElements.insert( make_pair(*type1,*type2) ); | 
|---|
| 300 | LOG(1, "Creating element pair " << *(*type1) << " and " << *(*type2) << "."); | 
|---|
| 301 | } | 
|---|
| 302 | } else if (elements.size() == 1) { // one to all are valid | 
|---|
| 303 | const element *elemental = *elements.begin(); | 
|---|
| 304 | PairsOfElements.insert( pair<const element *,const element*>(elemental,0) ); | 
|---|
| 305 | PairsOfElements.insert( pair<const element *,const element*>(0,elemental) ); | 
|---|
| 306 | } else { // all elements valid | 
|---|
| 307 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); | 
|---|
| 308 | } | 
|---|
| 309 |  | 
|---|
| 310 | outmap = new PairCorrelationMap; | 
|---|
| 311 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ | 
|---|
| 312 | LOG(2, "Current molecule is " << (*MolWalker)->getName() << "."); | 
|---|
| 313 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 314 | LOG(3, "Current atom is " << **iter << "."); | 
|---|
| 315 | for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ | 
|---|
| 316 | LOG(2, "Current other molecule is " << (*MolOtherWalker)->getName() << "."); | 
|---|
| 317 | for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { | 
|---|
| 318 | LOG(3, "Current otheratom is " << **runner << "."); | 
|---|
| 319 | if ((*iter)->getId() < (*runner)->getId()){ | 
|---|
| 320 | for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) | 
|---|
| 321 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { | 
|---|
| 322 | distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition()); | 
|---|
| 323 | //LOG(1, "Inserting " << *(*iter) << " and " << *(*runner)); | 
|---|
| 324 | outmap->insert ( | 
|---|
| 325 | std::pair<double, std::pair <const atom *, const atom*> > ( | 
|---|
| 326 | distance, | 
|---|
| 327 | std::pair<const atom *, const atom*> ((*iter), (*runner)) | 
|---|
| 328 | ) | 
|---|
| 329 | ); | 
|---|
| 330 | } | 
|---|
| 331 | } | 
|---|
| 332 | } | 
|---|
| 333 | } | 
|---|
| 334 | } | 
|---|
| 335 | } | 
|---|
| 336 | return outmap; | 
|---|
| 337 | }; | 
|---|
| 338 |  | 
|---|
| 339 | /** Calculates the pair correlation between given elements. | 
|---|
| 340 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) | 
|---|
| 341 | * \param *molecules list of molecules structure | 
|---|
| 342 | * \param &elements vector of elements to correlate | 
|---|
| 343 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also | 
|---|
| 344 | * \return Map of doubles with values the pair of the two atoms. | 
|---|
| 345 | */ | 
|---|
| 346 | PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] ) | 
|---|
| 347 | { | 
|---|
| 348 | Info FunctionInfo(__func__); | 
|---|
| 349 | PairCorrelationMap *outmap = new PairCorrelationMap; | 
|---|
| 350 | double distance = 0.; | 
|---|
| 351 | int n[NDIM]; | 
|---|
| 352 | Vector checkX; | 
|---|
| 353 | Vector periodicX; | 
|---|
| 354 | int Othern[NDIM]; | 
|---|
| 355 | Vector checkOtherX; | 
|---|
| 356 | Vector periodicOtherX; | 
|---|
| 357 |  | 
|---|
| 358 | if (molecules.empty()) { | 
|---|
| 359 | ELOG(1, "No molecule given."); | 
|---|
| 360 | return outmap; | 
|---|
| 361 | } | 
|---|
| 362 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 363 | (*MolWalker)->doCountAtoms(); | 
|---|
| 364 |  | 
|---|
| 365 | // create all possible pairs of elements | 
|---|
| 366 | set <pair<const element *,const element *> > PairsOfElements; | 
|---|
| 367 | if (elements.size() >= 2) { | 
|---|
| 368 | for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) | 
|---|
| 369 | for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) | 
|---|
| 370 | if (type1 != type2) { | 
|---|
| 371 | PairsOfElements.insert( make_pair(*type1,*type2) ); | 
|---|
| 372 | LOG(1, "Creating element pair " << *(*type1) << " and " << *(*type2) << "."); | 
|---|
| 373 | } | 
|---|
| 374 | } else if (elements.size() == 1) { // one to all are valid | 
|---|
| 375 | const element *elemental = *elements.begin(); | 
|---|
| 376 | PairsOfElements.insert( pair<const element *,const element*>(elemental,0) ); | 
|---|
| 377 | PairsOfElements.insert( pair<const element *,const element*>(0,elemental) ); | 
|---|
| 378 | } else { // all elements valid | 
|---|
| 379 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); | 
|---|
| 380 | } | 
|---|
| 381 |  | 
|---|
| 382 | outmap = new PairCorrelationMap; | 
|---|
| 383 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ | 
|---|
| 384 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); | 
|---|
| 385 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); | 
|---|
| 386 | LOG(2, "Current molecule is " << *MolWalker << "."); | 
|---|
| 387 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 388 | LOG(3, "Current atom is " << **iter << "."); | 
|---|
| 389 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 | 
|---|
| 390 | // go through every range in xyz and get distance | 
|---|
| 391 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) | 
|---|
| 392 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) | 
|---|
| 393 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { | 
|---|
| 394 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); | 
|---|
| 395 | for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ | 
|---|
| 396 | LOG(2, "Current other molecule is " << *MolOtherWalker << "."); | 
|---|
| 397 | for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { | 
|---|
| 398 | LOG(3, "Current otheratom is " << **runner << "."); | 
|---|
| 399 | if ((*iter)->getId() < (*runner)->getId()){ | 
|---|
| 400 | for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) | 
|---|
| 401 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { | 
|---|
| 402 | periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3 | 
|---|
| 403 | // go through every range in xyz and get distance | 
|---|
| 404 | for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) | 
|---|
| 405 | for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) | 
|---|
| 406 | for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { | 
|---|
| 407 | checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); | 
|---|
| 408 | distance = checkX.distance(checkOtherX); | 
|---|
| 409 | //LOG(1, "Inserting " << *(*iter) << " and " << *(*runner)); | 
|---|
| 410 | outmap->insert ( | 
|---|
| 411 | std::pair<double, std::pair <const atom *, const atom*> > ( | 
|---|
| 412 | distance, | 
|---|
| 413 | std::pair<const atom *, const atom*> ( | 
|---|
| 414 | (*iter), | 
|---|
| 415 | (*runner)) | 
|---|
| 416 | ) | 
|---|
| 417 | ); | 
|---|
| 418 | } | 
|---|
| 419 | } | 
|---|
| 420 | } | 
|---|
| 421 | } | 
|---|
| 422 | } | 
|---|
| 423 | } | 
|---|
| 424 | } | 
|---|
| 425 | } | 
|---|
| 426 |  | 
|---|
| 427 | return outmap; | 
|---|
| 428 | }; | 
|---|
| 429 |  | 
|---|
| 430 | /** Calculates the distance (pair) correlation between a given element and a point. | 
|---|
| 431 | * \param *molecules list of molecules structure | 
|---|
| 432 | * \param &elements vector of elements to correlate with point | 
|---|
| 433 | * \param *point vector to the correlation point | 
|---|
| 434 | * \return Map of dobules with values as pairs of atom and the vector | 
|---|
| 435 | */ | 
|---|
| 436 | CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point ) | 
|---|
| 437 | { | 
|---|
| 438 | Info FunctionInfo(__func__); | 
|---|
| 439 | CorrelationToPointMap *outmap = new CorrelationToPointMap; | 
|---|
| 440 | double distance = 0.; | 
|---|
| 441 | Box &domain = World::getInstance().getDomain(); | 
|---|
| 442 |  | 
|---|
| 443 | if (molecules.empty()) { | 
|---|
| 444 | LOG(1, "No molecule given."); | 
|---|
| 445 | return outmap; | 
|---|
| 446 | } | 
|---|
| 447 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 448 | (*MolWalker)->doCountAtoms(); | 
|---|
| 449 | outmap = new CorrelationToPointMap; | 
|---|
| 450 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { | 
|---|
| 451 | LOG(2, "Current molecule is " << *MolWalker << "."); | 
|---|
| 452 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 453 | LOG(3, "Current atom is " << **iter << "."); | 
|---|
| 454 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) | 
|---|
| 455 | if ((*type == NULL) || ((*iter)->getType() == *type)) { | 
|---|
| 456 | distance = domain.periodicDistance((*iter)->getPosition(),*point); | 
|---|
| 457 | LOG(4, "Current distance is " << distance << "."); | 
|---|
| 458 | outmap->insert ( | 
|---|
| 459 | std::pair<double, std::pair<const atom *, const Vector*> >( | 
|---|
| 460 | distance, | 
|---|
| 461 | std::pair<const atom *, const Vector*> ( | 
|---|
| 462 | (*iter), | 
|---|
| 463 | point) | 
|---|
| 464 | ) | 
|---|
| 465 | ); | 
|---|
| 466 | } | 
|---|
| 467 | } | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | return outmap; | 
|---|
| 471 | }; | 
|---|
| 472 |  | 
|---|
| 473 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point. | 
|---|
| 474 | * \param *molecules list of molecules structure | 
|---|
| 475 | * \param &elements vector of elements to correlate to point | 
|---|
| 476 | * \param *point vector to the correlation point | 
|---|
| 477 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also | 
|---|
| 478 | * \return Map of dobules with values as pairs of atom and the vector | 
|---|
| 479 | */ | 
|---|
| 480 | CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] ) | 
|---|
| 481 | { | 
|---|
| 482 | Info FunctionInfo(__func__); | 
|---|
| 483 | CorrelationToPointMap *outmap = new CorrelationToPointMap; | 
|---|
| 484 | double distance = 0.; | 
|---|
| 485 | int n[NDIM]; | 
|---|
| 486 | Vector periodicX; | 
|---|
| 487 | Vector checkX; | 
|---|
| 488 |  | 
|---|
| 489 | if (molecules.empty()) { | 
|---|
| 490 | LOG(1, "No molecule given."); | 
|---|
| 491 | return outmap; | 
|---|
| 492 | } | 
|---|
| 493 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 494 | (*MolWalker)->doCountAtoms(); | 
|---|
| 495 | outmap = new CorrelationToPointMap; | 
|---|
| 496 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { | 
|---|
| 497 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); | 
|---|
| 498 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); | 
|---|
| 499 | LOG(2, "Current molecule is " << *MolWalker << "."); | 
|---|
| 500 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 501 | LOG(3, "Current atom is " << **iter << "."); | 
|---|
| 502 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) | 
|---|
| 503 | if ((*type == NULL) || ((*iter)->getType() == *type)) { | 
|---|
| 504 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 | 
|---|
| 505 | // go through every range in xyz and get distance | 
|---|
| 506 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) | 
|---|
| 507 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) | 
|---|
| 508 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { | 
|---|
| 509 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); | 
|---|
| 510 | distance = checkX.distance(*point); | 
|---|
| 511 | LOG(4, "Current distance is " << distance << "."); | 
|---|
| 512 | outmap->insert ( | 
|---|
| 513 | std::pair<double, | 
|---|
| 514 | std::pair<const atom *, const Vector*> >( | 
|---|
| 515 | distance, | 
|---|
| 516 | std::pair<const atom *, const Vector*> ( | 
|---|
| 517 | *iter, | 
|---|
| 518 | point) | 
|---|
| 519 | ) | 
|---|
| 520 | ); | 
|---|
| 521 | } | 
|---|
| 522 | } | 
|---|
| 523 | } | 
|---|
| 524 | } | 
|---|
| 525 |  | 
|---|
| 526 | return outmap; | 
|---|
| 527 | }; | 
|---|
| 528 |  | 
|---|
| 529 | /** Calculates the distance (pair) correlation between a given element and a surface. | 
|---|
| 530 | * \param *molecules list of molecules structure | 
|---|
| 531 | * \param &elements vector of elements to correlate to surface | 
|---|
| 532 | * \param *Surface pointer to Tesselation class surface | 
|---|
| 533 | * \param *LC LinkedCell_deprecated structure to quickly find neighbouring atoms | 
|---|
| 534 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest | 
|---|
| 535 | */ | 
|---|
| 536 | CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC ) | 
|---|
| 537 | { | 
|---|
| 538 | Info FunctionInfo(__func__); | 
|---|
| 539 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap; | 
|---|
| 540 | double distance = 0; | 
|---|
| 541 | class BoundaryTriangleSet *triangle = NULL; | 
|---|
| 542 | Vector centroid; | 
|---|
| 543 |  | 
|---|
| 544 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { | 
|---|
| 545 | ELOG(1, "No Tesselation, no LinkedCell or no molecule given."); | 
|---|
| 546 | return outmap; | 
|---|
| 547 | } | 
|---|
| 548 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 549 | (*MolWalker)->doCountAtoms(); | 
|---|
| 550 | outmap = new CorrelationToSurfaceMap; | 
|---|
| 551 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { | 
|---|
| 552 | LOG(2, "Current molecule is " << (*MolWalker)->name << "."); | 
|---|
| 553 | if ((*MolWalker)->empty()) | 
|---|
| 554 | LOG(2, "\t is empty."); | 
|---|
| 555 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 556 | LOG(3, "\tCurrent atom is " << *(*iter) << "."); | 
|---|
| 557 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) | 
|---|
| 558 | if ((*type == NULL) || ((*iter)->getType() == *type)) { | 
|---|
| 559 | TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC); | 
|---|
| 560 | distance = Intersections.GetSmallestDistance(); | 
|---|
| 561 | triangle = Intersections.GetClosestTriangle(); | 
|---|
| 562 | outmap->insert ( | 
|---|
| 563 | std::pair<double, | 
|---|
| 564 | std::pair<const atom *, BoundaryTriangleSet*> >( | 
|---|
| 565 | distance, | 
|---|
| 566 | std::pair<const atom *, BoundaryTriangleSet*> ( | 
|---|
| 567 | (*iter), | 
|---|
| 568 | triangle) | 
|---|
| 569 | ) | 
|---|
| 570 | ); | 
|---|
| 571 | } | 
|---|
| 572 | } | 
|---|
| 573 | } | 
|---|
| 574 |  | 
|---|
| 575 | return outmap; | 
|---|
| 576 | }; | 
|---|
| 577 |  | 
|---|
| 578 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and and a surface. | 
|---|
| 579 | * Note that we also put all periodic images found in the cells given by [ -ranges[i], ranges[i] ] and i=0,...,NDIM-1. | 
|---|
| 580 | * 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 | 
|---|
| 581 | * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into | 
|---|
| 582 | * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane(). | 
|---|
| 583 | * \param *molecules list of molecules structure | 
|---|
| 584 | * \param &elements vector of elements to correlate to surface | 
|---|
| 585 | * \param *Surface pointer to Tesselation class surface | 
|---|
| 586 | * \param *LC LinkedCell_deprecated structure to quickly find neighbouring atoms | 
|---|
| 587 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also | 
|---|
| 588 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest | 
|---|
| 589 | */ | 
|---|
| 590 | CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC, const int ranges[NDIM] ) | 
|---|
| 591 | { | 
|---|
| 592 | Info FunctionInfo(__func__); | 
|---|
| 593 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap; | 
|---|
| 594 | double distance = 0; | 
|---|
| 595 | class BoundaryTriangleSet *triangle = NULL; | 
|---|
| 596 | Vector centroid; | 
|---|
| 597 | int n[NDIM]; | 
|---|
| 598 | Vector periodicX; | 
|---|
| 599 | Vector checkX; | 
|---|
| 600 |  | 
|---|
| 601 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { | 
|---|
| 602 | LOG(1, "No Tesselation, no LinkedCell or no molecule given."); | 
|---|
| 603 | return outmap; | 
|---|
| 604 | } | 
|---|
| 605 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) | 
|---|
| 606 | (*MolWalker)->doCountAtoms(); | 
|---|
| 607 | outmap = new CorrelationToSurfaceMap; | 
|---|
| 608 | double ShortestDistance = 0.; | 
|---|
| 609 | BoundaryTriangleSet *ShortestTriangle = NULL; | 
|---|
| 610 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { | 
|---|
| 611 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); | 
|---|
| 612 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); | 
|---|
| 613 | LOG(2, "Current molecule is " << *MolWalker << "."); | 
|---|
| 614 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { | 
|---|
| 615 | LOG(3, "Current atom is " << **iter << "."); | 
|---|
| 616 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) | 
|---|
| 617 | if ((*type == NULL) || ((*iter)->getType() == *type)) { | 
|---|
| 618 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 | 
|---|
| 619 | // go through every range in xyz and get distance | 
|---|
| 620 | ShortestDistance = -1.; | 
|---|
| 621 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) | 
|---|
| 622 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) | 
|---|
| 623 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { | 
|---|
| 624 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); | 
|---|
| 625 | TriangleIntersectionList Intersections(checkX,Surface,LC); | 
|---|
| 626 | distance = Intersections.GetSmallestDistance(); | 
|---|
| 627 | triangle = Intersections.GetClosestTriangle(); | 
|---|
| 628 | if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { | 
|---|
| 629 | ShortestDistance = distance; | 
|---|
| 630 | ShortestTriangle = triangle; | 
|---|
| 631 | } | 
|---|
| 632 | } | 
|---|
| 633 | // insert | 
|---|
| 634 | outmap->insert ( | 
|---|
| 635 | std::pair<double, | 
|---|
| 636 | std::pair<const atom *, BoundaryTriangleSet*> >( | 
|---|
| 637 | ShortestDistance, | 
|---|
| 638 | std::pair<const atom *, BoundaryTriangleSet*> ( | 
|---|
| 639 | *iter, | 
|---|
| 640 | ShortestTriangle) | 
|---|
| 641 | ) | 
|---|
| 642 | ); | 
|---|
| 643 | //LOG(1, "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "."); | 
|---|
| 644 | } | 
|---|
| 645 | } | 
|---|
| 646 | } | 
|---|
| 647 |  | 
|---|
| 648 | return outmap; | 
|---|
| 649 | }; | 
|---|
| 650 |  | 
|---|
| 651 | /** Returns the index of the bin for a given value. | 
|---|
| 652 | * \param value value whose bin to look for | 
|---|
| 653 | * \param BinWidth width of bin | 
|---|
| 654 | * \param BinStart first bin | 
|---|
| 655 | */ | 
|---|
| 656 | int GetBin ( const double value, const double BinWidth, const double BinStart ) | 
|---|
| 657 | { | 
|---|
| 658 | //Info FunctionInfo(__func__); | 
|---|
| 659 | int bin =(int) (floor((value - BinStart)/BinWidth)); | 
|---|
| 660 | return (bin); | 
|---|
| 661 | }; | 
|---|
| 662 |  | 
|---|
| 663 |  | 
|---|
| 664 | /** Adds header part that is unique to BinPairMap. | 
|---|
| 665 | * | 
|---|
| 666 | * @param file stream to print to | 
|---|
| 667 | */ | 
|---|
| 668 | void OutputCorrelation_Header( ofstream * const file ) | 
|---|
| 669 | { | 
|---|
| 670 | *file << "\tCount"; | 
|---|
| 671 | }; | 
|---|
| 672 |  | 
|---|
| 673 | /** Prints values stored in BinPairMap iterator. | 
|---|
| 674 | * | 
|---|
| 675 | * @param file stream to print to | 
|---|
| 676 | * @param runner iterator pointing at values to print | 
|---|
| 677 | */ | 
|---|
| 678 | void OutputCorrelation_Value( ofstream * const file, BinPairMap::const_iterator &runner ) | 
|---|
| 679 | { | 
|---|
| 680 | *file << runner->second; | 
|---|
| 681 | }; | 
|---|
| 682 |  | 
|---|
| 683 |  | 
|---|
| 684 | /** Adds header part that is unique to DipoleAngularCorrelationMap. | 
|---|
| 685 | * | 
|---|
| 686 | * @param file stream to print to | 
|---|
| 687 | */ | 
|---|
| 688 | void OutputDipoleAngularCorrelation_Header( ofstream * const file ) | 
|---|
| 689 | { | 
|---|
| 690 | *file << "\tFirstAtomOfMolecule"; | 
|---|
| 691 | }; | 
|---|
| 692 |  | 
|---|
| 693 | /** Prints values stored in DipoleCorrelationMap iterator. | 
|---|
| 694 | * | 
|---|
| 695 | * @param file stream to print to | 
|---|
| 696 | * @param runner iterator pointing at values to print | 
|---|
| 697 | */ | 
|---|
| 698 | void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner ) | 
|---|
| 699 | { | 
|---|
| 700 | *file << *(runner->second); | 
|---|
| 701 | }; | 
|---|
| 702 |  | 
|---|
| 703 |  | 
|---|
| 704 | /** Adds header part that is unique to DipoleAngularCorrelationMap. | 
|---|
| 705 | * | 
|---|
| 706 | * @param file stream to print to | 
|---|
| 707 | */ | 
|---|
| 708 | void OutputDipoleCorrelation_Header( ofstream * const file ) | 
|---|
| 709 | { | 
|---|
| 710 | *file << "\tMolecule"; | 
|---|
| 711 | }; | 
|---|
| 712 |  | 
|---|
| 713 | /** Prints values stored in DipoleCorrelationMap iterator. | 
|---|
| 714 | * | 
|---|
| 715 | * @param file stream to print to | 
|---|
| 716 | * @param runner iterator pointing at values to print | 
|---|
| 717 | */ | 
|---|
| 718 | void OutputDipoleCorrelation_Value( ofstream * const file, DipoleCorrelationMap::const_iterator &runner ) | 
|---|
| 719 | { | 
|---|
| 720 | *file << runner->second.first->getId() << "\t" << runner->second.second->getId(); | 
|---|
| 721 | }; | 
|---|
| 722 |  | 
|---|
| 723 |  | 
|---|
| 724 | /** Adds header part that is unique to PairCorrelationMap. | 
|---|
| 725 | * | 
|---|
| 726 | * @param file stream to print to | 
|---|
| 727 | */ | 
|---|
| 728 | void OutputPairCorrelation_Header( ofstream * const file ) | 
|---|
| 729 | { | 
|---|
| 730 | *file << "\tAtom1\tAtom2"; | 
|---|
| 731 | }; | 
|---|
| 732 |  | 
|---|
| 733 | /** Prints values stored in PairCorrelationMap iterator. | 
|---|
| 734 | * | 
|---|
| 735 | * @param file stream to print to | 
|---|
| 736 | * @param runner iterator pointing at values to print | 
|---|
| 737 | */ | 
|---|
| 738 | void OutputPairCorrelation_Value( ofstream * const file, PairCorrelationMap::const_iterator &runner ) | 
|---|
| 739 | { | 
|---|
| 740 | *file << *(runner->second.first) << "\t" << *(runner->second.second); | 
|---|
| 741 | }; | 
|---|
| 742 |  | 
|---|
| 743 |  | 
|---|
| 744 | /** Adds header part that is unique to CorrelationToPointMap. | 
|---|
| 745 | * | 
|---|
| 746 | * @param file stream to print to | 
|---|
| 747 | */ | 
|---|
| 748 | void OutputCorrelationToPoint_Header( ofstream * const file ) | 
|---|
| 749 | { | 
|---|
| 750 | *file << "\tAtom::x[i]-point.x[i]"; | 
|---|
| 751 | }; | 
|---|
| 752 |  | 
|---|
| 753 | /** Prints values stored in CorrelationToPointMap iterator. | 
|---|
| 754 | * | 
|---|
| 755 | * @param file stream to print to | 
|---|
| 756 | * @param runner iterator pointing at values to print | 
|---|
| 757 | */ | 
|---|
| 758 | void OutputCorrelationToPoint_Value( ofstream * const file, CorrelationToPointMap::const_iterator &runner ) | 
|---|
| 759 | { | 
|---|
| 760 | for (int i=0;i<NDIM;i++) | 
|---|
| 761 | *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i)); | 
|---|
| 762 | }; | 
|---|
| 763 |  | 
|---|
| 764 |  | 
|---|
| 765 | /** Adds header part that is unique to CorrelationToSurfaceMap. | 
|---|
| 766 | * | 
|---|
| 767 | * @param file stream to print to | 
|---|
| 768 | */ | 
|---|
| 769 | void OutputCorrelationToSurface_Header( ofstream * const file ) | 
|---|
| 770 | { | 
|---|
| 771 | *file << "\tTriangle"; | 
|---|
| 772 | }; | 
|---|
| 773 |  | 
|---|
| 774 | /** Prints values stored in CorrelationToSurfaceMap iterator. | 
|---|
| 775 | * | 
|---|
| 776 | * @param file stream to print to | 
|---|
| 777 | * @param runner iterator pointing at values to print | 
|---|
| 778 | */ | 
|---|
| 779 | void OutputCorrelationToSurface_Value( ofstream * const file, CorrelationToSurfaceMap::const_iterator &runner ) | 
|---|
| 780 | { | 
|---|
| 781 | *file << *(runner->second.first) << "\t" << *(runner->second.second); | 
|---|
| 782 | }; | 
|---|