Changes in src/molecule_geometry.cpp [4bb63c:83f176]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
r4bb63c r83f176 1 /* 2 * Project: MoleCuilder 3 * Description: creates and alters molecular systems 4 * Copyright (C) 2010 University of Bonn. All rights reserved. 5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. 6 */ 7 1 8 /* 2 9 * molecule_geometry.cpp … … 6 13 */ 7 14 15 // include config.h 8 16 #ifdef HAVE_CONFIG_H 9 17 #include <config.h> 10 18 #endif 11 19 20 #include "Helpers/MemDebug.hpp" 21 12 22 #include "Helpers/helpers.hpp" 13 23 #include "Helpers/Log.hpp" 14 #include "Helpers/MemDebug.hpp"15 24 #include "Helpers/Verbose.hpp" 16 25 #include "LinearAlgebra/Line.hpp" … … 48 57 49 58 // go through all atoms 50 ActOnAllVectors( &Vector::SubtractVector, *Center); 51 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 59 BOOST_FOREACH(atom* iter, atoms){ 60 *iter -= *Center; 61 *iter -= *CenterBox; 62 } 52 63 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 53 64 … … 66 77 Box &domain = World::getInstance().getDomain(); 67 78 79 // go through all atoms 68 80 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 69 81 … … 83 95 if (iter != end()) { //list not empty? 84 96 for (int i=NDIM;i--;) { 85 max->at(i) = (*iter)-> x[i];86 min->at(i) = (*iter)-> x[i];97 max->at(i) = (*iter)->at(i); 98 min->at(i) = (*iter)->at(i); 87 99 } 88 100 for (; iter != end(); ++iter) {// continue with second if present 89 101 //(*iter)->Output(1,1,out); 90 102 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);103 max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i); 104 min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i); 93 105 } 94 106 } … … 101 113 (*max) += (*min); 102 114 Translate(min); 103 Center.Zero();104 115 } 105 116 delete(min); … … 115 126 int Num = 0; 116 127 molecule::const_iterator iter = begin(); // start at first in list 128 Vector Center; 117 129 118 130 Center.Zero(); 119 120 131 if (iter != end()) { //list not empty? 121 132 for (; iter != end(); ++iter) { // continue with second if present 122 133 Num++; 123 Center += (*iter)-> x;134 Center += (*iter)->getPosition(); 124 135 } 125 136 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 126 137 Translate(&Center); 127 Center.Zero();128 138 } 129 139 }; … … 143 153 for (; iter != end(); ++iter) { // continue with second if present 144 154 Num++; 145 (*a) += (*iter)-> x;155 (*a) += (*iter)->getPosition(); 146 156 } 147 157 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) … … 176 186 if (iter != end()) { //list not empty? 177 187 for (; iter != end(); ++iter) { // continue with second if present 178 Num += (*iter)-> type->mass;179 tmp = (*iter)-> type->mass * (*iter)->x;188 Num += (*iter)->getType()->getMass(); 189 tmp = (*iter)->getType()->getMass() * (*iter)->getPosition(); 180 190 (*a) += tmp; 181 191 } … … 194 204 void molecule::CenterPeriodic() 195 205 { 196 DeterminePeriodicCenter(Center); 206 Vector NewCenter; 207 DeterminePeriodicCenter(NewCenter); 208 // go through all atoms 209 BOOST_FOREACH(atom* iter, atoms){ 210 *iter -= NewCenter; 211 } 197 212 }; 198 213 … … 204 219 void molecule::CenterAtVector(Vector *newcenter) 205 220 { 206 Center = *newcenter; 221 // go through all atoms 222 BOOST_FOREACH(atom* iter, atoms){ 223 *iter -= *newcenter; 224 } 207 225 }; 208 226 … … 221 239 for (int j=0;j<MDSteps;j++) 222 240 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 223 (*iter)-> x.ScaleAll(*factor);241 (*iter)->ScaleAll(*factor); 224 242 } 225 243 }; … … 233 251 for (int j=0;j<MDSteps;j++) 234 252 (*iter)->Trajectory.R.at(j) += (*trans); 235 (*iter)->x+= (*trans);253 *(*iter) += (*trans); 236 254 } 237 255 }; … … 246 264 247 265 // go through all atoms 248 ActOnAllVectors( &Vector::AddVector, *trans); 266 BOOST_FOREACH(atom* iter, atoms){ 267 *iter += *trans; 268 } 249 269 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 250 270 … … 272 292 bool flag; 273 293 Vector Testvector, Translationvector; 294 Vector Center; 274 295 275 296 do { … … 278 299 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 279 300 #ifdef ADDHYDROGEN 280 if ((*iter)-> type->Z!= 1) {301 if ((*iter)->getType()->getAtomicNumber() != 1) { 281 302 #endif 282 Testvector = inversematrix * (*iter)-> x;303 Testvector = inversematrix * (*iter)->getPosition(); 283 304 Translationvector.Zero(); 284 305 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 285 306 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 286 307 for (int j=0;j<NDIM;j++) { 287 tmp = (*iter)-> x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];308 tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j); 288 309 if ((fabs(tmp)) > BondDistance) { 289 310 flag = false; … … 303 324 // now also change all hydrogens 304 325 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;326 if ((*Runner)->GetOtherAtom((*iter))->getType()->getAtomicNumber() == 1) { 327 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition(); 307 328 Testvector += Translationvector; 308 329 Testvector *= matrix; … … 317 338 318 339 Center.Scale(1./static_cast<double>(getAtomCount())); 340 CenterAtVector(&Center); 319 341 }; 320 342 … … 335 357 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 336 358 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];359 tmp = (*iter)->at(0); 360 (*iter)->set(0, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 361 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 340 362 for (int j=0;j<MDSteps;j++) { 341 363 tmp = (*iter)->Trajectory.R.at(j)[0]; … … 354 376 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 355 377 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];378 tmp = (*iter)->at(1); 379 (*iter)->set(1, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 380 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 359 381 for (int j=0;j<MDSteps;j++) { 360 382 tmp = (*iter)->Trajectory.R.at(j)[1]; … … 394 416 // go through all atoms 395 417 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 396 if ((*iter)-> type== ((struct lsq_params *)params)->type) { // for specific type397 c = (*iter)-> x- a;418 if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type 419 c = (*iter)->getPosition() - a; 398 420 t = c.ScalarProduct(b); // get direction parameter 399 421 d = t*b; // and create vector
Note:
See TracChangeset
for help on using the changeset viewer.