Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_correlation.cpp

    r1513a74 r7fd416  
    3939    return outmap;
    4040  }
     41  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     42    (*MolWalker)->doCountAtoms();
    4143  outmap = new PairCorrelationMap;
    42   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     44  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    4345    if ((*MolWalker)->ActiveFlag) {
    4446      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    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++)
     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++){
    5152            if ((*MolOtherWalker)->ActiveFlag) {
    5253              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    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) ) );
     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)) ) );
    6261                  }
     62                }
    6363              }
     64            }
    6465          }
    6566        }
    6667      }
    6768    }
    68 
     69  }
    6970  return outmap;
    7071};
     
    9596    return outmap;
    9697  }
     98  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     99    (*MolWalker)->doCountAtoms();
    97100  outmap = new PairCorrelationMap;
    98101  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    101104      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102105      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    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);
     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;
    109110          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    110111          // go through every range in xyz and get distance
     
    117118                  if ((*MolOtherWalker)->ActiveFlag) {
    118119                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    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);
     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;
    126125                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    127126                          // go through every range in xyz and get distance
     
    132131                                checkOtherX.MatrixMultiplication(FullMatrix);
    133132                                distance = checkX.distance(checkOtherX);
    134                                 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     133                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     134                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    136135                              }
    137136                        }
     
    141140        }
    142141      }
    143       Free(&FullMatrix);
    144       Free(&FullInverseMatrix);
     142      delete[](FullMatrix);
     143      delete[](FullInverseMatrix);
    145144    }
    146145
     
    165164    return outmap;
    166165  }
     166  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     167    (*MolWalker)->doCountAtoms();
    167168  outmap = new CorrelationToPointMap;
    168169  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169170    if ((*MolWalker)->ActiveFlag) {
    170171      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    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());
     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());
    177176          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     177          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    179178        }
    180179      }
     
    205204    return outmap;
    206205  }
     206  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     207    (*MolWalker)->doCountAtoms();
    207208  outmap = new CorrelationToPointMap;
    208209  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    211212      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212213      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    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);
     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;
    219218          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220219          // go through every range in xyz and get distance
     
    226225                distance = checkX.distance(*point);
    227226                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    228                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     227                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
    229228              }
    230229        }
    231230      }
    232       Free(&FullMatrix);
    233       Free(&FullInverseMatrix);
     231      delete[](FullMatrix);
     232      delete[](FullInverseMatrix);
    234233    }
    235234
     
    257256    return outmap;
    258257  }
     258  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     259    (*MolWalker)->doCountAtoms();
    259260  outmap = new CorrelationToSurfaceMap;
    260261  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    261262    if ((*MolWalker)->ActiveFlag) {
    262263      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    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);
     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);
    269270          distance = Intersections.GetSmallestDistance();
    270271          triangle = Intersections.GetClosestTriangle();
    271           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    272         }
    273       }
    274     } else
     272          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     273        }
     274      }
     275    } else {
    275276      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
     277    }
    276278
    277279  return outmap;
     
    306308    return outmap;
    307309  }
     310  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     311    (*MolWalker)->doCountAtoms();
    308312  outmap = new CorrelationToSurfaceMap;
    309313  double ShortestDistance = 0.;
     
    314318      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    315319      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    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);
     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;
    322324          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    323325          // go through every range in xyz and get distance
     
    337339              }
    338340          // insert
    339           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
     341          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
    340342          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    341343        }
    342344      }
    343       Free(&FullMatrix);
    344       Free(&FullInverseMatrix);
     345      delete[](FullMatrix);
     346      delete[](FullInverseMatrix);
    345347    }
    346348
Note: See TracChangeset for help on using the changeset viewer.