Changeset c95b69 for molecuilder


Ignore:
Timestamp:
Jul 10, 2009, 9:19:23 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
a048fa
Parents:
88b936
Message:

BUGFIX: Due to stupid mistake, first atom was overlooked in periodic translation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecules.cpp

    r88b936 rc95b69  
    853853  // go through all atoms
    854854  ptr = start->next;  // start at first in list
    855   if (ptr != end) {  //list not empty?
    856     while (ptr->next != end) {  // continue with second if present
    857       ptr = ptr->next;
    858       //ptr->Output(1,1,out);
    859       // multiply its vector with matrix inverse
    860       x.CopyVector(&ptr->x);
     855  while (ptr != end) {  // continue with second if present
     856    //ptr->Output(1,1,out);
     857    // multiply its vector with matrix inverse
     858    x.CopyVector(&ptr->x);
     859    x.Translate(trans);
     860    x.MatrixMultiplication(Minv);
     861    // truncate to [0,1] for each axis
     862    for (int i=0;i<NDIM;i++) {
     863      value = floor(fabs(x.x[i]));  // next lower integer
     864      if (x.x[i] >=0) {
     865        x.x[i] -= value;
     866      } else {
     867        x.x[i] += value+1;
     868      }
     869    }
     870    // matrix multiply
     871    x.MatrixMultiplication(M);
     872    ptr->x.CopyVector(&x);
     873    for (int j=0;j<MDSteps;j++) {
     874      x.CopyVector(&Trajectories[ptr].R.at(j));
    861875      x.Translate(trans);
    862876      x.MatrixMultiplication(Minv);
    863877      // truncate to [0,1] for each axis
    864878      for (int i=0;i<NDIM;i++) {
    865         value = floor(fabs(x.x[i]));  // next lower integer
     879        value = floor(x.x[i]);  // next lower integer
    866880        if (x.x[i] >=0) {
    867881          x.x[i] -= value;
     
    872886      // matrix multiply
    873887      x.MatrixMultiplication(M);
    874       ptr->x.CopyVector(&x);
    875       for (int j=0;j<MDSteps;j++) {
    876         x.CopyVector(&Trajectories[ptr].R.at(j));
    877         x.Translate(trans);
    878         x.MatrixMultiplication(Minv);
    879         // truncate to [0,1] for each axis
    880         for (int i=0;i<NDIM;i++) {
    881           value = floor(x.x[i]);  // next lower integer
    882           if (x.x[i] >=0) {
    883             x.x[i] -= value;
    884           } else {
    885             x.x[i] += value+1;
    886           }
    887         }
    888         // matrix multiply
    889         x.MatrixMultiplication(M);
    890         Trajectories[ptr].R.at(j).CopyVector(&x);
    891       }
     888      Trajectories[ptr].R.at(j).CopyVector(&x);
    892889    }
     890    ptr = ptr->next;
    893891  }
    894892  delete(M);
Note: See TracChangeset for help on using the changeset viewer.