Changes in src/molecule_geometry.cpp [1883f9:4bb63c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
r1883f9 r4bb63c 48 48 49 49 // 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); 54 52 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 55 53 … … 68 66 Box &domain = World::getInstance().getDomain(); 69 67 70 // go through all atoms71 68 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 72 69 … … 86 83 if (iter != end()) { //list not empty? 87 84 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]; 90 87 } 91 88 for (; iter != end(); ++iter) {// continue with second if present 92 89 //(*iter)->Output(1,1,out); 93 90 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); 96 93 } 97 94 } … … 104 101 (*max) += (*min); 105 102 Translate(min); 103 Center.Zero(); 106 104 } 107 105 delete(min); … … 117 115 int Num = 0; 118 116 molecule::const_iterator iter = begin(); // start at first in list 119 Vector Center;120 117 121 118 Center.Zero(); 119 122 120 if (iter != end()) { //list not empty? 123 121 for (; iter != end(); ++iter) { // continue with second if present 124 122 Num++; 125 Center += (*iter)-> getPosition();123 Center += (*iter)->x; 126 124 } 127 125 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 128 126 Translate(&Center); 127 Center.Zero(); 129 128 } 130 129 }; … … 144 143 for (; iter != end(); ++iter) { // continue with second if present 145 144 Num++; 146 (*a) += (*iter)-> getPosition();145 (*a) += (*iter)->x; 147 146 } 148 147 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) … … 177 176 if (iter != end()) { //list not empty? 178 177 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; 181 180 (*a) += tmp; 182 181 } … … 195 194 void molecule::CenterPeriodic() 196 195 { 197 Vector NewCenter; 198 DeterminePeriodicCenter(NewCenter); 199 // go through all atoms 200 BOOST_FOREACH(atom* iter, atoms){ 201 *iter -= NewCenter; 202 } 196 DeterminePeriodicCenter(Center); 203 197 }; 204 198 … … 210 204 void molecule::CenterAtVector(Vector *newcenter) 211 205 { 212 // go through all atoms 213 BOOST_FOREACH(atom* iter, atoms){ 214 *iter -= *newcenter; 215 } 206 Center = *newcenter; 216 207 }; 217 208 … … 230 221 for (int j=0;j<MDSteps;j++) 231 222 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 232 (*iter)-> ScaleAll(*factor);223 (*iter)->x.ScaleAll(*factor); 233 224 } 234 225 }; … … 242 233 for (int j=0;j<MDSteps;j++) 243 234 (*iter)->Trajectory.R.at(j) += (*trans); 244 *(*iter)+= (*trans);235 (*iter)->x += (*trans); 245 236 } 246 237 }; … … 255 246 256 247 // go through all atoms 257 BOOST_FOREACH(atom* iter, atoms){ 258 *iter += *trans; 259 } 248 ActOnAllVectors( &Vector::AddVector, *trans); 260 249 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 261 250 … … 283 272 bool flag; 284 273 Vector Testvector, Translationvector; 285 Vector Center;286 274 287 275 do { … … 290 278 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 291 279 #ifdef ADDHYDROGEN 292 if ((*iter)-> getType()->Z != 1) {280 if ((*iter)->type->Z != 1) { 293 281 #endif 294 Testvector = inversematrix * (*iter)-> getPosition();282 Testvector = inversematrix * (*iter)->x; 295 283 Translationvector.Zero(); 296 284 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 297 285 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 298 286 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]; 300 288 if ((fabs(tmp)) > BondDistance) { 301 289 flag = false; … … 315 303 // now also change all hydrogens 316 304 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; 319 307 Testvector += Translationvector; 320 308 Testvector *= matrix; … … 329 317 330 318 Center.Scale(1./static_cast<double>(getAtomCount())); 331 CenterAtVector(&Center);332 319 }; 333 320 … … 348 335 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 349 336 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]; 353 340 for (int j=0;j<MDSteps;j++) { 354 341 tmp = (*iter)->Trajectory.R.at(j)[0]; … … 367 354 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 368 355 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]; 372 359 for (int j=0;j<MDSteps;j++) { 373 360 tmp = (*iter)->Trajectory.R.at(j)[1]; … … 407 394 // go through all atoms 408 395 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 409 if ((*iter)-> getType()== ((struct lsq_params *)params)->type) { // for specific type410 c = (*iter)-> getPosition()- a;396 if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type 397 c = (*iter)->x - a; 411 398 t = c.ScalarProduct(b); // get direction parameter 412 399 d = t*b; // and create vector
Note:
See TracChangeset
for help on using the changeset viewer.