| [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)
|
|---|
| [325687] | 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.
|
|---|
| [ea430a] | 152 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 153 | */
|
|---|
| [325687] | 154 | DipoleAngularCorrelationMap *DipoleAngularCorrelation(
|
|---|
| 155 | std::vector<atom *> &atoms,
|
|---|
| 156 | std::map<atomId_t, Vector> &ZeroVector
|
|---|
| 157 | )
|
|---|
| [ea430a] | 158 | {
|
|---|
| 159 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 160 | DipoleAngularCorrelationMap *outmap = new DipoleAngularCorrelationMap;
|
|---|
| [be945c] | 161 |
|
|---|
| [208237b] | 162 | // store original time step
|
|---|
| 163 | const unsigned int oldtime = WorldTime::getTime();
|
|---|
| 164 | World::getInstance().setTime(0);
|
|---|
| [0a7fad] | 165 |
|
|---|
| [4b8630] | 166 | // calculate molecules for this time step
|
|---|
| [0a7fad] | 167 | std::set<molecule *> molecules;
|
|---|
| [4b8630] | 168 | BOOST_FOREACH(atom *_atom, atoms)
|
|---|
| 169 | molecules.insert(_atom->getMolecule());
|
|---|
| [208237b] | 170 |
|
|---|
| [4fc828] | 171 | BOOST_FOREACH(atom *_atom, World::getInstance().getAllAtoms())
|
|---|
| 172 | LOG(2, "INFO: Atom " << _atom->getId() << " "
|
|---|
| 173 | << *dynamic_cast<AtomInfo *>(_atom) <<".");
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| [325687] | 176 | // get zero orientation for each atom if not given
|
|---|
| 177 | if (ZeroVector.size() != atoms.size()) {
|
|---|
| 178 | ZeroVector.clear();
|
|---|
| 179 | ZeroVector = CalculateZeroAngularDipole(atoms);
|
|---|
| 180 | }
|
|---|
| [4fc828] | 181 |
|
|---|
| [208237b] | 182 | // go through every time step
|
|---|
| [4fc828] | 183 | LOG(0,"STATUS: Calculating dipoles of following time steps ...");
|
|---|
| [1cc661] | 184 | range<size_t> timesteps = getMaximumTrajectoryBounds(atoms);
|
|---|
| 185 | for (size_t step = 1; step < timesteps.first; ++step) {
|
|---|
| [208237b] | 186 | World::getInstance().setTime(step);
|
|---|
| [4b8630] | 187 | // recalculate molecules for this time step
|
|---|
| 188 | molecules.clear();
|
|---|
| 189 | BOOST_FOREACH(atom *_atom, atoms)
|
|---|
| 190 | molecules.insert(_atom->getMolecule());
|
|---|
| [208237b] | 191 | size_t i=0;
|
|---|
| 192 | BOOST_FOREACH(molecule *_mol, molecules) {
|
|---|
| 193 | const Vector Dipole = getDipole(_mol->begin(), _mol->end());
|
|---|
| [325687] | 194 | LOG(2,"INFO: Dipole vector at time step " << step << " for for molecule "
|
|---|
| 195 | << _mol->getId() << " is " << Dipole);
|
|---|
| [be0c61] | 196 | molecule::const_iterator iter = _mol->begin();
|
|---|
| 197 | ASSERT(ZeroVector.count((*iter)->getId()),
|
|---|
| 198 | "DipoleAngularCorrelation() - ZeroVector for atom "+toString(**iter)+" not present.");
|
|---|
| [325687] | 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 << ".");
|
|---|
| [be0c61] | 210 | outmap->insert ( make_pair (angle, *iter ) );
|
|---|
| [208237b] | 211 | ++i;
|
|---|
| 212 | }
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | // set original time step again
|
|---|
| 217 | World::getInstance().setTime(oldtime);
|
|---|
| [4fc828] | 218 | LOG(0,"STATUS: Done.");
|
|---|
| [208237b] | 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 |
|
|---|
| [be945c] | 245 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
|
|---|
| [92e5cb] | 246 | MolWalker != molecules.end(); ++MolWalker) {
|
|---|
| [be945c] | 247 | DoLog(2) && (Log()<< Verbose(2) << "Current molecule is "
|
|---|
| 248 | << (*MolWalker)->getId() << "." << endl);
|
|---|
| 249 | const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
|
|---|
| [92e5cb] | 250 | std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker;
|
|---|
| 251 | for (++MolOtherWalker;
|
|---|
| [be945c] | 252 | MolOtherWalker != molecules.end();
|
|---|
| [92e5cb] | 253 | ++MolOtherWalker) {
|
|---|
| [be945c] | 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 | }
|
|---|
| [ea430a] | 262 | return outmap;
|
|---|
| 263 | };
|
|---|
| 264 |
|
|---|
| [c4d4df] | 265 |
|
|---|
| 266 | /** Calculates the pair correlation between given elements.
|
|---|
| 267 | * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
|
|---|
| [e65de8] | 268 | * \param *molecules vector of molecules
|
|---|
| [c78d44] | 269 | * \param &elements vector of elements to correlate
|
|---|
| [c4d4df] | 270 | * \return Map of doubles with values the pair of the two atoms.
|
|---|
| 271 | */
|
|---|
| [e5c0a1] | 272 | PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
|
|---|
| [c4d4df] | 273 | {
|
|---|
| [3930eb] | 274 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 275 | PairCorrelationMap *outmap = new PairCorrelationMap;
|
|---|
| [c4d4df] | 276 | double distance = 0.;
|
|---|
| [014475] | 277 | Box &domain = World::getInstance().getDomain();
|
|---|
| [c4d4df] | 278 |
|
|---|
| [e65de8] | 279 | if (molecules.empty()) {
|
|---|
| [58ed4a] | 280 | DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
|
|---|
| [c4d4df] | 281 | return outmap;
|
|---|
| 282 | }
|
|---|
| [e65de8] | 283 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 284 | (*MolWalker)->doCountAtoms();
|
|---|
| [c78d44] | 285 |
|
|---|
| 286 | // create all possible pairs of elements
|
|---|
| [e5c0a1] | 287 | set <pair<const element *,const element *> > PairsOfElements;
|
|---|
| [c78d44] | 288 | if (elements.size() >= 2) {
|
|---|
| [e5c0a1] | 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)
|
|---|
| [c78d44] | 291 | if (type1 != type2) {
|
|---|
| [e5c0a1] | 292 | PairsOfElements.insert( make_pair(*type1,*type2) );
|
|---|
| [2fe971] | 293 | DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
|
|---|
| [c78d44] | 294 | }
|
|---|
| 295 | } else if (elements.size() == 1) { // one to all are valid
|
|---|
| [e5c0a1] | 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) );
|
|---|
| [c78d44] | 299 | } else { // all elements valid
|
|---|
| 300 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| [c4d4df] | 303 | outmap = new PairCorrelationMap;
|
|---|
| [e65de8] | 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()){
|
|---|
| [b5c53d] | 313 | for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
|
|---|
| [d74077] | 314 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
|
|---|
| 315 | distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition());
|
|---|
| [e65de8] | 316 | //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
|
|---|
| 317 | outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
|
|---|
| [a5551b] | 318 | }
|
|---|
| [c4d4df] | 319 | }
|
|---|
| [a5551b] | 320 | }
|
|---|
| [c4d4df] | 321 | }
|
|---|
| 322 | }
|
|---|
| [24725c] | 323 | }
|
|---|
| [c4d4df] | 324 | return outmap;
|
|---|
| 325 | };
|
|---|
| 326 |
|
|---|
| [7ea9e6] | 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
|
|---|
| [c78d44] | 330 | * \param &elements vector of elements to correlate
|
|---|
| [7ea9e6] | 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 | */
|
|---|
| [e5c0a1] | 334 | PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 335 | {
|
|---|
| [3930eb] | 336 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 337 | PairCorrelationMap *outmap = new PairCorrelationMap;
|
|---|
| [7ea9e6] | 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 |
|
|---|
| [e65de8] | 346 | if (molecules.empty()) {
|
|---|
| [58ed4a] | 347 | DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
|
|---|
| [7ea9e6] | 348 | return outmap;
|
|---|
| 349 | }
|
|---|
| [e65de8] | 350 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 351 | (*MolWalker)->doCountAtoms();
|
|---|
| [c78d44] | 352 |
|
|---|
| 353 | // create all possible pairs of elements
|
|---|
| [e5c0a1] | 354 | set <pair<const element *,const element *> > PairsOfElements;
|
|---|
| [c78d44] | 355 | if (elements.size() >= 2) {
|
|---|
| [e5c0a1] | 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)
|
|---|
| [c78d44] | 358 | if (type1 != type2) {
|
|---|
| [e5c0a1] | 359 | PairsOfElements.insert( make_pair(*type1,*type2) );
|
|---|
| [2fe971] | 360 | DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
|
|---|
| [c78d44] | 361 | }
|
|---|
| 362 | } else if (elements.size() == 1) { // one to all are valid
|
|---|
| [e5c0a1] | 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) );
|
|---|
| [c78d44] | 366 | } else { // all elements valid
|
|---|
| 367 | PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| [7ea9e6] | 370 | outmap = new PairCorrelationMap;
|
|---|
| [e65de8] | 371 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
|
|---|
| [cca9ef] | 372 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 373 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 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);
|
|---|
| [d74077] | 377 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 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()){
|
|---|
| [e5c0a1] | 388 | for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
|
|---|
| [d74077] | 389 | if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
|
|---|
| 390 | periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 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 | }
|
|---|
| [c78d44] | 401 | }
|
|---|
| [7ea9e6] | 402 | }
|
|---|
| [c78d44] | 403 | }
|
|---|
| [7ea9e6] | 404 | }
|
|---|
| 405 | }
|
|---|
| [c78d44] | 406 | }
|
|---|
| [7ea9e6] | 407 |
|
|---|
| 408 | return outmap;
|
|---|
| 409 | };
|
|---|
| 410 |
|
|---|
| [c4d4df] | 411 | /** Calculates the distance (pair) correlation between a given element and a point.
|
|---|
| [a5551b] | 412 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 413 | * \param &elements vector of elements to correlate with point
|
|---|
| [c4d4df] | 414 | * \param *point vector to the correlation point
|
|---|
| 415 | * \return Map of dobules with values as pairs of atom and the vector
|
|---|
| 416 | */
|
|---|
| [e5c0a1] | 417 | CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
|
|---|
| [c4d4df] | 418 | {
|
|---|
| [3930eb] | 419 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 420 | CorrelationToPointMap *outmap = new CorrelationToPointMap;
|
|---|
| [c4d4df] | 421 | double distance = 0.;
|
|---|
| [014475] | 422 | Box &domain = World::getInstance().getDomain();
|
|---|
| [c4d4df] | 423 |
|
|---|
| [e65de8] | 424 | if (molecules.empty()) {
|
|---|
| [a67d19] | 425 | DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
|
|---|
| [c4d4df] | 426 | return outmap;
|
|---|
| 427 | }
|
|---|
| [e65de8] | 428 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 429 | (*MolWalker)->doCountAtoms();
|
|---|
| [c4d4df] | 430 | outmap = new CorrelationToPointMap;
|
|---|
| [e65de8] | 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);
|
|---|
| [e5c0a1] | 435 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 436 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 437 | distance = domain.periodicDistance((*iter)->getPosition(),*point);
|
|---|
| [e65de8] | 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 | }
|
|---|
| [c4d4df] | 441 | }
|
|---|
| [e65de8] | 442 | }
|
|---|
| [c4d4df] | 443 |
|
|---|
| 444 | return outmap;
|
|---|
| 445 | };
|
|---|
| 446 |
|
|---|
| [7ea9e6] | 447 | /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
|
|---|
| 448 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 449 | * \param &elements vector of elements to correlate to point
|
|---|
| [7ea9e6] | 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 | */
|
|---|
| [e5c0a1] | 454 | CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 455 | {
|
|---|
| [3930eb] | 456 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 457 | CorrelationToPointMap *outmap = new CorrelationToPointMap;
|
|---|
| [7ea9e6] | 458 | double distance = 0.;
|
|---|
| 459 | int n[NDIM];
|
|---|
| 460 | Vector periodicX;
|
|---|
| 461 | Vector checkX;
|
|---|
| 462 |
|
|---|
| [e65de8] | 463 | if (molecules.empty()) {
|
|---|
| [a67d19] | 464 | DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
|
|---|
| [7ea9e6] | 465 | return outmap;
|
|---|
| 466 | }
|
|---|
| [e65de8] | 467 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 468 | (*MolWalker)->doCountAtoms();
|
|---|
| [7ea9e6] | 469 | outmap = new CorrelationToPointMap;
|
|---|
| [e65de8] | 470 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| [cca9ef] | 471 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 472 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 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);
|
|---|
| [e5c0a1] | 476 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 477 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 478 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 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 | }
|
|---|
| [7ea9e6] | 489 | }
|
|---|
| [e65de8] | 490 | }
|
|---|
| [7ea9e6] | 491 |
|
|---|
| 492 | return outmap;
|
|---|
| 493 | };
|
|---|
| 494 |
|
|---|
| [c4d4df] | 495 | /** Calculates the distance (pair) correlation between a given element and a surface.
|
|---|
| [a5551b] | 496 | * \param *molecules list of molecules structure
|
|---|
| [c78d44] | 497 | * \param &elements vector of elements to correlate to surface
|
|---|
| [c4d4df] | 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 | */
|
|---|
| [e5c0a1] | 502 | CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
|
|---|
| [c4d4df] | 503 | {
|
|---|
| [3930eb] | 504 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 505 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap;
|
|---|
| [99593f] | 506 | double distance = 0;
|
|---|
| [c4d4df] | 507 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 508 | Vector centroid;
|
|---|
| [7ea9e6] | 509 |
|
|---|
| [e65de8] | 510 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
|
|---|
| [58ed4a] | 511 | DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
|
|---|
| [7ea9e6] | 512 | return outmap;
|
|---|
| 513 | }
|
|---|
| [e65de8] | 514 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 515 | (*MolWalker)->doCountAtoms();
|
|---|
| [7ea9e6] | 516 | outmap = new CorrelationToSurfaceMap;
|
|---|
| [e65de8] | 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);
|
|---|
| [e5c0a1] | 523 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 524 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 525 | TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC);
|
|---|
| [e65de8] | 526 | distance = Intersections.GetSmallestDistance();
|
|---|
| 527 | triangle = Intersections.GetClosestTriangle();
|
|---|
| 528 | outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
|
|---|
| 529 | }
|
|---|
| [7fd416] | 530 | }
|
|---|
| [e65de8] | 531 | }
|
|---|
| [7ea9e6] | 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
|
|---|
| [c78d44] | 542 | * \param &elements vector of elements to correlate to surface
|
|---|
| [7ea9e6] | 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 | */
|
|---|
| [e5c0a1] | 548 | CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
|
|---|
| [7ea9e6] | 549 | {
|
|---|
| [3930eb] | 550 | Info FunctionInfo(__func__);
|
|---|
| [caa30b] | 551 | CorrelationToSurfaceMap *outmap = new CorrelationToSurfaceMap;
|
|---|
| [7ea9e6] | 552 | double distance = 0;
|
|---|
| 553 | class BoundaryTriangleSet *triangle = NULL;
|
|---|
| 554 | Vector centroid;
|
|---|
| [99593f] | 555 | int n[NDIM];
|
|---|
| 556 | Vector periodicX;
|
|---|
| 557 | Vector checkX;
|
|---|
| [c4d4df] | 558 |
|
|---|
| [e65de8] | 559 | if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
|
|---|
| [a67d19] | 560 | DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
|
|---|
| [c4d4df] | 561 | return outmap;
|
|---|
| 562 | }
|
|---|
| [e65de8] | 563 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
|
|---|
| [009607e] | 564 | (*MolWalker)->doCountAtoms();
|
|---|
| [c4d4df] | 565 | outmap = new CorrelationToSurfaceMap;
|
|---|
| [244a84] | 566 | double ShortestDistance = 0.;
|
|---|
| 567 | BoundaryTriangleSet *ShortestTriangle = NULL;
|
|---|
| [e65de8] | 568 | for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
|
|---|
| [cca9ef] | 569 | RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
|
|---|
| 570 | RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
|
|---|
| [e65de8] | 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);
|
|---|
| [e5c0a1] | 574 | for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
|
|---|
| [d74077] | 575 | if ((*type == NULL) || ((*iter)->getType() == *type)) {
|
|---|
| 576 | periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
|
|---|
| [e65de8] | 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);
|
|---|
| [d74077] | 583 | TriangleIntersectionList Intersections(checkX,Surface,LC);
|
|---|
| [e65de8] | 584 | distance = Intersections.GetSmallestDistance();
|
|---|
| 585 | triangle = Intersections.GetClosestTriangle();
|
|---|
| 586 | if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
|
|---|
| 587 | ShortestDistance = distance;
|
|---|
| 588 | ShortestTriangle = triangle;
|
|---|
| [99593f] | 589 | }
|
|---|
| [e65de8] | 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 | }
|
|---|
| [c4d4df] | 595 | }
|
|---|
| [e65de8] | 596 | }
|
|---|
| [c4d4df] | 597 |
|
|---|
| 598 | return outmap;
|
|---|
| 599 | };
|
|---|
| 600 |
|
|---|
| [bd61b41] | 601 | /** Returns the index of the bin for a given value.
|
|---|
| [c4d4df] | 602 | * \param value value whose bin to look for
|
|---|
| 603 | * \param BinWidth width of bin
|
|---|
| 604 | * \param BinStart first bin
|
|---|
| 605 | */
|
|---|
| [bd61b41] | 606 | int GetBin ( const double value, const double BinWidth, const double BinStart )
|
|---|
| [c4d4df] | 607 | {
|
|---|
| [92e5cb] | 608 | //Info FunctionInfo(__func__);
|
|---|
| [bd61b41] | 609 | int bin =(int) (floor((value - BinStart)/BinWidth));
|
|---|
| 610 | return (bin);
|
|---|
| [c4d4df] | 611 | };
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| [92e5cb] | 614 | /** Adds header part that is unique to BinPairMap.
|
|---|
| 615 | *
|
|---|
| 616 | * @param file stream to print to
|
|---|
| [c4d4df] | 617 | */
|
|---|
| [92e5cb] | 618 | void OutputCorrelation_Header( ofstream * const file )
|
|---|
| [c4d4df] | 619 | {
|
|---|
| [92e5cb] | 620 | *file << "\tCount";
|
|---|
| [c4d4df] | 621 | };
|
|---|
| [b1f254] | 622 |
|
|---|
| [92e5cb] | 623 | /** Prints values stored in BinPairMap iterator.
|
|---|
| 624 | *
|
|---|
| 625 | * @param file stream to print to
|
|---|
| 626 | * @param runner iterator pointing at values to print
|
|---|
| [be945c] | 627 | */
|
|---|
| [92e5cb] | 628 | void OutputCorrelation_Value( ofstream * const file, BinPairMap::const_iterator &runner )
|
|---|
| [be945c] | 629 | {
|
|---|
| [92e5cb] | 630 | *file << runner->second;
|
|---|
| [be945c] | 631 | };
|
|---|
| 632 |
|
|---|
| [92e5cb] | 633 |
|
|---|
| 634 | /** Adds header part that is unique to DipoleAngularCorrelationMap.
|
|---|
| 635 | *
|
|---|
| 636 | * @param file stream to print to
|
|---|
| [b1f254] | 637 | */
|
|---|
| [92e5cb] | 638 | void OutputDipoleAngularCorrelation_Header( ofstream * const file )
|
|---|
| [b1f254] | 639 | {
|
|---|
| [4b8630] | 640 | *file << "\tFirstAtomOfMolecule";
|
|---|
| [b1f254] | 641 | };
|
|---|
| 642 |
|
|---|
| [208237b] | 643 | /** Prints values stored in DipoleCorrelationMap iterator.
|
|---|
| [92e5cb] | 644 | *
|
|---|
| 645 | * @param file stream to print to
|
|---|
| 646 | * @param runner iterator pointing at values to print
|
|---|
| [b1f254] | 647 | */
|
|---|
| [92e5cb] | 648 | void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner )
|
|---|
| [208237b] | 649 | {
|
|---|
| [4b8630] | 650 | *file << runner->second->getName();
|
|---|
| [208237b] | 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 )
|
|---|
| [b1f254] | 669 | {
|
|---|
| [92e5cb] | 670 | *file << runner->second.first->getId() << "\t" << runner->second.second->getId();
|
|---|
| [b1f254] | 671 | };
|
|---|
| 672 |
|
|---|
| [92e5cb] | 673 |
|
|---|
| 674 | /** Adds header part that is unique to PairCorrelationMap.
|
|---|
| 675 | *
|
|---|
| 676 | * @param file stream to print to
|
|---|
| [b1f254] | 677 | */
|
|---|
| [92e5cb] | 678 | void OutputPairCorrelation_Header( ofstream * const file )
|
|---|
| [b1f254] | 679 | {
|
|---|
| [92e5cb] | 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));
|
|---|
| [b1f254] | 712 | };
|
|---|
| 713 |
|
|---|
| [92e5cb] | 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 | };
|
|---|