- Timestamp:
- Oct 16, 2008, 9:27:17 AM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- f00693
- Parents:
- 52f5d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
r52f5d5 ra8b9d61 840 840 break; 841 841 case 'e': 842 cout << "Using " << argv[argptr] << " as elements database." << endl; 843 PathToDatabases = argv[argptr]; 844 argptr+=1; 842 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 843 cerr << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl; 844 } else { 845 cout << "Using " << argv[argptr] << " as elements database." << endl; 846 PathToDatabases = argv[argptr]; 847 argptr+=1; 848 } 845 849 break; 846 850 case 'n': … … 914 918 case 'p': 915 919 ExitFlag = 1; 916 SaveFlag = true; 917 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl; 918 if (!mol->AddXYZFile(argv[argptr])) 919 cout << Verbose(2) << "File not found." << endl; 920 else { 921 cout << Verbose(2) << "File found and parsed." << endl; 922 config_present = present; 920 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 921 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl; 922 } else { 923 SaveFlag = true; 924 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl; 925 if (!mol->AddXYZFile(argv[argptr])) 926 cout << Verbose(2) << "File not found." << endl; 927 else { 928 cout << Verbose(2) << "File found and parsed." << endl; 929 config_present = present; 930 } 923 931 } 924 932 break; 925 933 case 'a': 926 934 ExitFlag = 1; 927 SaveFlag = true; 928 cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), "; 929 first = new atom; 930 first->type = periode->FindElement(atoi(argv[argptr])); 931 if (first->type != NULL) 932 cout << Verbose(2) << "found element " << first->type->name << endl; 933 for (int i=NDIM;i--;) 934 first->x.x[i] = atof(argv[argptr+1+i]); 935 if (first->type != NULL) { 936 mol->AddAtom(first); // add to molecule 937 if ((config_present == empty) && (mol->AtomCount != 0)) 938 config_present = present; 939 } else 940 cerr << Verbose(1) << "Could not find the specified element." << endl; 941 argptr+=4; 935 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) { 936 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl; 937 } else { 938 SaveFlag = true; 939 cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), "; 940 first = new atom; 941 first->type = periode->FindElement(atoi(argv[argptr])); 942 if (first->type != NULL) 943 cout << Verbose(2) << "found element " << first->type->name << endl; 944 for (int i=NDIM;i--;) 945 first->x.x[i] = atof(argv[argptr+1+i]); 946 if (first->type != NULL) { 947 mol->AddAtom(first); // add to molecule 948 if ((config_present == empty) && (mol->AtomCount != 0)) 949 config_present = present; 950 } else 951 cerr << Verbose(1) << "Could not find the specified element." << endl; 952 argptr+=4; 953 } 942 954 break; 943 955 default: // no match? Don't step on (this is done in next switch's default) … … 978 990 delete[](MinimumRingSize); 979 991 } 980 argptr+=1;992 //argptr+=1; 981 993 break; 982 994 case 'E': 983 995 ExitFlag = 1; 984 SaveFlag = true; 985 cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl; 986 first = mol->FindAtom(atoi(argv[argptr])); 987 first->type = periode->FindElement(atoi(argv[argptr+1])); 988 argptr+=2; 996 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) { 997 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl; 998 } else { 999 SaveFlag = true; 1000 cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl; 1001 first = mol->FindAtom(atoi(argv[argptr])); 1002 first->type = periode->FindElement(atoi(argv[argptr+1])); 1003 argptr+=2; 1004 } 989 1005 break; 990 1006 case 'T': 991 1007 ExitFlag = 1; 992 { 1008 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1009 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl; 1010 } else { 993 1011 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl; 994 1012 ofstream *output = new ofstream(argv[argptr], ios::trunc); … … 999 1017 output->close(); 1000 1018 delete(output); 1019 argptr+=1; 1001 1020 } 1002 argptr+=1;1003 1021 break; 1004 1022 case 'P': 1005 1023 ExitFlag = 1; 1006 SaveFlag = true; 1007 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl; 1008 if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem())) 1009 cout << Verbose(2) << "File not found." << endl; 1010 else 1011 cout << Verbose(2) << "File found and parsed." << endl; 1012 argptr+=1; 1024 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1025 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl; 1026 } else { 1027 SaveFlag = true; 1028 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl; 1029 if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem())) 1030 cout << Verbose(2) << "File not found." << endl; 1031 else 1032 cout << Verbose(2) << "File found and parsed." << endl; 1033 argptr+=1; 1034 } 1013 1035 break; 1014 1036 case 't': 1015 1037 ExitFlag = 1; 1016 SaveFlag = true; 1017 cout << Verbose(1) << "Translating all ions to new origin." << endl; 1018 for (int i=NDIM;i--;) 1019 x.x[i] = atof(argv[argptr+i]); 1020 mol->Translate((const Vector *)&x); 1021 argptr+=3; 1038 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1039 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl; 1040 } else { 1041 ExitFlag = 1; 1042 SaveFlag = true; 1043 cout << Verbose(1) << "Translating all ions to new origin." << endl; 1044 for (int i=NDIM;i--;) 1045 x.x[i] = atof(argv[argptr+i]); 1046 mol->Translate((const Vector *)&x); 1047 argptr+=3; 1048 } 1022 1049 break; 1023 1050 case 's': 1024 1051 ExitFlag = 1; 1025 SaveFlag = true; 1026 j = -1; 1027 cout << Verbose(1) << "Scaling all ion positions by factor." << endl; 1028 factor = new double[NDIM]; 1029 factor[0] = atof(argv[argptr]); 1030 if (argc > argptr+1) 1031 argptr++; 1032 factor[1] = atof(argv[argptr]); 1033 if (argc > argptr+1) 1034 argptr++; 1035 factor[2] = atof(argv[argptr]); 1036 mol->Scale(&factor); 1037 for (int i=0;i<NDIM;i++) { 1038 j += i+1; 1039 x.x[i] = atof(argv[NDIM+i]); 1040 mol->cell_size[j]*=factor[i]; 1052 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) { 1053 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl; 1054 } else { 1055 SaveFlag = true; 1056 j = -1; 1057 cout << Verbose(1) << "Scaling all ion positions by factor." << endl; 1058 factor = new double[NDIM]; 1059 factor[0] = atof(argv[argptr]); 1060 if ((argptr < argc) && (IsValidNumber(argv[argptr]))) 1061 argptr++; 1062 factor[1] = atof(argv[argptr]); 1063 if ((argptr < argc) && (IsValidNumber(argv[argptr]))) 1064 argptr++; 1065 factor[2] = atof(argv[argptr]); 1066 mol->Scale(&factor); 1067 for (int i=0;i<NDIM;i++) { 1068 j += i+1; 1069 x.x[i] = atof(argv[NDIM+i]); 1070 mol->cell_size[j]*=factor[i]; 1071 } 1072 delete[](factor); 1073 argptr+=1; 1041 1074 } 1042 delete[](factor);1043 argptr+=1;1044 1075 break; 1045 1076 case 'b': 1046 1077 ExitFlag = 1; 1047 SaveFlag = true; 1048 j = -1; 1049 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 1050 j=-1; 1051 for (int i=0;i<NDIM;i++) { 1052 j += i+1; 1053 x.x[i] = atof(argv[argptr++]); 1054 mol->cell_size[j] += x.x[i]*2.; 1078 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1079 cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl; 1080 } else { 1081 SaveFlag = true; 1082 j = -1; 1083 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 1084 j=-1; 1085 for (int i=0;i<NDIM;i++) { 1086 j += i+1; 1087 x.x[i] = atof(argv[argptr++]); 1088 mol->cell_size[j] += x.x[i]*2.; 1089 } 1090 // center 1091 mol->CenterInBox((ofstream *)&cout, &x); 1092 // update Box of atoms by boundary 1093 mol->SetBoxDimension(&x); 1055 1094 } 1056 // center1057 mol->CenterInBox((ofstream *)&cout, &x);1058 // update Box of atoms by boundary1059 mol->SetBoxDimension(&x);1060 1095 break; 1061 1096 case 'c': 1062 1097 ExitFlag = 1; 1063 SaveFlag = true; 1064 j = -1; 1065 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl; 1066 // make every coordinate positive 1067 mol->CenterEdge((ofstream *)&cout, &x); 1068 // update Box of atoms by boundary 1069 mol->SetBoxDimension(&x); 1070 // translate each coordinate by boundary 1071 j=-1; 1072 for (int i=0;i<NDIM;i++) { 1073 j += i+1; 1074 x.x[i] = atof(argv[argptr++]); 1075 mol->cell_size[j] += x.x[i]*2.; 1098 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1099 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl; 1100 } else { 1101 SaveFlag = true; 1102 j = -1; 1103 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl; 1104 // make every coordinate positive 1105 mol->CenterEdge((ofstream *)&cout, &x); 1106 // update Box of atoms by boundary 1107 mol->SetBoxDimension(&x); 1108 // translate each coordinate by boundary 1109 j=-1; 1110 for (int i=0;i<NDIM;i++) { 1111 j += i+1; 1112 x.x[i] = atof(argv[argptr++]); 1113 mol->cell_size[j] += x.x[i]*2.; 1114 } 1115 mol->Translate((const Vector *)&x); 1076 1116 } 1077 mol->Translate((const Vector *)&x);1078 1117 break; 1079 1118 case 'O': … … 1092 1131 case 'f': 1093 1132 ExitFlag = 1; 1094 cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl; 1095 if (argc >= argptr+2) { 1133 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 1134 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl; 1135 } else { 1136 cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl; 1096 1137 cout << Verbose(0) << "Creating connection matrix..." << endl; 1097 1138 start = clock(); … … 1103 1144 end = clock(); 1104 1145 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; 1105 argptr+=1; 1106 } else { 1107 cerr << "Not enough arguments for fragmentation: -f <max. bond distance> <bond order>" << endl; 1146 argptr+=2; 1108 1147 } 1109 1148 break; … … 1130 1169 case 'U': 1131 1170 ExitFlag = 1; 1132 volume = atof(argv[argptr++]); 1133 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl; 1171 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) { 1172 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl; 1173 volume = -1; // for case 'u': don't print error again 1174 } else { 1175 volume = atof(argv[argptr++]); 1176 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl; 1177 } 1134 1178 case 'u': 1135 1179 ExitFlag = 1; 1136 { 1180 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) { 1181 if (volume != -1) 1182 cerr << "Not enough arguments given for suspension: -u <density>" << endl; 1183 } else { 1137 1184 double density; 1138 1185 SaveFlag = true; … … 1149 1196 // repetition[i] = 1; 1150 1197 // } 1151 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density); 1198 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope 1152 1199 } 1153 1200 break; 1154 1201 case 'd': 1155 1202 ExitFlag = 1; 1156 SaveFlag = true; 1157 for (int axis = 1; axis <= NDIM; axis++) { 1158 int faktor = atoi(argv[argptr++]); 1159 int count; 1160 element ** Elements; 1161 Vector ** vectors; 1162 if (faktor < 1) { 1163 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl; 1164 faktor = 1; 1165 } 1166 mol->CountAtoms((ofstream *)&cout); // recount atoms 1167 if (mol->AtomCount != 0) { // if there is more than none 1168 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1169 Elements = new element *[count]; 1170 vectors = new Vector *[count]; 1171 j = 0; 1172 first = mol->start; 1173 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 1174 first = first->next; 1175 Elements[j] = first->type; 1176 vectors[j] = &first->x; 1177 j++; 1203 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1204 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl; 1205 } else { 1206 SaveFlag = true; 1207 for (int axis = 1; axis <= NDIM; axis++) { 1208 int faktor = atoi(argv[argptr++]); 1209 int count; 1210 element ** Elements; 1211 Vector ** vectors; 1212 if (faktor < 1) { 1213 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl; 1214 faktor = 1; 1178 1215 } 1179 if (count != j) 1180 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl; 1181 x.Zero(); 1182 y.Zero(); 1183 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 1184 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1185 x.AddVector(&y); // per factor one cell width further 1186 for (int k=count;k--;) { // go through every atom of the original cell 1187 first = new atom(); // create a new body 1188 first->x.CopyVector(vectors[k]); // use coordinate of original atom 1189 first->x.AddVector(&x); // translate the coordinates 1190 first->type = Elements[k]; // insert original element 1191 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 1216 mol->CountAtoms((ofstream *)&cout); // recount atoms 1217 if (mol->AtomCount != 0) { // if there is more than none 1218 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1219 Elements = new element *[count]; 1220 vectors = new Vector *[count]; 1221 j = 0; 1222 first = mol->start; 1223 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 1224 first = first->next; 1225 Elements[j] = first->type; 1226 vectors[j] = &first->x; 1227 j++; 1192 1228 } 1229 if (count != j) 1230 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl; 1231 x.Zero(); 1232 y.Zero(); 1233 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 1234 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1235 x.AddVector(&y); // per factor one cell width further 1236 for (int k=count;k--;) { // go through every atom of the original cell 1237 first = new atom(); // create a new body 1238 first->x.CopyVector(vectors[k]); // use coordinate of original atom 1239 first->x.AddVector(&x); // translate the coordinates 1240 first->type = Elements[k]; // insert original element 1241 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 1242 } 1243 } 1244 // free memory 1245 delete[](Elements); 1246 delete[](vectors); 1247 // correct cell size 1248 if (axis < 0) { // if sign was negative, we have to translate everything 1249 x.Zero(); 1250 x.AddVector(&y); 1251 x.Scale(-(faktor-1)); 1252 mol->Translate(&x); 1253 } 1254 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 1193 1255 } 1194 // free memory1195 delete[](Elements);1196 delete[](vectors);1197 // correct cell size1198 if (axis < 0) { // if sign was negative, we have to translate everything1199 x.Zero();1200 x.AddVector(&y);1201 x.Scale(-(faktor-1));1202 mol->Translate(&x);1203 }1204 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;1205 1256 } 1206 1257 }
Note:
See TracChangeset
for help on using the changeset viewer.