Ignore:
Timestamp:
Nov 4, 2009, 5:34:05 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
5f1d021
Parents:
c1b76e
Message:

Extension to the periodic boundary case for analysis_correlation.cpp

other stuff:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/analysis_correlation.cpp

    rc1b76e r20895b  
    5252                if (Walker->nr < OtherWalker->nr)
    5353                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
    54                     distance = Walker->node->Distance(OtherWalker->node);
     54                    distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
    5555                    //*out << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    5656                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     
    9090        *out << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    9191        if ((type == NULL) || (Walker->type == type)) {
    92           distance = Walker->node->Distance(point);
     92          distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
    9393          *out << Verbose(4) << "Current distance is " << distance << "." << endl;
    9494          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     
    111111{
    112112  CorrelationToSurfaceMap *outmap = NULL;
    113   double distance = 0.;
     113  double distance = 0;
    114114  class BoundaryTriangleSet *triangle = NULL;
    115115  Vector centroid;
     116  int ranges[NDIM] = {1, 1, 1};
     117  int n[NDIM];
     118  Vector periodicX;
     119  Vector checkX;
    116120
    117121  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
     
    122126  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    123127    if ((*MolWalker)->ActiveFlag) {
     128      const double * const FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     129      const double * const FullInverseMatrix = InverseMatrix(FullMatrix);
    124130      *out << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    125131      atom *Walker = (*MolWalker)->start;
     
    128134        *out << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    129135        if ((type == NULL) || (Walker->type == type)) {
    130           triangle = Surface->FindClosestTriangleToPoint(out, Walker->node, LC );
    131           if (triangle != NULL) {
    132             distance = DistanceToTrianglePlane(out, Walker->node, triangle);
    133             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     136          periodicX.CopyVector(Walker->node);
     137          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     138          // go through every range in xyz and get distance
     139          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     140            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     141              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     142                checkX.Init(n[0], n[1], n[2]);
     143                checkX.AddVector(&periodicX);
     144                checkX.MatrixMultiplication(FullMatrix);
     145                triangle = Surface->FindClosestTriangleToPoint(out, &checkX, LC );
     146                if (triangle != NULL) {
     147                  distance = DistanceToTrianglePlane(out, &checkX, triangle);
     148                  outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     149                }
    134150          }
    135151        }
Note: See TracChangeset for help on using the changeset viewer.