| [bcf653] | 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 |
|
|---|
| [c4d4df] | 8 | /*
|
|---|
| 9 | * analysis.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Oct 13, 2009
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| [bf3817] | 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| [ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| [112b09] | 21 |
|
|---|
| [c4d4df] | 22 | #include <iostream>
|
|---|
| [36166d] | 23 | #include <iomanip>
|
|---|
| [c4d4df] | 24 |
|
|---|
| [be945c] | 25 | #include "atom.hpp"
|
|---|
| [129204] | 26 | #include "Bond/bond.hpp"
|
|---|
| [d127c8] | 27 | #include "Tesselation/BoundaryTriangleSet.hpp"
|
|---|
| [be945c] | 28 | #include "Box.hpp"
|
|---|
| [3bdb6d] | 29 | #include "Element/element.hpp"
|
|---|
| [ad011c] | 30 | #include "CodePatterns/Info.hpp"
|
|---|
| 31 | #include "CodePatterns/Log.hpp"
|
|---|
| [208237b] | 32 | #include "CodePatterns/Verbose.hpp"
|
|---|
| [4b8630] | 33 | #include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp"
|
|---|
| [ea430a] | 34 | #include "Formula.hpp"
|
|---|
| [208237b] | 35 | #include "LinearAlgebra/Vector.hpp"
|
|---|
| 36 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
|---|
| [c4d4df] | 37 | #include "molecule.hpp"
|
|---|
| [d127c8] | 38 | #include "Tesselation/tesselation.hpp"
|
|---|
| 39 | #include "Tesselation/tesselationhelpers.hpp"
|
|---|
| 40 | #include "Tesselation/triangleintersectionlist.hpp"
|
|---|
| [be945c] | 41 | #include "World.hpp"
|
|---|
| [208237b] | 42 | #include "WorldTime.hpp"
|
|---|
| [c4d4df] | 43 |
|
|---|
| [be945c] | 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
|
|---|
| [d1912f] | 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
|
|---|
| [be945c] | 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
|
|---|
| [9d83b6] | 68 | const BondList& ListOfBonds = (*atomiter)->getListOfBonds();
|
|---|
| [4fc828] | 69 | ASSERT(ListOfBonds.begin() != ListOfBonds.end(),
|
|---|
| 70 | "getDipole() - no bonds in molecule!");
|
|---|
| [9d83b6] | 71 | for (BondList::const_iterator bonditer = ListOfBonds.begin();
|
|---|
| 72 | bonditer != ListOfBonds.end();
|
|---|
| [be945c] | 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;
|
|---|
| [4fc828] | 82 | LOG(3,"INFO: Dipole vector from bond " << **bonditer << " is " << BondDipoleVector);
|
|---|
| [be945c] | 83 | DipoleVector += BondDipoleVector;
|
|---|
| 84 | SumOfVectors++;
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| [4fc828] | 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;
|
|---|
| [be945c] | 92 | DoLog(1) && (Log() << Verbose(1) << "Resulting dipole vector is " << DipoleVector << std::endl);
|
|---|
| 93 |
|
|---|
| 94 | return DipoleVector;
|
|---|
| 95 | };
|
|---|
| 96 |
|
|---|
| [1cc661] | 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 |
|
|---|
| [0a7fad] | 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 | }
|
|---|
| [1cc661] | 143 |
|
|---|
| [ea430a] | 144 | /** Calculates the dipole angular correlation for given molecule type.
|
|---|
| [208237b] | 145 | * Calculate the change of the dipole orientation angle over time.
|
|---|
| [ea430a] | 146 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| [be945c] | 147 | * Angles are given in degrees.
|
|---|
| [4b8630] | 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)
|
|---|
| [ea430a] | 150 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 151 | */
|
|---|
| [4b8630] | 152 | DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<atom *> &atoms)
|
|---|
| [ea430a] | 153 | {
|
|---|
| 154 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 155 | DipoleAngularCorrelationMap *outmap = new DipoleAngularCorrelationMap;
|
|---|
| [be945c] | 156 |
|
|---|
| [208237b] | 157 | // store original time step
|
|---|
| 158 | const unsigned int oldtime = WorldTime::getTime();
|
|---|
| 159 | World::getInstance().setTime(0);
|
|---|
| [0a7fad] | 160 |
|
|---|
| [4b8630] | 161 | // calculate molecules for this time step
|
|---|
| [0a7fad] | 162 | std::set<molecule *> molecules;
|
|---|
| [4b8630] | 163 | BOOST_FOREACH(atom *_atom, atoms)
|
|---|
| 164 | molecules.insert(_atom->getMolecule());
|
|---|
| [208237b] | 165 |
|
|---|
| [4fc828] | 166 | BOOST_FOREACH(atom *_atom, World::getInstance().getAllAtoms())
|
|---|
| 167 | LOG(2, "INFO: Atom " << _atom->getId() << " "
|
|---|
| 168 | << *dynamic_cast<AtomInfo *>(_atom) <<".");
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| [208237b] | 171 | // get zero orientation for each molecule.
|
|---|
| [0a7fad] | 172 | std::map<atomId_t, Vector> ZeroVector = CalculateZeroAngularDipole(atoms);
|
|---|
| [4fc828] | 173 |
|
|---|
| [208237b] | 174 | // go through every time step
|
|---|
| [4fc828] | 175 | LOG(0,"STATUS: Calculating dipoles of following time steps ...");
|
|---|
| [1cc661] | 176 | range<size_t> timesteps = getMaximumTrajectoryBounds(atoms);
|
|---|
| 177 | for (size_t step = 1; step < timesteps.first; ++step) {
|
|---|
| [208237b] | 178 | World::getInstance().setTime(step);
|
|---|
| [4b8630] | 179 | // recalculate molecules for this time step
|
|---|
| 180 | molecules.clear();
|
|---|
| 181 | BOOST_FOREACH(atom *_atom, atoms)
|
|---|
| 182 | molecules.insert(_atom->getMolecule());
|
|---|
| [208237b] | 183 | size_t i=0;
|
|---|
| 184 | BOOST_FOREACH(molecule *_mol, molecules) {
|
|---|
| 185 | const Vector Dipole = getDipole(_mol->begin(), _mol->end());
|
|---|
| [4fc828] | 186 | LOG(2,"INFO: Dipole vector at time step " << step << " for for molecule " << _mol->getId() << " is " << Dipole);
|
|---|
| [be0c61] | 187 | molecule::const_iterator iter = _mol->begin();
|
|---|
| 188 | ASSERT(ZeroVector.count((*iter)->getId()),
|
|---|
| 189 | "DipoleAngularCorrelation() - ZeroVector for atom "+toString(**iter)+" not present.");
|
|---|
| 190 | const double angle = Dipole.Angle(ZeroVector[(*iter)->getId()]) * (180./M_PI);
|
|---|
| 191 | LOG(1,"INFO: Resulting relative angle for molecule " << **iter << " is " << angle << ".");
|
|---|
| 192 | outmap->insert ( make_pair (angle, *iter ) );
|
|---|
| [208237b] | 193 | ++i;
|
|---|
| 194 | }
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 | // set original time step again
|
|---|
| 199 | World::getInstance().setTime(oldtime);
|
|---|
| [4fc828] | 200 | LOG(0,"STATUS: Done.");
|
|---|
| [208237b] | 201 |
|
|---|
| 202 | // and return results
|
|---|
| 203 | return outmap;
|
|---|
| 204 | };
|
|---|
| 205 |
|
|---|
| 206 | /** Calculates the dipole correlation for given molecule type.
|
|---|
| 207 | * I.e. we calculate how the angle between any two given dipoles in the
|
|---|
| 208 | * systems behaves. Sort of pair correlation but distance is replaced by
|
|---|
| 209 | * the orientation distance, i.e. an angle.
|
|---|
| 210 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| 211 | * Angles are given in degrees.
|
|---|
| 212 | * \param *molecules vector of molecules
|
|---|
| 213 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 214 | */
|
|---|
| 215 | DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules)
|
|---|
| 216 | {
|
|---|
| 217 | Info FunctionInfo(__func__);
|
|---|
| 218 | DipoleCorrelationMap *outmap = new DipoleCorrelationMap;
|
|---|
| 219 | // double distance = 0.;
|
|---|
| 220 | // Box &domain = World::getInstance().getDomain();
|
|---|
| 221 | //
|
|---|
| 222 | if (molecules.empty()) {
|
|---|
| 223 | DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
|
|---|
| 224 | return outmap;
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| [be945c] | 227 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
|
|---|
| [92e5cb] | 228 | MolWalker != molecules.end(); ++MolWalker) {
|
|---|
| [be945c] | 229 | DoLog(2) && (Log()<< Verbose(2) << "Current molecule is "
|
|---|
| 230 | << (*MolWalker)->getId() << "." << endl);
|
|---|
| 231 | const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
|
|---|
| [92e5cb] | 232 | std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker;
|
|---|
| 233 | for (++MolOtherWalker;
|
|---|
| [be945c] | 234 | MolOtherWalker != molecules.end();
|
|---|
| [92e5cb] | 235 | ++MolOtherWalker) {
|
|---|
| [be945c] | 236 | DoLog(2) && (Log() << Verbose(2) << "Current other molecule is "
|
|---|
| 237 | << (*MolOtherWalker)->getId() << "." << endl);
|
|---|
| 238 | const Vector OtherDipole = getDipole((*MolOtherWalker)->begin(), (*MolOtherWalker)->end());
|
|---|
| 239 | const double angle = Dipole.Angle(OtherDipole) * (180./M_PI);
|
|---|
| 240 | DoLog(1) && (Log() << Verbose(1) << "Angle is " << angle << "." << endl);
|
|---|
| 241 | outmap->insert ( make_pair (angle, make_pair ((*MolWalker), (*MolOtherWalker)) ) );
|
|---|
| 242 | }
|
|---|
| 243 | }
|
|---|
| [ea430a] | 244 | return outmap;
|
|---|
| 245 | };
|
|---|
| 246 |
|
|---|
| [c4d4df] | 247 |
|
|---|
| 248 | /** Calculates the pair correlation between given elements.
|
|---|
| 249 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| [e65de8] | 250 | * \param *molecules vector of molecules
|
|---|
| [c78d44] | 251 | * \param &elements vector of elements to correlate
|
|---|
| [c4d4df] | 252 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 253 | */
|
|---|
| [e5c0a1] | 254 | PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
|
|---|
| [c4d4df] | 255 | {
|
|---|
| [3930eb] | 256 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 257 | PairCorrelationMap *outmap = new PairCorrelationMap;
|
|---|
| [c4d4df] | 258 | double distance = 0.;
|
|---|
| [014475] | 259 | Box &domain = World::getInstance().getDomain();
|
|---|
| [c4d4df] | 260 |
|
|---|
| [e65de8] | 261 | if (molecules.empty()) {
|
|---|
| [58ed4a] | 262 | DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
|
|---|
| [c4d4df] | 263 | return outmap;
|
|---|
| 264 | }
|
|---|
| [e65de8] | 265 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 266 | (*MolWalker)->doCountAtoms();
|
|---|
| [c78d44] | 267 |
|
|---|
| 268 | // create all possible pairs of elements
|
|---|
| [e5c0a1] | 269 | set <pair<const element *,const element *> > PairsOfElements;
|
|---|
| [c78d44] | 270 | if (elements.size() >= 2) {
|
|---|
| [e5c0a1] | 271 | for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
|
|---|
| 272 | for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
|
|---|
| [c78d44] | 273 | if (type1 != type2) {
|
|---|
| [e5c0a1] | 274 | PairsOfElements.insert( make_pair(*type1,*type2) );
|
|---|
| [2fe971] | 275 | DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
|
|---|
| [c78d44] | 276 | }
|
|---|
| 277 | } else if (elements.size() == 1) { // one to all are valid
|
|---|
| [e5c0a1] | 278 | const element *elemental = *elements.begin();
|
|---|
| 279 | PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
|
|---|
| 280 | PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
|
|---|
| [c78d44] | 281 | } else { // all elements valid
|
|---|
| 282 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| [c4d4df] | 285 | outmap = new PairCorrelationMap;
|
|---|
| [e65de8] | 286 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
|
|---|
| 287 | DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
|
|---|
| 288 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 289 | DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
|
|---|
| 290 | for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
|
|---|
| 291 | DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
|
|---|
| 292 | for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
|
|---|
| 293 | DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
|
|---|
| 294 | if ((*iter)->getId() < (*runner)->getId()){
|
|---|
| [b5c53d] | 295 | for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
|
|---|
| [d74077] | 296 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
|
|---|
| 297 | distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition());
|
|---|
| [e65de8] | 298 | //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
|
|---|
| 299 | outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
|
|---|
| [a5551b] | 300 | }
|
|---|
| [c4d4df] | 301 | }
|
|---|
| [a5551b] | 302 | }
|
|---|
| [c4d4df] | 303 | }
|
|---|
| 304 | }
|
|---|
| [24725c] | 305 | }
|
|---|
| [c4d4df] | 306 | return outmap;
|
|---|
| 307 | };
|
|---|
| 308 |
|
|---|
| [7ea9e6] | 309 | /** Calculates the pair correlation between given elements.
|
|---|
| 310 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| 311 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 312 | * \param &elements vector of elements to correlate
|
|---|
| [7ea9e6] | 313 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 314 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 315 | */
|
|---|
| [e5c0a1] | 316 | PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 317 | {
|
|---|
| [3930eb] | 318 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 319 | PairCorrelationMap *outmap = new PairCorrelationMap;
|
|---|
| [7ea9e6] | 320 | double distance = 0.;
|
|---|
| 321 | int n[NDIM];
|
|---|
| 322 | Vector checkX;
|
|---|
| 323 | Vector periodicX;
|
|---|
| 324 | int Othern[NDIM];
|
|---|
| 325 | Vector checkOtherX;
|
|---|
| 326 | Vector periodicOtherX;
|
|---|
| 327 |
|
|---|
| [e65de8] | 328 | if (molecules.empty()) {
|
|---|
| [58ed4a] | 329 | DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
|
|---|
| [7ea9e6] | 330 | return outmap;
|
|---|
| 331 | }
|
|---|
| [e65de8] | 332 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 333 | (*MolWalker)->doCountAtoms();
|
|---|
| [c78d44] | 334 |
|
|---|
| 335 | // create all possible pairs of elements
|
|---|
| [e5c0a1] | 336 | set <pair<const element *,const element *> > PairsOfElements;
|
|---|
| [c78d44] | 337 | if (elements.size() >= 2) {
|
|---|
| [e5c0a1] | 338 | for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
|
|---|
| 339 | for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
|
|---|
| [c78d44] | 340 | if (type1 != type2) {
|
|---|
| [e5c0a1] | 341 | PairsOfElements.insert( make_pair(*type1,*type2) );
|
|---|
| [2fe971] | 342 | DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
|
|---|
| [c78d44] | 343 | }
|
|---|
| 344 | } else if (elements.size() == 1) { // one to all are valid
|
|---|
| [e5c0a1] | 345 | const element *elemental = *elements.begin();
|
|---|
| 346 | PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
|
|---|
| 347 | PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
|
|---|
| [c78d44] | 348 | } else { // all elements valid
|
|---|
| 349 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| [7ea9e6] | 352 | outmap = new PairCorrelationMap;
|
|---|
| [e65de8] | 353 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
|
|---|
| [cca9ef] | 354 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 355 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 356 | DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
|
|---|
| 357 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 358 | DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
|
|---|
| [d74077] | 359 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 360 | // go through every range in xyz and get distance
|
|---|
| 361 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 362 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 363 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 364 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
|
|---|
| 365 | for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
|
|---|
| 366 | DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
|
|---|
| 367 | for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
|
|---|
| 368 | DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
|
|---|
| 369 | if ((*iter)->getId() < (*runner)->getId()){
|
|---|
| [e5c0a1] | 370 | for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
|
|---|
| [d74077] | 371 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
|
|---|
| 372 | periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 373 | // go through every range in xyz and get distance
|
|---|
| 374 | for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
|
|---|
| 375 | for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
|
|---|
| 376 | for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
|
|---|
| 377 | checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
|
|---|
| 378 | distance = checkX.distance(checkOtherX);
|
|---|
| 379 | //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
|
|---|
| 380 | outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
|
|---|
| 381 | }
|
|---|
| 382 | }
|
|---|
| [c78d44] | 383 | }
|
|---|
| [7ea9e6] | 384 | }
|
|---|
| [c78d44] | 385 | }
|
|---|
| [7ea9e6] | 386 | }
|
|---|
| 387 | }
|
|---|
| [c78d44] | 388 | }
|
|---|
| [7ea9e6] | 389 |
|
|---|
| 390 | return outmap;
|
|---|
| 391 | };
|
|---|
| 392 |
|
|---|
| [c4d4df] | 393 | /** Calculates the distance (pair) correlation between a given element and a point.
|
|---|
| [a5551b] | 394 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 395 | * \param &elements vector of elements to correlate with point
|
|---|
| [c4d4df] | 396 | * \param *point vector to the correlation point
|
|---|
| 397 | * \return Map of dobules with values as pairs of atom and the vector
|
|---|
| 398 | */
|
|---|
| [e5c0a1] | 399 | CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
|
|---|
| [c4d4df] | 400 | {
|
|---|
| [3930eb] | 401 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 402 | CorrelationToPointMap *outmap = new CorrelationToPointMap;
|
|---|
| [c4d4df] | 403 | double distance = 0.;
|
|---|
| [014475] | 404 | Box &domain = World::getInstance().getDomain();
|
|---|
| [c4d4df] | 405 |
|
|---|
| [e65de8] | 406 | if (molecules.empty()) {
|
|---|
| [a67d19] | 407 | DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
|
|---|
| [c4d4df] | 408 | return outmap;
|
|---|
| 409 | }
|
|---|
| [e65de8] | 410 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 411 | (*MolWalker)->doCountAtoms();
|
|---|
| [c4d4df] | 412 | outmap = new CorrelationToPointMap;
|
|---|
| [e65de8] | 413 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| 414 | DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
|
|---|
| 415 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 416 | DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
|
|---|
| [e5c0a1] | 417 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 418 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 419 | distance = domain.periodicDistance((*iter)->getPosition(),*point);
|
|---|
| [e65de8] | 420 | DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
|
|---|
| 421 | outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
|
|---|
| 422 | }
|
|---|
| [c4d4df] | 423 | }
|
|---|
| [e65de8] | 424 | }
|
|---|
| [c4d4df] | 425 |
|
|---|
| 426 | return outmap;
|
|---|
| 427 | };
|
|---|
| 428 |
|
|---|
| [7ea9e6] | 429 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
|
|---|
| 430 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 431 | * \param &elements vector of elements to correlate to point
|
|---|
| [7ea9e6] | 432 | * \param *point vector to the correlation point
|
|---|
| 433 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 434 | * \return Map of dobules with values as pairs of atom and the vector
|
|---|
| 435 | */
|
|---|
| [e5c0a1] | 436 | CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 437 | {
|
|---|
| [3930eb] | 438 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 439 | CorrelationToPointMap *outmap = new CorrelationToPointMap;
|
|---|
| [7ea9e6] | 440 | double distance = 0.;
|
|---|
| 441 | int n[NDIM];
|
|---|
| 442 | Vector periodicX;
|
|---|
| 443 | Vector checkX;
|
|---|
| 444 |
|
|---|
| [e65de8] | 445 | if (molecules.empty()) {
|
|---|
| [a67d19] | 446 | DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
|
|---|
| [7ea9e6] | 447 | return outmap;
|
|---|
| 448 | }
|
|---|
| [e65de8] | 449 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 450 | (*MolWalker)->doCountAtoms();
|
|---|
| [7ea9e6] | 451 | outmap = new CorrelationToPointMap;
|
|---|
| [e65de8] | 452 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| [cca9ef] | 453 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 454 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 455 | DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
|
|---|
| 456 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 457 | DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
|
|---|
| [e5c0a1] | 458 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 459 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 460 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 461 | // go through every range in xyz and get distance
|
|---|
| 462 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 463 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 464 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 465 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
|
|---|
| 466 | distance = checkX.distance(*point);
|
|---|
| 467 | DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
|
|---|
| 468 | outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
|
|---|
| 469 | }
|
|---|
| 470 | }
|
|---|
| [7ea9e6] | 471 | }
|
|---|
| [e65de8] | 472 | }
|
|---|
| [7ea9e6] | 473 |
|
|---|
| 474 | return outmap;
|
|---|
| 475 | };
|
|---|
| 476 |
|
|---|
| [c4d4df] | 477 | /** Calculates the distance (pair) correlation between a given element and a surface.
|
|---|
| [a5551b] | 478 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 479 | * \param &elements vector of elements to correlate to surface
|
|---|
| [c4d4df] | 480 | * \param *Surface pointer to Tesselation class surface
|
|---|
| 481 | * \param *LC LinkedCell structure to quickly find neighbouring atoms
|
|---|
| 482 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
|
|---|
| 483 | */
|
|---|
| [e5c0a1] | 484 | CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
|
|---|
| [c4d4df] | 485 | {
|
|---|
| [3930eb] | 486 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 487 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap;
|
|---|
| [99593f] | 488 | double distance = 0;
|
|---|
| [c4d4df] | 489 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 490 | Vector centroid;
|
|---|
| [7ea9e6] | 491 |
|
|---|
| [e65de8] | 492 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
|
|---|
| [58ed4a] | 493 | DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
|
|---|
| [7ea9e6] | 494 | return outmap;
|
|---|
| 495 | }
|
|---|
| [e65de8] | 496 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 497 | (*MolWalker)->doCountAtoms();
|
|---|
| [7ea9e6] | 498 | outmap = new CorrelationToSurfaceMap;
|
|---|
| [e65de8] | 499 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| 500 | DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl);
|
|---|
| 501 | if ((*MolWalker)->empty())
|
|---|
| 502 | DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl);
|
|---|
| 503 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 504 | DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
|
|---|
| [e5c0a1] | 505 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 506 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 507 | TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC);
|
|---|
| [e65de8] | 508 | distance = Intersections.GetSmallestDistance();
|
|---|
| 509 | triangle = Intersections.GetClosestTriangle();
|
|---|
| 510 | outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
|
|---|
| 511 | }
|
|---|
| [7fd416] | 512 | }
|
|---|
| [e65de8] | 513 | }
|
|---|
| [7ea9e6] | 514 |
|
|---|
| 515 | return outmap;
|
|---|
| 516 | };
|
|---|
| 517 |
|
|---|
| 518 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and and a surface.
|
|---|
| 519 | * Note that we also put all periodic images found in the cells given by [ -ranges[i], ranges[i] ] and i=0,...,NDIM-1.
|
|---|
| 520 | * 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
|
|---|
| 521 | * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
|
|---|
| 522 | * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
|
|---|
| 523 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 524 | * \param &elements vector of elements to correlate to surface
|
|---|
| [7ea9e6] | 525 | * \param *Surface pointer to Tesselation class surface
|
|---|
| 526 | * \param *LC LinkedCell structure to quickly find neighbouring atoms
|
|---|
| 527 | * \param ranges[NDIM] interval boundaries for the periodic images to scan also
|
|---|
| 528 | * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
|
|---|
| 529 | */
|
|---|
| [e5c0a1] | 530 | CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 531 | {
|
|---|
| [3930eb] | 532 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 533 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap;
|
|---|
| [7ea9e6] | 534 | double distance = 0;
|
|---|
| 535 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 536 | Vector centroid;
|
|---|
| [99593f] | 537 | int n[NDIM];
|
|---|
| 538 | Vector periodicX;
|
|---|
| 539 | Vector checkX;
|
|---|
| [c4d4df] | 540 |
|
|---|
| [e65de8] | 541 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
|
|---|
| [a67d19] | 542 | DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
|
|---|
| [c4d4df] | 543 | return outmap;
|
|---|
| 544 | }
|
|---|
| [e65de8] | 545 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 546 | (*MolWalker)->doCountAtoms();
|
|---|
| [c4d4df] | 547 | outmap = new CorrelationToSurfaceMap;
|
|---|
| [244a84] | 548 | double ShortestDistance = 0.;
|
|---|
| 549 | BoundaryTriangleSet *ShortestTriangle = NULL;
|
|---|
| [e65de8] | 550 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| [cca9ef] | 551 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 552 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 553 | DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
|
|---|
| 554 | for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
|
|---|
| 555 | DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
|
|---|
| [e5c0a1] | 556 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 557 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 558 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 559 | // go through every range in xyz and get distance
|
|---|
| 560 | ShortestDistance = -1.;
|
|---|
| 561 | for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
|
|---|
| 562 | for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
|
|---|
| 563 | for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
|
|---|
| 564 | checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
|
|---|
| [d74077] | 565 | TriangleIntersectionList Intersections(checkX,Surface,LC);
|
|---|
| [e65de8] | 566 | distance = Intersections.GetSmallestDistance();
|
|---|
| 567 | triangle = Intersections.GetClosestTriangle();
|
|---|
| 568 | if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
|
|---|
| 569 | ShortestDistance = distance;
|
|---|
| 570 | ShortestTriangle = triangle;
|
|---|
| [99593f] | 571 | }
|
|---|
| [e65de8] | 572 | }
|
|---|
| 573 | // insert
|
|---|
| 574 | outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
|
|---|
| 575 | //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
|
|---|
| 576 | }
|
|---|
| [c4d4df] | 577 | }
|
|---|
| [e65de8] | 578 | }
|
|---|
| [c4d4df] | 579 |
|
|---|
| 580 | return outmap;
|
|---|
| 581 | };
|
|---|
| 582 |
|
|---|
| [bd61b41] | 583 | /** Returns the index of the bin for a given value.
|
|---|
| [c4d4df] | 584 | * \param value value whose bin to look for
|
|---|
| 585 | * \param BinWidth width of bin
|
|---|
| 586 | * \param BinStart first bin
|
|---|
| 587 | */
|
|---|
| [bd61b41] | 588 | int GetBin ( const double value, const double BinWidth, const double BinStart )
|
|---|
| [c4d4df] | 589 | {
|
|---|
| [92e5cb] | 590 | //Info FunctionInfo(__func__);
|
|---|
| [bd61b41] | 591 | int bin =(int) (floor((value - BinStart)/BinWidth));
|
|---|
| 592 | return (bin);
|
|---|
| [c4d4df] | 593 | };
|
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| [92e5cb] | 596 | /** Adds header part that is unique to BinPairMap.
|
|---|
| 597 | *
|
|---|
| 598 | * @param file stream to print to
|
|---|
| [c4d4df] | 599 | */
|
|---|
| [92e5cb] | 600 | void OutputCorrelation_Header( ofstream * const file )
|
|---|
| [c4d4df] | 601 | {
|
|---|
| [92e5cb] | 602 | *file << "\tCount";
|
|---|
| [c4d4df] | 603 | };
|
|---|
| [b1f254] | 604 |
|
|---|
| [92e5cb] | 605 | /** Prints values stored in BinPairMap iterator.
|
|---|
| 606 | *
|
|---|
| 607 | * @param file stream to print to
|
|---|
| 608 | * @param runner iterator pointing at values to print
|
|---|
| [be945c] | 609 | */
|
|---|
| [92e5cb] | 610 | void OutputCorrelation_Value( ofstream * const file, BinPairMap::const_iterator &runner )
|
|---|
| [be945c] | 611 | {
|
|---|
| [92e5cb] | 612 | *file << runner->second;
|
|---|
| [be945c] | 613 | };
|
|---|
| 614 |
|
|---|
| [92e5cb] | 615 |
|
|---|
| 616 | /** Adds header part that is unique to DipoleAngularCorrelationMap.
|
|---|
| 617 | *
|
|---|
| 618 | * @param file stream to print to
|
|---|
| [b1f254] | 619 | */
|
|---|
| [92e5cb] | 620 | void OutputDipoleAngularCorrelation_Header( ofstream * const file )
|
|---|
| [b1f254] | 621 | {
|
|---|
| [4b8630] | 622 | *file << "\tFirstAtomOfMolecule";
|
|---|
| [b1f254] | 623 | };
|
|---|
| 624 |
|
|---|
| [208237b] | 625 | /** Prints values stored in DipoleCorrelationMap iterator.
|
|---|
| [92e5cb] | 626 | *
|
|---|
| 627 | * @param file stream to print to
|
|---|
| 628 | * @param runner iterator pointing at values to print
|
|---|
| [b1f254] | 629 | */
|
|---|
| [92e5cb] | 630 | void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner )
|
|---|
| [208237b] | 631 | {
|
|---|
| [4b8630] | 632 | *file << runner->second->getName();
|
|---|
| [208237b] | 633 | };
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 | /** Adds header part that is unique to DipoleAngularCorrelationMap.
|
|---|
| 637 | *
|
|---|
| 638 | * @param file stream to print to
|
|---|
| 639 | */
|
|---|
| 640 | void OutputDipoleCorrelation_Header( ofstream * const file )
|
|---|
| 641 | {
|
|---|
| 642 | *file << "\tMolecule";
|
|---|
| 643 | };
|
|---|
| 644 |
|
|---|
| 645 | /** Prints values stored in DipoleCorrelationMap iterator.
|
|---|
| 646 | *
|
|---|
| 647 | * @param file stream to print to
|
|---|
| 648 | * @param runner iterator pointing at values to print
|
|---|
| 649 | */
|
|---|
| 650 | void OutputDipoleCorrelation_Value( ofstream * const file, DipoleCorrelationMap::const_iterator &runner )
|
|---|
| [b1f254] | 651 | {
|
|---|
| [92e5cb] | 652 | *file << runner->second.first->getId() << "\t" << runner->second.second->getId();
|
|---|
| [b1f254] | 653 | };
|
|---|
| 654 |
|
|---|
| [92e5cb] | 655 |
|
|---|
| 656 | /** Adds header part that is unique to PairCorrelationMap.
|
|---|
| 657 | *
|
|---|
| 658 | * @param file stream to print to
|
|---|
| [b1f254] | 659 | */
|
|---|
| [92e5cb] | 660 | void OutputPairCorrelation_Header( ofstream * const file )
|
|---|
| [b1f254] | 661 | {
|
|---|
| [92e5cb] | 662 | *file << "\tAtom1\tAtom2";
|
|---|
| 663 | };
|
|---|
| 664 |
|
|---|
| 665 | /** Prints values stored in PairCorrelationMap iterator.
|
|---|
| 666 | *
|
|---|
| 667 | * @param file stream to print to
|
|---|
| 668 | * @param runner iterator pointing at values to print
|
|---|
| 669 | */
|
|---|
| 670 | void OutputPairCorrelation_Value( ofstream * const file, PairCorrelationMap::const_iterator &runner )
|
|---|
| 671 | {
|
|---|
| 672 | *file << *(runner->second.first) << "\t" << *(runner->second.second);
|
|---|
| 673 | };
|
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 | /** Adds header part that is unique to CorrelationToPointMap.
|
|---|
| 677 | *
|
|---|
| 678 | * @param file stream to print to
|
|---|
| 679 | */
|
|---|
| 680 | void OutputCorrelationToPoint_Header( ofstream * const file )
|
|---|
| 681 | {
|
|---|
| 682 | *file << "\tAtom::x[i]-point.x[i]";
|
|---|
| 683 | };
|
|---|
| 684 |
|
|---|
| 685 | /** Prints values stored in CorrelationToPointMap iterator.
|
|---|
| 686 | *
|
|---|
| 687 | * @param file stream to print to
|
|---|
| 688 | * @param runner iterator pointing at values to print
|
|---|
| 689 | */
|
|---|
| 690 | void OutputCorrelationToPoint_Value( ofstream * const file, CorrelationToPointMap::const_iterator &runner )
|
|---|
| 691 | {
|
|---|
| 692 | for (int i=0;i<NDIM;i++)
|
|---|
| 693 | *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i));
|
|---|
| [b1f254] | 694 | };
|
|---|
| 695 |
|
|---|
| [92e5cb] | 696 |
|
|---|
| 697 | /** Adds header part that is unique to CorrelationToSurfaceMap.
|
|---|
| 698 | *
|
|---|
| 699 | * @param file stream to print to
|
|---|
| 700 | */
|
|---|
| 701 | void OutputCorrelationToSurface_Header( ofstream * const file )
|
|---|
| 702 | {
|
|---|
| 703 | *file << "\tTriangle";
|
|---|
| 704 | };
|
|---|
| 705 |
|
|---|
| 706 | /** Prints values stored in CorrelationToSurfaceMap iterator.
|
|---|
| 707 | *
|
|---|
| 708 | * @param file stream to print to
|
|---|
| 709 | * @param runner iterator pointing at values to print
|
|---|
| 710 | */
|
|---|
| 711 | void OutputCorrelationToSurface_Value( ofstream * const file, CorrelationToSurfaceMap::const_iterator &runner )
|
|---|
| 712 | {
|
|---|
| 713 | *file << *(runner->second.first) << "\t" << *(runner->second.second);
|
|---|
| 714 | };
|
|---|