Ignore:
Timestamp:
Aug 20, 2014, 1:06:47 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Children:
4a44ed, 9d51a8
Parents:
f5fa48
git-author:
Frederik Heber <heber@…> (07/18/14 17:45:45)
git-committer:
Frederik Heber <heber@…> (08/20/14 13:06:47)
Message:

FragmentationAction now compiles global saturation positions information.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    rf5fa48 rd635829  
    4343#include "Fragmentation/Exporters/ExportGraph_ToJobs.hpp"
    4444#include "Fragmentation/Exporters/SaturatedFragment.hpp"
     45#include "Fragmentation/Exporters/SphericalPointDistribution.hpp"
    4546#include "Fragmentation/Fragmentation.hpp"
    4647#include "Fragmentation/Graph.hpp"
     
    264265  // create global saturation positions map
    265266  SaturatedFragment::GlobalSaturationPositions_t globalsaturationpositions;
     267  {
     268    // go through each atom
     269    for (World::AtomSelectionConstIterator iter = world.beginAtomSelection();
     270        iter != world.endAtomSelection(); ++iter) {
     271      const atom * const _atom = iter->second;
     272
     273      // skip hydrogens if treated special
     274      const enum HydrogenTreatment treatment =  params.HowtoTreatHydrogen.get() ? ExcludeHydrogen : IncludeHydrogen;
     275      if ((treatment == ExcludeHydrogen) && (_atom->getType()->getAtomicNumber() == 1)) {
     276        LOG(4, "DEBUG: Skipping hydrogen atom " << *_atom);
     277        continue;
     278      }
     279
     280      // gather the polygon
     281      SphericalPointDistribution::WeightedPolygon_t polygon;
     282      const BondList &bondlist = _atom->getListOfBonds();
     283      for (BondList::const_iterator bonditer = bondlist.begin();
     284          bonditer != bondlist.end(); ++bonditer) {
     285        const atom * const _otheratom = (*bonditer)->GetOtherAtom(_atom);
     286        Vector bondvector = _otheratom->getPosition() - _atom->getPosition();
     287        bondvector.Normalize();
     288        polygon.push_back(
     289            std::make_pair(
     290                bondvector,
     291                (*bonditer)->getDegree()
     292            ) );
     293      }
     294      LOG(3, "DEBUG: Polygon is " << polygon << " for this atom " << *_atom << ".");
     295
     296      // get the valence
     297      unsigned int NumberOfPoints = _atom->getElement().getNoValenceOrbitals();
     298      LOG(3, "DEBUG: There are " << NumberOfPoints
     299          << " places to fill in in total for this atom " << *_atom << ".");
     300
     301      // check whether there are any bonds with degree larger than 1
     302      unsigned int SumOfDegrees = 0;
     303      bool PresentHigherBonds = false;
     304      for (BondList::const_iterator bonditer = bondlist.begin();
     305          bonditer != bondlist.end(); ++bonditer) {
     306        SumOfDegrees += (*bonditer)->getDegree();
     307        PresentHigherBonds |= (*bonditer)->getDegree() > 1;
     308      }
     309
     310      // get the association for each bond neighbor
     311      SphericalPointDistribution SPD;
     312      SphericalPointDistribution::PolygonWithIndexTuples globalinfo;
     313      if ((NumberOfPoints != SumOfDegrees) || (PresentHigherBonds))
     314        globalinfo = SPD.getAssociatedPoints(polygon, NumberOfPoints);
     315      else
     316        globalinfo = SphericalPointDistribution::getIdentityAssociation(polygon);
     317      LOG(3, "DEBUG: Original polygon was " << polygon << " for this atom " << *_atom << ".");
     318      LOG(3, "DEBUG: Got global saturation polygon " << globalinfo.polygon
     319          << " for atom " << *_atom);
     320      LOG(3, "DEBUG: Associated matching is " << globalinfo.indices
     321          << " for atom " << *_atom);
     322
     323      // convert into the desired entry in the map
     324      SaturatedFragment::SaturationsPositionsPerNeighbor_t positions_per_neighbor;
     325      BondList::const_iterator bonditer = bondlist.begin();
     326      // same number of bonds and tuples
     327      ASSERT( bondlist.size() == globalinfo.indices.size(),
     328          "FragmentationAction::performCall() - number of bonds "
     329          +toString(bondlist.size())+" unequal to number of tuples "
     330          +toString(globalinfo.indices.size()));
     331      for (SphericalPointDistribution::IndexTupleList_t::const_iterator tupleiter =
     332          globalinfo.indices.begin();
     333          tupleiter != globalinfo.indices.end(); ++tupleiter, ++bonditer) {
     334        // note that we cannot check whether the designated vector matches with the
     335        // normalized bond vector where it should have originated because the
     336        // vector has been rotated.
     337//        Vector bondvector =
     338//            (*bonditer)->GetOtherAtom(_atom)->getPosition()-_atom->getPosition();
     339//        bondvector.Normalize();
     340        // no go through all indices of the tuple (and positions)
     341        for (SphericalPointDistribution::IndexList_t::const_iterator indexiter =
     342            tupleiter->begin(); indexiter != tupleiter->end(); ++indexiter) {
     343          // and add them, first trying with new list
     344          std::pair<
     345              SaturatedFragment::SaturationsPositionsPerNeighbor_t::iterator,
     346              bool
     347              > inserter =
     348                  positions_per_neighbor.insert(
     349                      std::make_pair(
     350                          (*bonditer)->GetOtherAtom(_atom)->getId(),
     351                          SaturatedFragment::SaturationsPositions_t(
     352                              1,
     353                              globalinfo.polygon[*indexiter])
     354                      )
     355                  );
     356          // if already pressent, add to this present list
     357          if (!inserter.second) {
     358            inserter.first->second.push_back(globalinfo.polygon[*indexiter]);
     359          }
     360        }
     361      }
     362      // bonditer follows nicely
     363      ASSERT( bonditer == bondlist.end(),
     364          "FragmentationAction::performCall() - bonditer is out of step, it still points at bond "
     365          +toString(*bonditer)+".");
     366
     367      // and insert
     368      globalsaturationpositions.insert(
     369          std::make_pair( _atom->getId(),
     370              positions_per_neighbor
     371          ));
     372    }
     373  }
    266374
    267375  {
Note: See TracChangeset for help on using the changeset viewer.