Changeset c3a303 for molecuilder/src/builder.cpp
- Timestamp:
- Jul 24, 2009, 10:38:32 AM (16 years ago)
- Children:
- 53d153
- Parents:
- a048fa (diff), 47548d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (07/23/09 14:23:32)
- git-committer:
- Frederik Heber <heber@…> (07/24/09 10:38:32)
- File:
-
- 1 edited
-
molecuilder/src/builder.cpp (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/builder.cpp
ra048fa rc3a303 282 282 case 'a': 283 283 cout << Verbose(0) << "Centering atoms in config file on origin." << endl; 284 mol->CenterOrigin((ofstream *)&cout , &x);284 mol->CenterOrigin((ofstream *)&cout); 285 285 break; 286 286 case 'b': 287 287 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl; 288 mol->Center Gravity((ofstream *)&cout, &x);288 mol->CenterPeriodic((ofstream *)&cout); 289 289 break; 290 290 case 'c': … … 295 295 } 296 296 mol->CenterEdge((ofstream *)&cout, &x); // make every coordinate positive 297 mol-> Translate(&y); // translate by boundary297 mol->Center.AddVector(&y); // translate by boundary 298 298 helper.CopyVector(&y); 299 299 helper.Scale(2.); … … 307 307 cin >> x.x[i]; 308 308 } 309 // update Box of atoms by boundary 310 mol->SetBoxDimension(&x); 309 311 // center 310 312 mol->CenterInBox((ofstream *)&cout); 311 // update Box of atoms by boundary312 mol->SetBoxDimension(&x);313 313 break; 314 314 } … … 463 463 cin >> tmp1; 464 464 first = mol->start; 465 while(first->next != mol->end) { 466 first = first->next; 465 second = first->next; 466 while(second != mol->end) { 467 first = second; 468 second = first->next; 467 469 if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ... 468 470 mol->RemoveAtom(first); … … 472 474 cout << Verbose(0) << "Which axis is it: "; 473 475 cin >> axis; 474 cout << Verbose(0) << "L eft inwardboundary: ";476 cout << Verbose(0) << "Lower boundary: "; 475 477 cin >> tmp1; 476 cout << Verbose(0) << " Right inwardboundary: ";478 cout << Verbose(0) << "Upper boundary: "; 477 479 cin >> tmp2; 478 480 first = mol->start; 479 while(first->next != mol->end) { 480 first = first->next; 481 if ((first->x.x[axis] > tmp2) || (first->x.x[axis] < tmp1)) // out of boundary ... 481 second = first->next; 482 while(second != mol->end) { 483 first = second; 484 second = first->next; 485 if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ... 486 //cout << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 482 487 mol->RemoveAtom(first); 488 } 483 489 } 484 490 break; … … 644 650 cout << Verbose(0) << "all else - go back" << endl; 645 651 cout << Verbose(0) << "===============================================" << endl; 646 if (molecules->NumberOfActiveMolecules() > 0)652 if (molecules->NumberOfActiveMolecules() > 1) 647 653 cout << Verbose(0) << "WARNING: There is more than one molecule active! Atoms will be added to each." << endl; 648 654 cout << Verbose(0) << "INPUT: "; … … 655 661 656 662 case 'a': // add atom 657 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 663 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 664 if ((*ListRunner)->ActiveFlag) { 658 665 mol = *ListRunner; 659 666 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 663 670 664 671 case 'b': // scale a bond 665 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 672 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 673 if ((*ListRunner)->ActiveFlag) { 666 674 mol = *ListRunner; 667 675 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 685 693 686 694 case 'c': // unit scaling of the metric 687 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 695 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 696 if ((*ListRunner)->ActiveFlag) { 688 697 mol = *ListRunner; 689 698 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 701 710 702 711 case 'l': // measure distances or angles 703 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 712 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 713 if ((*ListRunner)->ActiveFlag) { 704 714 mol = *ListRunner; 705 715 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 709 719 710 720 case 'r': // remove atom 711 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 721 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 722 if ((*ListRunner)->ActiveFlag) { 712 723 mol = *ListRunner; 713 724 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 717 728 718 729 case 'u': // change an atom's element 719 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 730 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 731 if ((*ListRunner)->ActiveFlag) { 720 732 int Z; 721 733 mol = *ListRunner; … … 761 773 cout << Verbose(0) << "all else - go back" << endl; 762 774 cout << Verbose(0) << "===============================================" << endl; 763 if (molecules->NumberOfActiveMolecules() > 0)775 if (molecules->NumberOfActiveMolecules() > 1) 764 776 cout << Verbose(0) << "WARNING: There is more than one molecule active! Atoms will be added to each." << endl; 765 777 cout << Verbose(0) << "INPUT: "; … … 772 784 773 785 case 'd': // duplicate the periodic cell along a given axis, given times 774 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 786 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 787 if ((*ListRunner)->ActiveFlag) { 775 788 mol = *ListRunner; 776 789 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 830 843 831 844 case 'g': // center the atoms 832 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 845 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 846 if ((*ListRunner)->ActiveFlag) { 833 847 mol = *ListRunner; 834 848 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 838 852 839 853 case 'i': // align all atoms 840 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 854 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 855 if ((*ListRunner)->ActiveFlag) { 841 856 mol = *ListRunner; 842 857 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 846 861 847 862 case 'm': // mirror atoms along a given axis 848 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 863 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 864 if ((*ListRunner)->ActiveFlag) { 849 865 mol = *ListRunner; 850 866 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; … … 854 870 855 871 case 'o': // create the connection matrix 856 { 872 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 873 if ((*ListRunner)->ActiveFlag) { 857 874 double bonddistance; 858 875 clock_t start,end; … … 868 885 869 886 case 't': // translate all atoms 870 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 887 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 888 if ((*ListRunner)->ActiveFlag) { 871 889 mol = *ListRunner; 872 890 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl; 873 891 cout << Verbose(0) << "Enter translation vector." << endl; 874 892 x.AskPosition(mol->cell_size,0); 875 mol-> Translate((const Vector *)&x);893 mol->Center.AddVector((const Vector *)&x); 876 894 } 877 895 break; … … 895 913 { 896 914 char choice; // menu choice char 897 Vector Center;915 Vector center; 898 916 int nr, count; 899 917 molecule *mol = NULL; 900 char filename[MAXSTRINGSIZE]; 901 902 cout << Verbose(0) << "==========Edit MOLECULES=====================" << endl; 918 919 cout << Verbose(0) << "==========EDIT MOLECULES=====================" << endl; 903 920 cout << Verbose(0) << "c - create new molecule" << endl; 904 921 cout << Verbose(0) << "l - load molecule from xyz file" << endl; 905 922 cout << Verbose(0) << "n - change molecule's name" << endl; 906 923 cout << Verbose(0) << "N - give molecules filename" << endl; 907 cout << Verbose(0) << "p - parse xyz file into molecule" << endl;924 cout << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl; 908 925 cout << Verbose(0) << "r - remove a molecule" << endl; 909 926 cout << Verbose(0) << "all else - go back" << endl; … … 921 938 break; 922 939 923 case 'l': // laod from XYZ file 924 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 925 mol = new molecule(periode); 926 do { 927 cout << Verbose(0) << "Enter file name: "; 940 case 'l': // load from XYZ file 941 { 942 char filename[MAXSTRINGSIZE]; 943 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 944 mol = new molecule(periode); 945 do { 946 cout << Verbose(0) << "Enter file name: "; 947 cin >> filename; 948 } while (!mol->AddXYZFile(filename)); 949 mol->SetNameFromFilename(filename); 950 // center at set box dimensions 951 mol->CenterEdge((ofstream *)&cout, ¢er); 952 mol->cell_size[0] = center.x[0]; 953 mol->cell_size[1] = 0; 954 mol->cell_size[2] = center.x[1]; 955 mol->cell_size[3] = 0; 956 mol->cell_size[4] = 0; 957 mol->cell_size[5] = center.x[2]; 958 molecules->insert(mol); 959 } 960 break; 961 962 case 'n': 963 { 964 char filename[MAXSTRINGSIZE]; 965 do { 966 cout << Verbose(0) << "Enter index of molecule: "; 967 cin >> nr; 968 mol = molecules->ReturnIndex(nr); 969 } while (mol == NULL); 970 cout << Verbose(0) << "Enter name: "; 928 971 cin >> filename; 929 } while (!mol->AddXYZFile(filename)); 930 mol->SetNameFromFilename(filename); 931 // center at set box dimensions 932 mol->CenterEdge((ofstream *)&cout, &Center); 933 mol->cell_size[0] = Center.x[0]; 934 mol->cell_size[1] = 0; 935 mol->cell_size[2] = Center.x[1]; 936 mol->cell_size[3] = 0; 937 mol->cell_size[4] = 0; 938 mol->cell_size[5] = Center.x[2]; 939 molecules->insert(mol); 940 break; 941 942 case 'n': 943 do { 944 cout << Verbose(0) << "Enter index of molecule: "; 945 cin >> nr; 946 mol = molecules->ReturnIndex(nr); 947 } while (mol != NULL); 948 cout << Verbose(0) << "Enter name: "; 949 cin >> filename; 950 strcpy(mol->name, filename); 972 strcpy(mol->name, filename); 973 } 951 974 break; 952 975 953 976 case 'N': 954 do { 955 cout << Verbose(0) << "Enter index of molecule: "; 956 cin >> nr; 957 mol = molecules->ReturnIndex(nr); 958 } while (mol != NULL); 959 cout << Verbose(0) << "Enter name: "; 960 cin >> filename; 961 mol->SetNameFromFilename(filename); 977 { 978 char filename[MAXSTRINGSIZE]; 979 do { 980 cout << Verbose(0) << "Enter index of molecule: "; 981 cin >> nr; 982 mol = molecules->ReturnIndex(nr); 983 } while (mol == NULL); 984 cout << Verbose(0) << "Enter name: "; 985 cin >> filename; 986 mol->SetNameFromFilename(filename); 987 } 962 988 break; 963 989 964 990 case 'p': // parse XYZ file 965 mol = NULL; 966 do { 967 cout << Verbose(0) << "Enter index of molecule: "; 968 cin >> nr; 969 mol = molecules->ReturnIndex(nr); 970 } while (mol == NULL); 971 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 972 do { 973 cout << Verbose(0) << "Enter file name: "; 974 cin >> filename; 975 } while (!mol->AddXYZFile(filename)); 976 mol->SetNameFromFilename(filename); 991 { 992 char filename[MAXSTRINGSIZE]; 993 mol = NULL; 994 do { 995 cout << Verbose(0) << "Enter index of molecule: "; 996 cin >> nr; 997 mol = molecules->ReturnIndex(nr); 998 } while (mol == NULL); 999 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 1000 do { 1001 cout << Verbose(0) << "Enter file name: "; 1002 cin >> filename; 1003 } while (!mol->AddXYZFile(filename)); 1004 mol->SetNameFromFilename(filename); 1005 } 977 1006 break; 978 1007 … … 981 1010 cin >> nr; 982 1011 count = 1; 983 MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); 984 for(; ((ListRunner != molecules->ListOfMolecules.end()) && (count < nr)); ListRunner++); 985 mol = *ListRunner; 986 if (count == nr) { 987 molecules->ListOfMolecules.erase(ListRunner); 988 delete(mol); 989 } 1012 for( MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1013 if (nr == (*ListRunner)->IndexNr) { 1014 mol = *ListRunner; 1015 molecules->ListOfMolecules.erase(ListRunner); 1016 delete(mol); 1017 } 990 1018 break; 991 1019 } … … 1002 1030 1003 1031 cout << Verbose(0) << "===========MERGE MOLECULES=====================" << endl; 1032 cout << Verbose(0) << "a - simple add of one molecule to another" << endl; 1004 1033 cout << Verbose(0) << "e - embedding merge of two molecules" << endl; 1005 1034 cout << Verbose(0) << "m - multi-merge of all molecules" << endl; … … 1016 1045 break; 1017 1046 1047 case 'a': 1048 { 1049 int src, dest; 1050 molecule *srcmol = NULL, *destmol = NULL; 1051 { 1052 do { 1053 cout << Verbose(0) << "Enter index of destination molecule: "; 1054 cin >> dest; 1055 destmol = molecules->ReturnIndex(dest); 1056 } while ((destmol == NULL) && (dest != -1)); 1057 do { 1058 cout << Verbose(0) << "Enter index of source molecule to add from: "; 1059 cin >> src; 1060 srcmol = molecules->ReturnIndex(src); 1061 } while ((srcmol == NULL) && (src != -1)); 1062 if ((src != -1) && (dest != -1)) 1063 molecules->SimpleAdd(srcmol, destmol); 1064 } 1065 } 1066 break; 1067 1018 1068 case 'e': 1069 cout << Verbose(0) << "Not implemented yet." << endl; 1019 1070 break; 1020 1071 1021 1072 case 'm': 1073 { 1074 int nr; 1075 molecule *mol = NULL; 1076 do { 1077 cout << Verbose(0) << "Enter index of molecule to merge into: "; 1078 cin >> nr; 1079 mol = molecules->ReturnIndex(nr); 1080 } while ((mol == NULL) && (nr != -1)); 1081 if (nr != -1) { 1082 int N = molecules->ListOfMolecules.size()-1; 1083 int *src = new int(N); 1084 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1085 if ((*ListRunner)->IndexNr != nr) 1086 src[N++] = (*ListRunner)->IndexNr; 1087 molecules->SimpleMultiMerge(mol, src, N); 1088 delete[](src); 1089 } 1090 } 1022 1091 break; 1023 1092 1024 1093 case 's': 1094 cout << Verbose(0) << "Not implemented yet." << endl; 1025 1095 break; 1026 1096 1027 1097 case 't': 1098 { 1099 int src, dest; 1100 molecule *srcmol = NULL, *destmol = NULL; 1101 { 1102 do { 1103 cout << Verbose(0) << "Enter index of destination molecule: "; 1104 cin >> dest; 1105 destmol = molecules->ReturnIndex(dest); 1106 } while ((destmol == NULL) && (dest != -1)); 1107 do { 1108 cout << Verbose(0) << "Enter index of source molecule to merge into: "; 1109 cin >> src; 1110 srcmol = molecules->ReturnIndex(src); 1111 } while ((srcmol == NULL) && (src != -1)); 1112 if ((src != -1) && (dest != -1)) 1113 molecules->SimpleMerge(srcmol, destmol); 1114 } 1115 } 1028 1116 break; 1029 1117 } … … 1125 1213 molecule *mol = new molecule(periode); 1126 1214 1127 // merge all molecules in MoleculeListClass into this molecule1215 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1128 1216 int N = molecules->ListOfMolecules.size(); 1129 1217 int *src = new int(N); 1130 1218 N=0; 1131 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1219 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1132 1220 src[N++] = (*ListRunner)->IndexNr; 1221 (*ListRunner)->Translate(&(*ListRunner)->Center); 1222 } 1133 1223 molecules->SimpleMultiAdd(mol, src, N); 1224 delete[](src); 1225 // ... and translate back 1226 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1227 (*ListRunner)->Center.Scale(-1.); 1228 (*ListRunner)->Translate(&(*ListRunner)->Center); 1229 (*ListRunner)->Center.Scale(-1.); 1230 } 1134 1231 1135 1232 cout << Verbose(0) << "Storing configuration ... " << endl; … … 1137 1234 mol->CalculateOrbitals(*configuration); 1138 1235 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble; 1139 strcpy(filename, ConfigFileName);1140 1236 if (ConfigFileName != NULL) { // test the file name 1141 output.open(ConfigFileName, ios::trunc); 1237 strcpy(filename, ConfigFileName); 1238 output.open(filename, ios::trunc); 1142 1239 } else if (strlen(configuration->configname) != 0) { 1143 1240 strcpy(filename, configuration->configname); … … 1227 1324 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place 1228 1325 molecule *mol = new molecule(periode); 1326 mol->ActiveFlag = true; 1229 1327 molecules->insert(mol); 1230 1328 … … 1257 1355 cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl; 1258 1356 cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl; 1259 cout << "\t-N \tGet non-convex-envelope." << endl;1357 cout << "\t-N <radius> <file>\tGet non-convex-envelope." << endl; 1260 1358 cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl; 1261 1359 cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl; 1262 1360 cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl; 1361 cout << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl; 1263 1362 cout << "\t-r\t\tConvert file from an old pcp syntax." << endl; 1363 cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl; 1264 1364 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl; 1265 1365 cout << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl; … … 1504 1604 } 1505 1605 break; 1606 case 'L': 1607 ExitFlag = 1; 1608 SaveFlag = true; 1609 cout << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl; 1610 if (!mol->LinearInterpolationBetweenConfiguration((ofstream *)&cout, atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration)) 1611 cout << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl; 1612 else 1613 cout << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl; 1614 argptr+=3; 1615 break; 1506 1616 case 'P': 1507 1617 ExitFlag = 1; … … 1512 1622 SaveFlag = true; 1513 1623 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl; 1514 if (!mol->VerletForceIntegration( argv[argptr], configuration.Deltat, configuration.GetIsAngstroem()))1624 if (!mol->VerletForceIntegration((ofstream *)&cout, argv[argptr], configuration)) 1515 1625 cout << Verbose(2) << "File not found." << endl; 1516 1626 else 1517 1627 cout << Verbose(2) << "File found and parsed." << endl; 1518 1628 argptr+=1; 1629 } 1630 break; 1631 case 'R': 1632 ExitFlag = 1; 1633 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 1634 ExitFlag = 255; 1635 cerr << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl; 1636 } else { 1637 SaveFlag = true; 1638 cout << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl; 1639 double tmp1 = atof(argv[argptr+1]); 1640 atom *third = mol->FindAtom(atoi(argv[argptr])); 1641 atom *first = mol->start; 1642 if ((third != NULL) && (first != mol->end)) { 1643 atom *second = first->next; 1644 while(second != mol->end) { 1645 first = second; 1646 second = first->next; 1647 if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ... 1648 mol->RemoveAtom(first); 1649 } 1650 } else { 1651 cerr << "Removal failed due to missing atoms on molecule or wrong id." << endl; 1652 } 1653 argptr+=2; 1519 1654 } 1520 1655 break; … … 1533 1668 argptr+=3; 1534 1669 } 1535 break;1536 1670 case 'T': 1537 1671 ExitFlag = 1; … … 1583 1717 } else { 1584 1718 SaveFlag = true; 1719 j = -1; 1585 1720 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 1586 1721 for (int i=0;i<6;i++) { … … 1609 1744 for (int i=0;i<NDIM;i++) { 1610 1745 j += i+1; 1611 x.x[i] = atof(argv[argptr+ +]);1746 x.x[i] = atof(argv[argptr+i]); 1612 1747 mol->cell_size[j] += x.x[i]*2.; 1613 1748 } … … 1619 1754 ExitFlag = 1; 1620 1755 SaveFlag = true; 1621 cout << Verbose(1) << "Centering atoms in origin." << endl; 1622 mol->CenterOrigin((ofstream *)&cout, &x); 1756 cout << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl; 1757 x.Zero(); 1758 mol->CenterEdge((ofstream *)&cout, &x); 1623 1759 mol->SetBoxDimension(&x); 1624 1760 argptr+=0; … … 1802 1938 string line; 1803 1939 char *ConfigFileName = NULL; 1804 int j , count;1940 int j; 1805 1941 1806 1942 // =========================== PARSE COMMAND LINE OPTIONS ==================================== … … 1844 1980 cout << Verbose(0) << "============Menu===============================" << endl; 1845 1981 cout << Verbose(0) << "a - set molecule (in)active" << endl; 1846 cout << Verbose(0) << "e - edit new molecules" << endl;1982 cout << Verbose(0) << "e - edit molecules (load, parse, save)" << endl; 1847 1983 cout << Verbose(0) << "g - globally manipulate atoms in molecule" << endl; 1848 1984 cout << Verbose(0) << "M - Merge molecules" << endl; … … 1863 1999 cout << "Enter index of molecule: "; 1864 2000 cin >> j; 1865 count = 1; 1866 MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); 1867 for(; ((ListRunner != molecules->ListOfMolecules.end()) && (count < j)); ListRunner++); 1868 if (count == j) 1869 (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag; 2001 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 2002 if ((*ListRunner)->IndexNr == j) 2003 (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag; 1870 2004 } 1871 2005 break;
Note:
See TracChangeset
for help on using the changeset viewer.
