Changeset f75030 for molecuilder/src/builder.cpp
- Timestamp:
- May 23, 2008, 9:17:19 AM (18 years ago)
- Children:
- 6145aa7
- Parents:
- 6c96f4
- File:
-
- 1 edited
-
molecuilder/src/builder.cpp (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/builder.cpp
r6c96f4 rf75030 59 59 * \param *mol the molecule to add to 60 60 */ 61 void AddAtoms(periodentafel *periode, molecule *mol)61 static void AddAtoms(periodentafel *periode, molecule *mol) 62 62 { 63 63 atom *first, *second, *third, *fourth; … … 113 113 cout << Verbose(0) << "Enter relative coordinates." << endl; 114 114 first->x.AskPosition(mol->cell_size, false); 115 for (int i= 0;i<3;i++) {115 for (int i=NDIM;i--;) { 116 116 first->x.x[i] += second->x.x[i]; 117 117 } … … 227 227 atoms = new (vector*[128]); 228 228 valid = true; 229 for(int i= 0;i<128;i++)229 for(int i=128;i--;) 230 230 atoms[i] = NULL; 231 231 int i=0, j=0; … … 256 256 * \param *mol the molecule with all the atoms 257 257 */ 258 void CenterAtoms(molecule *mol)258 static void CenterAtoms(molecule *mol) 259 259 { 260 260 vector x, y; … … 285 285 case 'c': 286 286 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl; 287 for (int i=0;i< 3;i++) {287 for (int i=0;i<NDIM;i++) { 288 288 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 289 289 cin >> y.x[i]; … … 295 295 case 'd': 296 296 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 297 for (int i=0;i< 3;i++) {297 for (int i=0;i<NDIM;i++) { 298 298 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 299 299 cin >> x.x[i]; … … 311 311 * \param *mol the molecule with all the atoms 312 312 */ 313 void AlignAtoms(periodentafel *periode, molecule *mol)313 static void AlignAtoms(periodentafel *periode, molecule *mol) 314 314 { 315 315 atom *first, *second, *third; … … 359 359 cout << Verbose(0) << "Element is " << param.type->name << endl; 360 360 mol->GetAlignVector(¶m); 361 for (int i= 0;i<3;i++) {361 for (int i=NDIM;i--;) { 362 362 x.x[i] = gsl_vector_get(param.x,i); 363 n.x[i] = gsl_vector_get(param.x,i+ 3);363 n.x[i] = gsl_vector_get(param.x,i+NDIM); 364 364 } 365 365 gsl_vector_free(param.x); … … 379 379 * \param *mol the molecule with all the atoms 380 380 */ 381 void MirrorAtoms(molecule *mol)381 static void MirrorAtoms(molecule *mol) 382 382 { 383 383 atom *first, *second, *third; … … 426 426 * \param *mol the molecule with all the atoms 427 427 */ 428 void RemoveAtoms(molecule *mol)428 static void RemoveAtoms(molecule *mol) 429 429 { 430 430 atom *first, *second; … … 484 484 * \param *mol the molecule with all the atoms 485 485 */ 486 void MeasureAtoms(periodentafel *periode, molecule *mol)486 static void MeasureAtoms(periodentafel *periode, molecule *mol) 487 487 { 488 488 atom *first, *second, *third; … … 507 507 case 'a': 508 508 first = mol->AskAtom("Enter first atom: "); 509 for (int i= 0;i<256;i++)509 for (int i=MAX_ELEMENTS;i--;) 510 510 min[i] = 0.; 511 511 … … 523 523 //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl; 524 524 } 525 for (int i= 0;i<256;i++)525 for (int i=MAX_ELEMENTS;i--;) 526 526 if (min[i] != 0.) cout << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl; 527 527 break; … … 530 530 first = mol->AskAtom("Enter first atom: "); 531 531 second = mol->AskAtom("Enter second atom: "); 532 for (int i= 0;i<NDIM;i++)532 for (int i=NDIM;i--;) 533 533 min[i] = 0.; 534 534 x.CopyVector((const vector *)&first->x); … … 560 560 * \param *configuration configuration structure for the to be written config files of all fragments 561 561 */ 562 void FragmentAtoms(molecule *mol, config *configuration)562 static void FragmentAtoms(molecule *mol, config *configuration) 563 563 { 564 564 int Order1; … … 581 581 /** Is called always as option 'T' in the menu. 582 582 */ 583 void testroutine(molecule *mol)583 static void testroutine(molecule *mol) 584 584 { 585 585 // the current test routine checks the functionality of the KeySet&Graph concept: … … 654 654 * \param *mol pointer to molecule structure with all the atoms and coordinates 655 655 */ 656 void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, molecule *mol)656 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, molecule *mol) 657 657 { 658 658 char filename[MAXSTRINGSIZE]; … … 709 709 * \return exit code (0 - successful, all else - something's wrong) 710 710 */ 711 int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&ElementsFileName)711 static int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&ElementsFileName) 712 712 { 713 713 element *finder; … … 846 846 ExitFlag = 1; 847 847 cout << Verbose(1) << "Translating all ions to new origin." << endl; 848 for (int i= 0;i<3;i++)848 for (int i=NDIM;i--;) 849 849 x.x[i] = atof(argv[argptr+i]); 850 850 mol->Translate((const vector *)&x); … … 855 855 cout << Verbose(1) << "Adding new atom." << endl; 856 856 first = new atom; 857 for (int i= 0;i<3;i++)857 for (int i=NDIM;i--;) 858 858 first->x.x[i] = atof(argv[argptr+1+i]); 859 859 finder = periode->start; … … 872 872 j = -1; 873 873 cout << Verbose(1) << "Scaling all ion positions by factor." << endl; 874 factor = (double *) Malloc(sizeof(double)*NDIM, "main: *factor");874 factor = new double[NDIM]; 875 875 factor[0] = atof(argv[argptr]); 876 876 if (argc > argptr+1) … … 881 881 factor[2] = atof(argv[argptr]); 882 882 mol->Scale(&factor); 883 for (int i=0;i< 3;i++) {883 for (int i=0;i<NDIM;i++) { 884 884 j += i+1; 885 x.x[i] = atof(argv[ 3+i]);885 x.x[i] = atof(argv[NDIM+i]); 886 886 mol->cell_size[j]*=factor[i]; 887 887 } 888 Free((void **)&factor, "main: *factor");888 delete[](factor); 889 889 argptr+=1; 890 890 break; … … 894 894 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 895 895 j=-1; 896 for (int i=0;i< 3;i++) {896 for (int i=0;i<NDIM;i++) { 897 897 j += i+1; 898 898 x.x[i] = atof(argv[argptr++]); … … 914 914 // translate each coordinate by boundary 915 915 j=-1; 916 for (int i=0;i< 3;i++) {916 for (int i=0;i<NDIM;i++) { 917 917 j += i+1; 918 918 x.x[i] = atof(argv[argptr++]); … … 1056 1056 second = mol->AskAtom("Enter second (shifting) atom: "); 1057 1057 min_bond = 0.; 1058 for (int i= 0;i<3;i++)1058 for (int i=NDIM;i--;) 1059 1059 min_bond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]); 1060 1060 min_bond = sqrt(min_bond); … … 1062 1062 cout << Verbose(0) << "Enter new bond length [a.u.]: "; 1063 1063 cin >> bond; 1064 for (int i= 0;i<3;i++) {1064 for (int i=NDIM;i--;) { 1065 1065 second->x.x[i] -= (second->x.x[i]-first->x.x[i])/min_bond*(min_bond-bond); 1066 1066 } … … 1107 1107 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1108 1108 x.AddVector(&y); // per factor one cell width further 1109 for (int k= 0;k<count;k++) { // go through every atom of the original cell1109 for (int k=count;k--;) { // go through every atom of the original cell 1110 1110 first = new atom(); // create a new body 1111 1111 first->x.CopyVector(Vectors[k]); // use coordinate of original atom
Note:
See TracChangeset
for help on using the changeset viewer.
