Changes in src/molecule_geometry.cpp [a67d19:7fd416]
- File:
-
- 1 edited
-
src/molecule_geometry.cpp (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
ra67d19 r7fd416 27 27 bool status = true; 28 28 const Vector *Center = DetermineCenterOfAll(); 29 double * const cell_size = World::get()->cell_size; 29 const Vector *CenterBox = DetermineCenterOfBox(); 30 double * const cell_size = World::getInstance().getDomain(); 30 31 double *M = ReturnFullMatrixforSymmetric(cell_size); 31 32 double *Minv = InverseMatrix(M); 32 33 33 34 // go through all atoms 34 ActOnAllVectors( &Vector::SubtractVector, Center); 35 ActOnAllVectors( &Vector::SubtractVector, *Center); 36 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 35 37 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 36 38 37 Free(&M);38 Free(&Minv);39 delete[](M); 40 delete[](Minv); 39 41 delete(Center); 40 42 return status; … … 48 50 { 49 51 bool status = true; 50 double * const cell_size = World::get ()->cell_size;52 double * const cell_size = World::getInstance().getDomain(); 51 53 double *M = ReturnFullMatrixforSymmetric(cell_size); 52 54 double *Minv = InverseMatrix(M); … … 55 57 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 56 58 57 Free(&M);58 Free(&Minv);59 delete[](M); 60 delete[](Minv); 59 61 return status; 60 62 }; … … 69 71 70 72 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 71 atom *ptr = start->next; // start at first in list72 if ( ptr != end) {//list not empty?73 molecule::const_iterator iter = begin(); // start at first in list 74 if (iter != end()) { //list not empty? 73 75 for (int i=NDIM;i--;) { 74 max->x[i] = ptr->x.x[i]; 75 min->x[i] = ptr->x.x[i]; 76 } 77 while (ptr->next != end) { // continue with second if present 78 ptr = ptr->next; 79 //ptr->Output(1,1,out); 76 max->at(i) = (*iter)->x[i]; 77 min->at(i) = (*iter)->x[i]; 78 } 79 for (; iter != end(); ++iter) {// continue with second if present 80 //(*iter)->Output(1,1,out); 80 81 for (int i=NDIM;i--;) { 81 max-> x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i];82 min-> x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i];82 max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i); 83 min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i); 83 84 } 84 85 } … … 89 90 // Log() << Verbose(0) << endl; 90 91 min->Scale(-1.); 91 max->AddVector(min);92 (*max) += (*min); 92 93 Translate(min); 93 94 Center.Zero(); … … 104 105 { 105 106 int Num = 0; 106 atom *ptr = start; // start at first in list107 molecule::const_iterator iter = begin(); // start at first in list 107 108 108 109 Center.Zero(); 109 110 110 if (ptr->next != end) { //list not empty? 111 while (ptr->next != end) { // continue with second if present 112 ptr = ptr->next; 111 if (iter != end()) { //list not empty? 112 for (; iter != end(); ++iter) { // continue with second if present 113 113 Num++; 114 Center .AddVector(&ptr->x);114 Center += (*iter)->x; 115 115 } 116 116 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 125 125 Vector * molecule::DetermineCenterOfAll() const 126 126 { 127 atom *ptr = start->next; // start at first in list 127 molecule::const_iterator iter = begin(); // start at first in list 128 Vector *a = new Vector(); 129 double Num = 0; 130 131 a->Zero(); 132 133 if (iter != end()) { //list not empty? 134 for (; iter != end(); ++iter) { // continue with second if present 135 Num++; 136 (*a) += (*iter)->x; 137 } 138 a->Scale(1./Num); // divide through total mass (and sign for direction) 139 } 140 return a; 141 }; 142 143 /** Returns vector pointing to center of the domain. 144 * \return pointer to center of the domain 145 */ 146 Vector * molecule::DetermineCenterOfBox() const 147 { 148 Vector *a = new Vector(0.5,0.5,0.5); 149 150 const double *cell_size = World::getInstance().getDomain(); 151 double *M = ReturnFullMatrixforSymmetric(cell_size); 152 a->MatrixMultiplication(M); 153 delete[](M); 154 155 return a; 156 }; 157 158 /** Returns vector pointing to center of gravity. 159 * \param *out output stream for debugging 160 * \return pointer to center of gravity vector 161 */ 162 Vector * molecule::DetermineCenterOfGravity() 163 { 164 molecule::const_iterator iter = begin(); // start at first in list 128 165 Vector *a = new Vector(); 129 166 Vector tmp; … … 132 169 a->Zero(); 133 170 134 if (ptr != end) { //list not empty? 135 while (ptr->next != end) { // continue with second if present 136 ptr = ptr->next; 137 Num += 1.; 138 tmp.CopyVector(&ptr->x); 139 a->AddVector(&tmp); 171 if (iter != end()) { //list not empty? 172 for (; iter != end(); ++iter) { // continue with second if present 173 Num += (*iter)->type->mass; 174 tmp = (*iter)->type->mass * (*iter)->x; 175 (*a) += tmp; 140 176 } 141 177 a->Scale(1./Num); // divide through total mass (and sign for direction) 142 }143 return a;144 };145 146 /** Returns vector pointing to center of gravity.147 * \param *out output stream for debugging148 * \return pointer to center of gravity vector149 */150 Vector * molecule::DetermineCenterOfGravity()151 {152 atom *ptr = start->next; // start at first in list153 Vector *a = new Vector();154 Vector tmp;155 double Num = 0;156 157 a->Zero();158 159 if (ptr != end) { //list not empty?160 while (ptr->next != end) { // continue with second if present161 ptr = ptr->next;162 Num += ptr->type->mass;163 tmp.CopyVector(&ptr->x);164 tmp.Scale(ptr->type->mass); // scale by mass165 a->AddVector(&tmp);166 }167 a->Scale(-1./Num); // divide through total mass (and sign for direction)168 178 } 169 179 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 189 199 void molecule::CenterAtVector(Vector *newcenter) 190 200 { 191 Center .CopyVector(newcenter);201 Center = *newcenter; 192 202 }; 193 203 … … 195 205 /** Scales all atoms by \a *factor. 196 206 * \param *factor pointer to scaling factor 207 * 208 * TODO: Is this realy what is meant, i.e. 209 * x=(x[0]*factor[0],x[1]*factor[1],x[2]*factor[2]) (current impl) 210 * or rather 211 * x=(**factor) * x (as suggested by comment) 197 212 */ 198 213 void molecule::Scale(const double ** const factor) 199 214 { 200 atom *ptr = start; 201 202 while (ptr->next != end) { 203 ptr = ptr->next; 215 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 204 216 for (int j=0;j<MDSteps;j++) 205 ptr->Trajectory.R.at(j).Scale(factor);206 ptr->x.Scale(factor);217 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 218 (*iter)->x.ScaleAll(*factor); 207 219 } 208 220 }; … … 213 225 void molecule::Translate(const Vector *trans) 214 226 { 215 atom *ptr = start; 216 217 while (ptr->next != end) { 218 ptr = ptr->next; 227 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 219 228 for (int j=0;j<MDSteps;j++) 220 ptr->Trajectory.R.at(j).Translate(trans);221 ptr->x.Translate(trans);229 (*iter)->Trajectory.R.at(j) += (*trans); 230 (*iter)->x += (*trans); 222 231 } 223 232 }; … … 229 238 void molecule::TranslatePeriodically(const Vector *trans) 230 239 { 231 double * const cell_size = World::get ()->cell_size;240 double * const cell_size = World::getInstance().getDomain(); 232 241 double *M = ReturnFullMatrixforSymmetric(cell_size); 233 242 double *Minv = InverseMatrix(M); 234 243 235 244 // go through all atoms 236 ActOnAllVectors( &Vector:: SubtractVector,trans);245 ActOnAllVectors( &Vector::AddVector, *trans); 237 246 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 238 247 239 Free(&M);240 Free(&Minv);248 delete[](M); 249 delete[](Minv); 241 250 }; 242 251 … … 247 256 void molecule::Mirror(const Vector *n) 248 257 { 249 ActOnAllVectors( &Vector::Mirror, n );258 ActOnAllVectors( &Vector::Mirror, *n ); 250 259 }; 251 260 … … 255 264 void molecule::DeterminePeriodicCenter(Vector ¢er) 256 265 { 257 atom *Walker = start; 258 double * const cell_size = World::get()->cell_size; 266 double * const cell_size = World::getInstance().getDomain(); 259 267 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 260 double *inversematrix = InverseMatrix( cell_size);268 double *inversematrix = InverseMatrix(matrix); 261 269 double tmp; 262 270 bool flag; … … 266 274 Center.Zero(); 267 275 flag = true; 268 while (Walker->next != end) { 269 Walker = Walker->next; 276 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 270 277 #ifdef ADDHYDROGEN 271 if ( Walker->type->Z != 1) {278 if ((*iter)->type->Z != 1) { 272 279 #endif 273 Testvector .CopyVector(&Walker->x);280 Testvector = (*iter)->x; 274 281 Testvector.MatrixMultiplication(inversematrix); 275 282 Translationvector.Zero(); 276 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {277 if ( Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing283 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 284 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 278 285 for (int j=0;j<NDIM;j++) { 279 tmp = Walker->x.x[j] - (*Runner)->GetOtherAtom(Walker)->x.x[j];286 tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j]; 280 287 if ((fabs(tmp)) > BondDistance) { 281 288 flag = false; 282 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->Name<< " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);289 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl); 283 290 if (tmp > 0) 284 Translationvector .x[j] -= 1.;291 Translationvector[j] -= 1.; 285 292 else 286 Translationvector .x[j] += 1.;293 Translationvector[j] += 1.; 287 294 } 288 295 } 289 296 } 290 Testvector .AddVector(&Translationvector);297 Testvector += Translationvector; 291 298 Testvector.MatrixMultiplication(matrix); 292 Center.AddVector(&Testvector); 293 DoLog(1) && (Log() << Verbose(1) << "vector is: "); 294 Testvector.Output(); 295 DoLog(0) && (Log() << Verbose(0) << endl); 299 Center += Testvector; 300 Log() << Verbose(1) << "vector is: " << Testvector << endl; 296 301 #ifdef ADDHYDROGEN 297 302 // now also change all hydrogens 298 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {299 if ((*Runner)->GetOtherAtom( Walker)->type->Z == 1) {300 Testvector .CopyVector(&(*Runner)->GetOtherAtom(Walker)->x);303 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 304 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 305 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 301 306 Testvector.MatrixMultiplication(inversematrix); 302 Testvector .AddVector(&Translationvector);307 Testvector += Translationvector; 303 308 Testvector.MatrixMultiplication(matrix); 304 Center.AddVector(&Testvector); 305 DoLog(1) && (Log() << Verbose(1) << "Hydrogen vector is: "); 306 Testvector.Output(); 307 DoLog(0) && (Log() << Verbose(0) << endl); 309 Center += Testvector; 310 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; 308 311 } 309 312 } … … 312 315 } 313 316 } while (!flag); 314 Free(&matrix);315 Free(&inversematrix);316 317 Center.Scale(1./ (double)AtomCount);317 delete[](matrix); 318 delete[](inversematrix); 319 320 Center.Scale(1./static_cast<double>(getAtomCount())); 318 321 }; 319 322 … … 325 328 void molecule::PrincipalAxisSystem(bool DoRotate) 326 329 { 327 atom *ptr = start; // start at first in list328 330 double InertiaTensor[NDIM*NDIM]; 329 331 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 336 338 337 339 // sum up inertia tensor 338 while (ptr->next != end) { 339 ptr = ptr->next; 340 Vector x; 341 x.CopyVector(&ptr->x); 340 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 341 Vector x = (*iter)->x; 342 342 //x.SubtractVector(CenterOfGravity); 343 InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);344 InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);345 InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);346 InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);347 InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);348 InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);349 InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);350 InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);351 InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);343 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 344 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 345 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 346 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 347 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 348 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 349 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 350 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 351 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 352 352 } 353 353 // print InertiaTensor for debugging … … 387 387 388 388 // sum up inertia tensor 389 ptr = start; 390 while (ptr->next != end) { 391 ptr = ptr->next; 392 Vector x; 393 x.CopyVector(&ptr->x); 394 //x.SubtractVector(CenterOfGravity); 395 InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]); 396 InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]); 397 InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]); 398 InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]); 399 InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]); 400 InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]); 401 InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]); 402 InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]); 403 InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]); 389 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 390 Vector x = (*iter)->x; 391 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 392 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 393 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 394 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 395 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 396 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 397 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 398 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 399 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 404 400 } 405 401 // print InertiaTensor for debugging … … 425 421 void molecule::Align(Vector *n) 426 422 { 427 atom *ptr = start;428 423 double alpha, tmp; 429 424 Vector z_axis; 430 z_axis .x[0] = 0.;431 z_axis .x[1] = 0.;432 z_axis .x[2] = 1.;425 z_axis[0] = 0.; 426 z_axis[1] = 0.; 427 z_axis[2] = 1.; 433 428 434 429 // rotate on z-x plane 435 430 DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl); 436 alpha = atan(-n-> x[0]/n->x[2]);431 alpha = atan(-n->at(0)/n->at(2)); 437 432 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 438 while (ptr->next != end) { 439 ptr = ptr->next; 440 tmp = ptr->x.x[0]; 441 ptr->x.x[0] = cos(alpha) * tmp + sin(alpha) * ptr->x.x[2]; 442 ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2]; 433 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 434 tmp = (*iter)->x[0]; 435 (*iter)->x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 436 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 443 437 for (int j=0;j<MDSteps;j++) { 444 tmp = ptr->Trajectory.R.at(j).x[0];445 ptr->Trajectory.R.at(j).x[0] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];446 ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];438 tmp = (*iter)->Trajectory.R.at(j)[0]; 439 (*iter)->Trajectory.R.at(j)[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 440 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 447 441 } 448 442 } 449 443 // rotate n vector 450 tmp = n->x[0]; 451 n->x[0] = cos(alpha) * tmp + sin(alpha) * n->x[2]; 452 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 453 DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: "); 454 n->Output(); 455 DoLog(0) && (Log() << Verbose(0) << endl); 444 tmp = n->at(0); 445 n->at(0) = cos(alpha) * tmp + sin(alpha) * n->at(2); 446 n->at(2) = -sin(alpha) * tmp + cos(alpha) * n->at(2); 447 DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: " << n << endl); 456 448 457 449 // rotate on z-y plane 458 ptr = start; 459 alpha = atan(-n->x[1]/n->x[2]); 450 alpha = atan(-n->at(1)/n->at(2)); 460 451 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 461 while (ptr->next != end) { 462 ptr = ptr->next; 463 tmp = ptr->x.x[1]; 464 ptr->x.x[1] = cos(alpha) * tmp + sin(alpha) * ptr->x.x[2]; 465 ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2]; 452 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 453 tmp = (*iter)->x[1]; 454 (*iter)->x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 455 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 466 456 for (int j=0;j<MDSteps;j++) { 467 tmp = ptr->Trajectory.R.at(j).x[1];468 ptr->Trajectory.R.at(j).x[1] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];469 ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];457 tmp = (*iter)->Trajectory.R.at(j)[1]; 458 (*iter)->Trajectory.R.at(j)[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 459 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 470 460 } 471 461 } 472 462 // rotate n vector (for consistency check) 473 tmp = n->x[1]; 474 n->x[1] = cos(alpha) * tmp + sin(alpha) * n->x[2]; 475 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 476 477 DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: "); 478 n->Output(); 479 DoLog(1) && (Log() << Verbose(1) << endl); 463 tmp = n->at(1); 464 n->at(1) = cos(alpha) * tmp + sin(alpha) * n->at(2); 465 n->at(2) = -sin(alpha) * tmp + cos(alpha) * n->at(2); 466 467 468 DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: " << n << endl); 480 469 DoLog(0) && (Log() << Verbose(0) << "End of Aligning all atoms." << endl); 481 470 }; … … 492 481 Vector a,b,c,d; 493 482 struct lsq_params *par = (struct lsq_params *)params; 494 atom *ptr = par->mol->start;495 483 496 484 // initialize vectors 497 a .x[0] = gsl_vector_get(x,0);498 a .x[1] = gsl_vector_get(x,1);499 a .x[2] = gsl_vector_get(x,2);500 b .x[0] = gsl_vector_get(x,3);501 b .x[1] = gsl_vector_get(x,4);502 b .x[2] = gsl_vector_get(x,5);485 a[0] = gsl_vector_get(x,0); 486 a[1] = gsl_vector_get(x,1); 487 a[2] = gsl_vector_get(x,2); 488 b[0] = gsl_vector_get(x,3); 489 b[1] = gsl_vector_get(x,4); 490 b[2] = gsl_vector_get(x,5); 503 491 // go through all atoms 504 while (ptr != par->mol->end) { 505 ptr = ptr->next; 506 if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type 507 c.CopyVector(&ptr->x); // copy vector to temporary one 508 c.SubtractVector(&a); // subtract offset vector 509 t = c.ScalarProduct(&b); // get direction parameter 510 d.CopyVector(&b); // and create vector 511 d.Scale(&t); 512 c.SubtractVector(&d); // ... yielding distance vector 513 res += d.ScalarProduct((const Vector *)&d); // add squared distance 492 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 493 if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type 494 c = (*iter)->x - a; 495 t = c.ScalarProduct(b); // get direction parameter 496 d = t*b; // and create vector 497 c -= d; // ... yielding distance vector 498 res += d.ScalarProduct(d); // add squared distance 514 499 } 515 500 }
Note:
See TracChangeset
for help on using the changeset viewer.
