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