Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_geometry.cpp

    r4bb63c r1883f9  
    4848
    4949  // go through all atoms
    50   ActOnAllVectors( &Vector::SubtractVector, *Center);
    51   ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
     50  BOOST_FOREACH(atom* iter, atoms){
     51    *iter -= *Center;
     52    *iter -= *CenterBox;
     53  }
    5254  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    5355
     
    6668  Box &domain = World::getInstance().getDomain();
    6769
     70  // go through all atoms
    6871  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    6972
     
    8386  if (iter != end()) { //list not empty?
    8487    for (int i=NDIM;i--;) {
    85       max->at(i) = (*iter)->x[i];
    86       min->at(i) = (*iter)->x[i];
     88      max->at(i) = (*iter)->at(i);
     89      min->at(i) = (*iter)->at(i);
    8790    }
    8891    for (; iter != end(); ++iter) {// continue with second if present
    8992      //(*iter)->Output(1,1,out);
    9093      for (int i=NDIM;i--;) {
    91         max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i);
    92         min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i);
     94        max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i);
     95        min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i);
    9396      }
    9497    }
     
    101104    (*max) += (*min);
    102105    Translate(min);
    103     Center.Zero();
    104106  }
    105107  delete(min);
     
    115117  int Num = 0;
    116118  molecule::const_iterator iter = begin();  // start at first in list
     119  Vector Center;
    117120
    118121  Center.Zero();
    119 
    120122  if (iter != end()) {   //list not empty?
    121123    for (; iter != end(); ++iter) {  // continue with second if present
    122124      Num++;
    123       Center += (*iter)->x;
     125      Center += (*iter)->getPosition();
    124126    }
    125127    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
    126128    Translate(&Center);
    127     Center.Zero();
    128129  }
    129130};
     
    143144    for (; iter != end(); ++iter) {  // continue with second if present
    144145      Num++;
    145       (*a) += (*iter)->x;
     146      (*a) += (*iter)->getPosition();
    146147    }
    147148    a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
     
    176177  if (iter != end()) {   //list not empty?
    177178    for (; iter != end(); ++iter) {  // continue with second if present
    178       Num += (*iter)->type->mass;
    179       tmp = (*iter)->type->mass * (*iter)->x;
     179      Num += (*iter)->getType()->mass;
     180      tmp = (*iter)->getType()->mass * (*iter)->getPosition();
    180181      (*a) += tmp;
    181182    }
     
    194195void molecule::CenterPeriodic()
    195196{
    196   DeterminePeriodicCenter(Center);
     197  Vector NewCenter;
     198  DeterminePeriodicCenter(NewCenter);
     199  // go through all atoms
     200  BOOST_FOREACH(atom* iter, atoms){
     201    *iter -= NewCenter;
     202  }
    197203};
    198204
     
    204210void molecule::CenterAtVector(Vector *newcenter)
    205211{
    206   Center = *newcenter;
     212  // go through all atoms
     213  BOOST_FOREACH(atom* iter, atoms){
     214    *iter -= *newcenter;
     215  }
    207216};
    208217
     
    221230    for (int j=0;j<MDSteps;j++)
    222231      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
    223     (*iter)->x.ScaleAll(*factor);
     232    (*iter)->ScaleAll(*factor);
    224233  }
    225234};
     
    233242    for (int j=0;j<MDSteps;j++)
    234243      (*iter)->Trajectory.R.at(j) += (*trans);
    235     (*iter)->x += (*trans);
     244    *(*iter) += (*trans);
    236245  }
    237246};
     
    246255
    247256  // go through all atoms
    248   ActOnAllVectors( &Vector::AddVector, *trans);
     257  BOOST_FOREACH(atom* iter, atoms){
     258    *iter += *trans;
     259  }
    249260  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    250261
     
    272283  bool flag;
    273284  Vector Testvector, Translationvector;
     285  Vector Center;
    274286
    275287  do {
     
    278290    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    279291#ifdef ADDHYDROGEN
    280       if ((*iter)->type->Z != 1) {
     292      if ((*iter)->getType()->Z != 1) {
    281293#endif
    282         Testvector = inversematrix * (*iter)->x;
     294        Testvector = inversematrix * (*iter)->getPosition();
    283295        Translationvector.Zero();
    284296        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
    285297         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    286298            for (int j=0;j<NDIM;j++) {
    287               tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
     299              tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j);
    288300              if ((fabs(tmp)) > BondDistance) {
    289301                flag = false;
     
    303315        // now also change all hydrogens
    304316        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
    305           if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
    306             Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x;
     317          if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) {
     318            Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition();
    307319            Testvector += Translationvector;
    308320            Testvector *= matrix;
     
    317329
    318330  Center.Scale(1./static_cast<double>(getAtomCount()));
     331  CenterAtVector(&Center);
    319332};
    320333
     
    335348  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    336349  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    337     tmp = (*iter)->x[0];
    338     (*iter)->x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
    339     (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
     350    tmp = (*iter)->at(0);
     351    (*iter)->set(0,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
     352    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
    340353    for (int j=0;j<MDSteps;j++) {
    341354      tmp = (*iter)->Trajectory.R.at(j)[0];
     
    354367  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    355368  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    356     tmp = (*iter)->x[1];
    357     (*iter)->x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
    358     (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
     369    tmp = (*iter)->at(1);
     370    (*iter)->set(1,  cos(alpha) * tmp + sin(alpha) * (*iter)->at(2));
     371    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
    359372    for (int j=0;j<MDSteps;j++) {
    360373      tmp = (*iter)->Trajectory.R.at(j)[1];
     
    394407  // go through all atoms
    395408  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
    396     if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
    397       c = (*iter)->x - a;
     409    if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type
     410      c = (*iter)->getPosition() - a;
    398411      t = c.ScalarProduct(b);           // get direction parameter
    399412      d = t*b;       // and create vector
Note: See TracChangeset for help on using the changeset viewer.