Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_geometry.cpp

    r1883f9 r4bb63c  
    4848
    4949  // go through all atoms
    50   BOOST_FOREACH(atom* iter, atoms){
    51     *iter -= *Center;
    52     *iter -= *CenterBox;
    53   }
     50  ActOnAllVectors( &Vector::SubtractVector, *Center);
     51  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
    5452  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    5553
     
    6866  Box &domain = World::getInstance().getDomain();
    6967
    70   // go through all atoms
    7168  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    7269
     
    8683  if (iter != end()) { //list not empty?
    8784    for (int i=NDIM;i--;) {
    88       max->at(i) = (*iter)->at(i);
    89       min->at(i) = (*iter)->at(i);
     85      max->at(i) = (*iter)->x[i];
     86      min->at(i) = (*iter)->x[i];
    9087    }
    9188    for (; iter != end(); ++iter) {// continue with second if present
    9289      //(*iter)->Output(1,1,out);
    9390      for (int i=NDIM;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);
     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);
    9693      }
    9794    }
     
    104101    (*max) += (*min);
    105102    Translate(min);
     103    Center.Zero();
    106104  }
    107105  delete(min);
     
    117115  int Num = 0;
    118116  molecule::const_iterator iter = begin();  // start at first in list
    119   Vector Center;
    120117
    121118  Center.Zero();
     119
    122120  if (iter != end()) {   //list not empty?
    123121    for (; iter != end(); ++iter) {  // continue with second if present
    124122      Num++;
    125       Center += (*iter)->getPosition();
     123      Center += (*iter)->x;
    126124    }
    127125    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
    128126    Translate(&Center);
     127    Center.Zero();
    129128  }
    130129};
     
    144143    for (; iter != end(); ++iter) {  // continue with second if present
    145144      Num++;
    146       (*a) += (*iter)->getPosition();
     145      (*a) += (*iter)->x;
    147146    }
    148147    a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
     
    177176  if (iter != end()) {   //list not empty?
    178177    for (; iter != end(); ++iter) {  // continue with second if present
    179       Num += (*iter)->getType()->mass;
    180       tmp = (*iter)->getType()->mass * (*iter)->getPosition();
     178      Num += (*iter)->type->mass;
     179      tmp = (*iter)->type->mass * (*iter)->x;
    181180      (*a) += tmp;
    182181    }
     
    195194void molecule::CenterPeriodic()
    196195{
    197   Vector NewCenter;
    198   DeterminePeriodicCenter(NewCenter);
    199   // go through all atoms
    200   BOOST_FOREACH(atom* iter, atoms){
    201     *iter -= NewCenter;
    202   }
     196  DeterminePeriodicCenter(Center);
    203197};
    204198
     
    210204void molecule::CenterAtVector(Vector *newcenter)
    211205{
    212   // go through all atoms
    213   BOOST_FOREACH(atom* iter, atoms){
    214     *iter -= *newcenter;
    215   }
     206  Center = *newcenter;
    216207};
    217208
     
    230221    for (int j=0;j<MDSteps;j++)
    231222      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
    232     (*iter)->ScaleAll(*factor);
     223    (*iter)->x.ScaleAll(*factor);
    233224  }
    234225};
     
    242233    for (int j=0;j<MDSteps;j++)
    243234      (*iter)->Trajectory.R.at(j) += (*trans);
    244     *(*iter) += (*trans);
     235    (*iter)->x += (*trans);
    245236  }
    246237};
     
    255246
    256247  // go through all atoms
    257   BOOST_FOREACH(atom* iter, atoms){
    258     *iter += *trans;
    259   }
     248  ActOnAllVectors( &Vector::AddVector, *trans);
    260249  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
    261250
     
    283272  bool flag;
    284273  Vector Testvector, Translationvector;
    285   Vector Center;
    286274
    287275  do {
     
    290278    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    291279#ifdef ADDHYDROGEN
    292       if ((*iter)->getType()->Z != 1) {
     280      if ((*iter)->type->Z != 1) {
    293281#endif
    294         Testvector = inversematrix * (*iter)->getPosition();
     282        Testvector = inversematrix * (*iter)->x;
    295283        Translationvector.Zero();
    296284        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
    297285         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    298286            for (int j=0;j<NDIM;j++) {
    299               tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j);
     287              tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
    300288              if ((fabs(tmp)) > BondDistance) {
    301289                flag = false;
     
    315303        // now also change all hydrogens
    316304        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
    317           if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) {
    318             Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition();
     305          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
     306            Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x;
    319307            Testvector += Translationvector;
    320308            Testvector *= matrix;
     
    329317
    330318  Center.Scale(1./static_cast<double>(getAtomCount()));
    331   CenterAtVector(&Center);
    332319};
    333320
     
    348335  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    349336  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    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));
     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];
    353340    for (int j=0;j<MDSteps;j++) {
    354341      tmp = (*iter)->Trajectory.R.at(j)[0];
     
    367354  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    368355  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    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));
     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];
    372359    for (int j=0;j<MDSteps;j++) {
    373360      tmp = (*iter)->Trajectory.R.at(j)[1];
     
    407394  // go through all atoms
    408395  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
    409     if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type
    410       c = (*iter)->getPosition() - a;
     396    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
     397      c = (*iter)->x - a;
    411398      t = c.ScalarProduct(b);           // get direction parameter
    412399      d = t*b;       // and create vector
Note: See TracChangeset for help on using the changeset viewer.