Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_correlation.cpp

    r7fd416 r1513a74  
    3939    return outmap;
    4040  }
    41   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    42     (*MolWalker)->doCountAtoms();
    4341  outmap = new PairCorrelationMap;
    44   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
     42  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    4543    if ((*MolWalker)->ActiveFlag) {
    4644      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    47       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    48       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    49         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    50         if ((type1 == NULL) || ((*iter)->type == type1)) {
    51           for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     45      atom *Walker = (*MolWalker)->start;
     46      while (Walker->next != (*MolWalker)->end) {
     47        Walker = Walker->next;
     48        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
     49        if ((type1 == NULL) || (Walker->type == type1)) {
     50          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    5251            if ((*MolOtherWalker)->ActiveFlag) {
    5352              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    54               for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    55                 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    56                 if ((*iter)->getId() < (*runner)->getId()){
    57                   if ((type2 == NULL) || ((*runner)->type == type2)) {
    58                     distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  World::getInstance().getDomain());
    59                     //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    60                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
     53              atom *OtherWalker = (*MolOtherWalker)->start;
     54              while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
     55                OtherWalker = OtherWalker->next;
     56                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
     57                if (Walker->nr < OtherWalker->nr)
     58                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
     59                    distance = Walker->node->PeriodicDistance(*OtherWalker->node, World::getInstance().getDomain());
     60                    //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
     61                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
    6162                  }
    62                 }
    6363              }
    64             }
    6564          }
    6665        }
    6766      }
    6867    }
    69   }
     68
    7069  return outmap;
    7170};
     
    9695    return outmap;
    9796  }
    98   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    99     (*MolWalker)->doCountAtoms();
    10097  outmap = new PairCorrelationMap;
    10198  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    104101      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    105102      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    106       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    107         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    108         if ((type1 == NULL) || ((*iter)->type == type1)) {
    109           periodicX = *(*iter)->node;
     103      atom *Walker = (*MolWalker)->start;
     104      while (Walker->next != (*MolWalker)->end) {
     105        Walker = Walker->next;
     106        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
     107        if ((type1 == NULL) || (Walker->type == type1)) {
     108          periodicX = *(Walker->node);
    110109          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    111110          // go through every range in xyz and get distance
     
    118117                  if ((*MolOtherWalker)->ActiveFlag) {
    119118                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    120                     for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    121                       DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    122                       if ((*iter)->nr < (*runner)->nr)
    123                         if ((type2 == NULL) || ((*runner)->type == type2)) {
    124                           periodicOtherX = *(*runner)->node;
     119                    atom *OtherWalker = (*MolOtherWalker)->start;
     120                    while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
     121                      OtherWalker = OtherWalker->next;
     122                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
     123                      if (Walker->nr < OtherWalker->nr)
     124                        if ((type2 == NULL) || (OtherWalker->type == type2)) {
     125                          periodicOtherX = *(OtherWalker->node);
    125126                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    126127                          // go through every range in xyz and get distance
     
    131132                                checkOtherX.MatrixMultiplication(FullMatrix);
    132133                                distance = checkX.distance(checkOtherX);
    133                                 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    134                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
     134                                //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
     135                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
    135136                              }
    136137                        }
     
    140141        }
    141142      }
    142       delete[](FullMatrix);
    143       delete[](FullInverseMatrix);
     143      Free(&FullMatrix);
     144      Free(&FullInverseMatrix);
    144145    }
    145146
     
    164165    return outmap;
    165166  }
    166   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    167     (*MolWalker)->doCountAtoms();
    168167  outmap = new CorrelationToPointMap;
    169168  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    170169    if ((*MolWalker)->ActiveFlag) {
    171170      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    172       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    173         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    174         if ((type == NULL) || ((*iter)->type == type)) {
    175           distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain());
     171      atom *Walker = (*MolWalker)->start;
     172      while (Walker->next != (*MolWalker)->end) {
     173        Walker = Walker->next;
     174        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
     175        if ((type == NULL) || (Walker->type == type)) {
     176          distance = Walker->node->PeriodicDistance(*point, World::getInstance().getDomain());
    176177          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    177           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     178          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    178179        }
    179180      }
     
    204205    return outmap;
    205206  }
    206   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    207     (*MolWalker)->doCountAtoms();
    208207  outmap = new CorrelationToPointMap;
    209208  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    212211      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    213212      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    214       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    215         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    216         if ((type == NULL) || ((*iter)->type == type)) {
    217           periodicX = *(*iter)->node;
     213      atom *Walker = (*MolWalker)->start;
     214      while (Walker->next != (*MolWalker)->end) {
     215        Walker = Walker->next;
     216        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
     217        if ((type == NULL) || (Walker->type == type)) {
     218          periodicX = *(Walker->node);
    218219          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    219220          // go through every range in xyz and get distance
     
    225226                distance = checkX.distance(*point);
    226227                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    227                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     228                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    228229              }
    229230        }
    230231      }
    231       delete[](FullMatrix);
    232       delete[](FullInverseMatrix);
     232      Free(&FullMatrix);
     233      Free(&FullInverseMatrix);
    233234    }
    234235
     
    256257    return outmap;
    257258  }
    258   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    259     (*MolWalker)->doCountAtoms();
    260259  outmap = new CorrelationToSurfaceMap;
    261260  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    262261    if ((*MolWalker)->ActiveFlag) {
    263262      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    264       if ((*MolWalker)->empty())
    265         DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
    266       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    267         DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
    268         if ((type == NULL) || ((*iter)->type == type)) {
    269           TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     263      atom *Walker = (*MolWalker)->start;
     264      while (Walker->next != (*MolWalker)->end) {
     265        Walker = Walker->next;
     266        //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
     267        if ((type == NULL) || (Walker->type == type)) {
     268          TriangleIntersectionList Intersections(Walker->node,Surface,LC);
    270269          distance = Intersections.GetSmallestDistance();
    271270          triangle = Intersections.GetClosestTriangle();
    272           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    273         }
    274       }
    275     } else {
     271          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     272        }
     273      }
     274    } else
    276275      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    277     }
    278276
    279277  return outmap;
     
    308306    return outmap;
    309307  }
    310   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    311     (*MolWalker)->doCountAtoms();
    312308  outmap = new CorrelationToSurfaceMap;
    313309  double ShortestDistance = 0.;
     
    318314      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    319315      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    320       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    321         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    322         if ((type == NULL) || ((*iter)->type == type)) {
    323           periodicX = *(*iter)->node;
     316      atom *Walker = (*MolWalker)->start;
     317      while (Walker->next != (*MolWalker)->end) {
     318        Walker = Walker->next;
     319        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
     320        if ((type == NULL) || (Walker->type == type)) {
     321          periodicX = *(Walker->node);
    324322          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    325323          // go through every range in xyz and get distance
     
    339337              }
    340338          // insert
    341           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     339          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    342340          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    343341        }
    344342      }
    345       delete[](FullMatrix);
    346       delete[](FullInverseMatrix);
     343      Free(&FullMatrix);
     344      Free(&FullInverseMatrix);
    347345    }
    348346
Note: See TracChangeset for help on using the changeset viewer.