Changes in src/builder.cpp [fedd5f:14d4d4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
rfedd5f r14d4d4 52 52 #include "helpers.hpp" 53 53 #include "molecules.hpp" 54 #include "boundary.hpp" 54 55 55 56 /********************************************** Submenu routine **************************************/ … … 484 485 * \param *mol the molecule with all the atoms 485 486 */ 486 static void MeasureAtoms(periodentafel *periode, molecule *mol )487 static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration) 487 488 { 488 489 atom *first, *second, *third; … … 496 497 cout << Verbose(0) << " b - calculate bond length between two atoms" << endl; 497 498 cout << Verbose(0) << " c - calculate bond angle" << endl; 499 cout << Verbose(0) << " d - calculate principal axis of the system" << endl; 500 cout << Verbose(0) << " e - calculate volume of the convex envelope" << endl; 498 501 cout << Verbose(0) << "all else - go back" << endl; 499 502 cout << Verbose(0) << "===============================================" << endl; … … 553 556 cout << Verbose(0) << (acos(x.ScalarProduct((const vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl; 554 557 break; 558 case 'd': 559 cout << Verbose(0) << "Evaluating prinicipal axis." << endl; 560 cout << Verbose(0) << "Shall we rotate? [0/1]: "; 561 cin >> Z; 562 if ((Z >=0) && (Z <=1)) 563 mol->PrincipalAxisSystem((ofstream *)&cout, (bool)Z); 564 else 565 mol->PrincipalAxisSystem((ofstream *)&cout, false); 566 break; 567 case 'e': 568 cout << Verbose(0) << "Evaluating volume of the convex envelope."; 569 VolumeOfConvexEnvelope((ofstream *)&cout, configuration, NULL, mol); 570 break; 555 571 } 556 572 }; … … 720 736 int ExitFlag = 0; 721 737 int j; 738 double volume = 0.; 722 739 enum ConfigStatus config_present = absent; 723 740 clock_t start,end; … … 742 759 cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl; 743 760 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; 761 cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl; 744 762 cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl; 745 763 cout << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner and stores config files in same dir as config." << endl; 746 764 cout << "\t-h/-H/-?\tGive this help screen." << endl; 765 cout << "\t-m\tAlign in PAS with greatest EV along z axis." << endl; 766 cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl; 767 cout << "\t-o\tGet volume of the convex envelope (and store to tecplot file)." << endl; 747 768 cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl; 748 769 cout << "\t-r\t\tConvert file from an old pcp syntax." << endl; 749 770 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl; 750 771 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 772 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl; 751 773 cout << "\t-v/-V\t\tGives version information." << endl; 752 774 cout << "Note: config files must not begin with '-' !" << endl; … … 768 790 argptr+=1; 769 791 break; 792 case 'n': 793 cout << "I won't parse trajectories." << endl; 794 configuration.FastParsing = true; 770 795 default: // no match? Step on 771 796 argptr++; … … 780 805 cout << Verbose(0) << "Element list loaded successfully." << endl; 781 806 periode->Output((ofstream *)&cout); 782 } else 807 } else { 783 808 cout << Verbose(0) << "Element list loading failed." << endl; 809 return 1; 810 } 784 811 785 812 // 3. Find config file name and parse if possible … … 945 972 } 946 973 break; 974 case 'm': 975 ExitFlag = 1; 976 j = atoi(argv[argptr++]); 977 if ((j<0) || (j>1)) { 978 cerr << Verbose(1) << "ERROR: Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl; 979 j = 0; 980 } 981 if (j) 982 cout << Verbose(0) << "Converting to prinicipal axis system." << endl; 983 else 984 cout << Verbose(0) << "Evaluating prinicipal axis." << endl; 985 mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j); 986 break; 987 case 'o': 988 ExitFlag = 1; 989 cout << Verbose(0) << "Evaluating volume of the convex envelope."; 990 VolumeOfConvexEnvelope((ofstream *)&cout, &configuration, NULL, mol); 991 break; 992 case 'U': 993 volume = atof(argv[argptr++]); 994 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl; 995 case 'u': 996 { 997 double density; 998 ExitFlag = 1; 999 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."; 1000 density = atof(argv[argptr++]); 1001 if (density < 1.0) { 1002 cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl; 1003 density = 1.3; 1004 } 1005 // for(int i=0;i<NDIM;i++) { 1006 // repetition[i] = atoi(argv[argptr++]); 1007 // if (repetition[i] < 1) 1008 // cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl; 1009 // repetition[i] = 1; 1010 // } 1011 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density); 1012 } 1013 break; 1014 case 'd': 1015 for (int axis = 1; axis <= NDIM; axis++) { 1016 int faktor = atoi(argv[argptr++]); 1017 int count; 1018 element ** Elements; 1019 vector ** Vectors; 1020 if (faktor < 1) { 1021 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl; 1022 faktor = 1; 1023 } 1024 mol->CountAtoms((ofstream *)&cout); // recount atoms 1025 if (mol->AtomCount != 0) { // if there is more than none 1026 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1027 Elements = new element *[count]; 1028 Vectors = new vector *[count]; 1029 j = 0; 1030 first = mol->start; 1031 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 1032 first = first->next; 1033 Elements[j] = first->type; 1034 Vectors[j] = &first->x; 1035 j++; 1036 } 1037 if (count != j) 1038 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl; 1039 x.Zero(); 1040 y.Zero(); 1041 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 1042 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1043 x.AddVector(&y); // per factor one cell width further 1044 for (int k=count;k--;) { // go through every atom of the original cell 1045 first = new atom(); // create a new body 1046 first->x.CopyVector(Vectors[k]); // use coordinate of original atom 1047 first->x.AddVector(&x); // translate the coordinates 1048 first->type = Elements[k]; // insert original element 1049 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 1050 } 1051 } 1052 // free memory 1053 delete[](Elements); 1054 delete[](Vectors); 1055 // correct cell size 1056 if (axis < 0) { // if sign was negative, we have to translate everything 1057 x.Zero(); 1058 x.AddVector(&y); 1059 x.Scale(-(faktor-1)); 1060 mol->Translate(&x); 1061 } 1062 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 1063 } 1064 } 1065 break; 947 1066 default: // no match? Step on 948 argptr++; 1067 if (argv[argptr][0] != '-') // if it started with a '-' we've already made a step! 1068 argptr++; 949 1069 break; 950 1070 } … … 1151 1271 1152 1272 case 'l': // measure distances or angles 1153 MeasureAtoms(periode, mol );1273 MeasureAtoms(periode, mol, &configuration); 1154 1274 break; 1155 1275 … … 1164 1284 mol->CreateAdjacencyList((ofstream *)&cout, tmp1, configuration.GetIsAngstroem()); 1165 1285 //mol->CreateListOfBondsPerAtom((ofstream *)&cout); 1166 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, false,MinimumRingSize);1286 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, MinimumRingSize); 1167 1287 while (Subgraphs->next != NULL) { 1168 1288 Subgraphs = Subgraphs->next; … … 1220 1340 1221 1341 // save element data base 1222 if (periode->StorePeriodentafel( )) //ElementsFileName1342 if (periode->StorePeriodentafel(ElementsFileName)) //ElementsFileName 1223 1343 cout << Verbose(0) << "Saving of elements.db successful." << endl; 1224 1344 else
Note:
See TracChangeset
for help on using the changeset viewer.