Changes in / [d250b2:8a3e45]
- Location:
- src
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Makefile.am ¶
rd250b2 r8a3e45 1 SOURCE = atom.cpp bond.cpp b uilder.cpp config.cpp element.cpp helpers.cpp molecules.cpp moleculelist.cpp periodentafel.cpp vector.cpp verbose.cpp2 HEADER = defs.hpp helpers.hpp molecules.hpp stackclass.hpp vector.hpp1 SOURCE = atom.cpp bond.cpp boundary.cpp builder.cpp config.cpp element.cpp helpers.cpp molecules.cpp moleculelist.cpp periodentafel.cpp vector.cpp verbose.cpp 2 HEADER = boundary.hpp defs.hpp helpers.hpp molecules.hpp stackclass.hpp vector.hpp 3 3 4 4 bin_PROGRAMS = molecuilder joiner analyzer -
TabularUnified src/builder.cpp ¶
rd250b2 r8a3e45 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 -
TabularUnified src/config.cpp ¶
rd250b2 r8a3e45 24 24 configname[0]='\0'; 25 25 26 FastParsing = false; 26 27 ProcPEGamma=8; 27 28 ProcPEPsi=1; … … 455 456 string zeile; 456 457 string dummy; 457 element *elementhash[ 128];458 char name[ 128];459 char keyword[ 128];460 int Z, No ;458 element *elementhash[MAX_ELEMENTS]; 459 char name[MAX_ELEMENTS]; 460 char keyword[MAX_ELEMENTS]; 461 int Z, No[MAX_ELEMENTS]; 461 462 int verbose = 0; 462 463 … … 632 633 if (!ParseForParameter(verbose,file,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional)) 633 634 config::StructOpt = 0; 635 // prescan number of ions per type 636 cout << Verbose(0) << "Prescanning ions per type: " << endl; 634 637 for (int i=0; i < config::MaxTypes; i++) { 635 638 sprintf(name,"Ion_Type%i",i+1); 636 ParseForParameter(verbose,file, (const char*)name, 0, 1, 1, int_type, &No , 1, critical);639 ParseForParameter(verbose,file, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical); 637 640 ParseForParameter(verbose,file, name, 0, 2, 1, int_type, &Z, 1, critical); 638 641 elementhash[i] = periode->FindElement(Z); 639 for(int j=0;j<No;j++) { 642 cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 643 } 644 for (int i=0; i < config::MaxTypes; i++) { 645 sprintf(name,"Ion_Type%i",i+1); 646 for(int j=0;j<No[i];j++) { 640 647 int repetition = 1; // which repeated keyword shall be read 641 648 sprintf(keyword,"%s_%i",name, j+1); 642 649 atom *neues = new atom(); 643 650 // then parse for each atom the coordinates as often as present 644 while (ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition, (repetition == 1) ? critical : optional) && 645 ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition, (repetition == 1) ? critical : optional) && 646 ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional)) 647 repetition++; 648 repetition--; 649 //cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl; 651 if (!FastParsing) { 652 while (ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition, (repetition == 1) ? critical : optional) && 653 ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition, (repetition == 1) ? critical : optional) && 654 ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional)) 655 repetition++; 656 repetition--; 657 //cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl; 658 } 650 659 ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical); 651 660 ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical); … … 656 665 if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional)) 657 666 neues->v.x[1] = 0.; 658 if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional))667 if(!ParseForParameter(verbose,file, keyword, (int)FastParsing, 7, 1, double_type, &neues->v.x[2], repetition,optional)) 659 668 neues->v.x[2] = 0.; 660 669 neues->type = elementhash[i]; // find element type -
TabularUnified src/defs.hpp ¶
rd250b2 r8a3e45 43 43 44 44 // various standard filenames 45 #define DEFAULTCONFIG "main_pcp_linux" 46 #define KEYSETFILE "KeySets.dat" 47 #define ADJACENCYFILE "Adjacency.dat" 48 #define TEFACTORSFILE "TE-Factors.dat" 49 #define FORCESFILE "Forces-Factors.dat" 50 #define ORDERATSITEFILE "OrderAtSite.dat" 51 #define ENERGYPERFRAGMENT "EnergyPerFragment" 52 #define FRAGMENTPREFIX "BondFragment" 53 #define STANDARDCONFIG "unknown.conf" 54 #define STANDARDELEMENTSDB "elements.db" 55 #define STANDARDVALENCEDB "valence.db" 56 #define STANDARDORBITALDB "orbitals.db" 57 #define STANDARDHBONDDISTANCEDB "Hbonddistance.db" 58 #define STANDARDHBONDANGLEDB "Hbondangle.db" 45 #define DEFAULTCONFIG "main_pcp_linux" //!< default filename of config file 46 #define CONVEXENVELOPE "ConvexEnvelope.dat" //!< default filename of convex envelope tecplot data file 47 #define KEYSETFILE "KeySets.dat" //!< default filename of BOSSANOVA key sets file 48 #define ADJACENCYFILE "Adjacency.dat" //!< default filename of BOSSANOVA adjacancy file 49 #define TEFACTORSFILE "TE-Factors.dat" //!< default filename of BOSSANOVA total energy factors file 50 #define FORCESFILE "Forces-Factors.dat" //!< default filename of BOSSANOVA force factors file 51 #define ORDERATSITEFILE "OrderAtSite.dat" //!< default filename of BOSSANOVA Bond Order at each atom file 52 #define ENERGYPERFRAGMENT "EnergyPerFragment" //!< default filename of BOSSANOVA Energy contribution Per Fragment file 53 #define FRAGMENTPREFIX "BondFragment" //!< default filename prefix of BOSSANOVA fragment config and directories 54 #define STANDARDCONFIG "unknown.conf" //!< default filename of standard config file 55 #define STANDARDELEMENTSDB "elements.db" //!< default filename of elements data base with masses, Z, VanDerWaals radii, ... 56 #define STANDARDVALENCEDB "valence.db" //!< default filename of valence number per element database 57 #define STANDARDORBITALDB "orbitals.db" //!< default filename of orbitals per element database 58 #define STANDARDHBONDDISTANCEDB "Hbonddistance.db" //!< default filename of typial bond distance to hydrogen database 59 #define STANDARDHBONDANGLEDB "Hbondangle.db" //!< default filename of typial bond angle to hydrogen database 60 61 // some values 62 #define SOLVENTDENSITY_A 0.6022142 63 #define SOLVENTDENSITY_a0 0.089238936 64 59 65 60 66 #define UPDATECOUNT 10 //!< update ten sites per BOSSANOVA interval -
TabularUnified src/helpers.hpp ¶
rd250b2 r8a3e45 118 118 }; 119 119 120 121 122 120 /******************************** Some templates for list management ***********************************/ 123 121 -
TabularUnified src/moleculelist.cpp ¶
rd250b2 r8a3e45 240 240 *out << endl; 241 241 // prepare output of config file 242 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);242 sprintf(FragmentName, "%s/%s%s.conf", PathBackup, FRAGMENTPREFIX, FragmentNumber); 243 243 outputFragment.open(FragmentName, ios::out); 244 strcpy(PathBackup, configuration->configpath);245 sprintf(FragmentName, "%s/%s%s/", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);244 //strcpy(PathBackup, configuration->configpath); 245 sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber); 246 246 247 247 // center on edge … … 251 251 for (int k=0;k<NDIM;k++) { 252 252 j += k+1; 253 BoxDimension.x[k] = 5.;253 BoxDimension.x[k] = 2.5* (configuration->GetIsAngstroem() ? 1. : 1./AtomicLengthToAngstroem); 254 254 ListOfMolecules[i]->cell_size[j] += BoxDimension.x[k]*2.; 255 255 } -
TabularUnified src/molecules.cpp ¶
rd250b2 r8a3e45 179 179 bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane 180 180 atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added 181 int i; // loop variable182 181 double b,l,d,f,g, alpha, factors[NDIM]; // hold temporary values in triple bond case for coordination determination 183 182 vector OrthoVector1, OrthoVector2; // temporary vectors in coordination construction … … 253 252 case 2: 254 253 // determine two other bonds (warning if there are more than two other) plus valence sanity check 255 for (i =0;i<NumBond;i++) {254 for (int i=0;i<NumBond;i++) { 256 255 if (BondList[i] != TopBond) { 257 256 if (FirstBond == NULL) { … … 312 311 FirstOtherAtom->x.Zero(); 313 312 SecondOtherAtom->x.Zero(); 314 for(i =NDIM;i--;) { // rotate by half the bond angle in both directions (InBondVector is bondangle = 0 direction)313 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondVector is bondangle = 0 direction) 315 314 FirstOtherAtom->x.x[i] = InBondVector.x[i] * cos(bondangle) + OrthoVector1.x[i] * (sin(bondangle)); 316 315 SecondOtherAtom->x.x[i] = InBondVector.x[i] * cos(bondangle) + OrthoVector1.x[i] * (-sin(bondangle)); … … 319 318 SecondOtherAtom->x.Scale(&BondRescale); 320 319 //*out << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 321 for(i =NDIM;i--;) { // and make relative to origin atom320 for(int i=NDIM;i--;) { // and make relative to origin atom 322 321 FirstOtherAtom->x.x[i] += TopOrigin->x.x[i]; 323 322 SecondOtherAtom->x.x[i] += TopOrigin->x.x[i]; … … 439 438 int NumberOfAtoms = 0; // atom number in xyz read 440 439 int i, j; // loop variables 441 atom * first= NULL; // pointer to added atom440 atom *Walker = NULL; // pointer to added atom 442 441 char shorthand[3]; // shorthand for atom name 443 442 ifstream xyzfile; // xyz file … … 457 456 458 457 for(i=0;i<NumberOfAtoms;i++){ 459 first= new atom;458 Walker = new atom; 460 459 getline(xyzfile,line,'\n'); 461 460 istringstream *item = new istringstream(line); … … 466 465 *item >> x[1]; 467 466 *item >> x[2]; 468 first->type = elemente->FindElement(shorthand);469 if ( first->type == NULL) {467 Walker->type = elemente->FindElement(shorthand); 468 if (Walker->type == NULL) { 470 469 cerr << "Could not parse the element at line: '" << line << "', setting to H."; 471 first->type = elemente->FindElement(1);470 Walker->type = elemente->FindElement(1); 472 471 } 473 472 for(j=NDIM;j--;) 474 first->x.x[j] = x[j];475 AddAtom( first); // add to molecule473 Walker->x.x[j] = x[j]; 474 AddAtom(Walker); // add to molecule 476 475 delete(item); 477 476 } … … 710 709 }; 711 710 712 /** Centers the center of gravity of the atoms at (0,0,0).711 /** Returns vector pointing to center of gravity. 713 712 * \param *out output stream for debugging 714 * \param *center return vector for translation vector 715 */ 716 void molecule::CenterGravity(ofstream *out, vector *center) 717 { 713 * \return pointer to center of gravity vector 714 */ 715 vector * molecule::DetermineCenterOfGravity(ofstream *out) 716 { 717 atom *ptr = start->next; // start at first in list 718 vector *a = new vector(); 719 vector tmp; 718 720 double Num = 0; 719 atom *ptr = start->next; // start at first in list 720 vector tmp; 721 722 for(int i=NDIM;i--;) // zero center vector 723 center->x[i] = 0.; 724 721 722 a->Zero(); 723 725 724 if (ptr != end) { //list not empty? 726 725 while (ptr->next != end) { // continue with second if present … … 729 728 tmp.CopyVector(&ptr->x); 730 729 tmp.Scale(ptr->type->mass); // scale by mass 731 center->AddVector(&tmp); 732 } 733 center->Scale(-1./Num); // divide through total mass (and sign for direction) 730 a->AddVector(&tmp); 731 } 732 a->Scale(-1./Num); // divide through total mass (and sign for direction) 733 } 734 *out << Verbose(1) << "Resulting center of gravity: "; 735 a->Output(out); 736 *out << endl; 737 return a; 738 }; 739 740 /** Centers the center of gravity of the atoms at (0,0,0). 741 * \param *out output stream for debugging 742 * \param *center return vector for translation vector 743 */ 744 void molecule::CenterGravity(ofstream *out, vector *center) 745 { 746 if (center == NULL) { 747 DetermineCenter(*center); 748 Translate(center); 749 delete(center); 750 } else { 734 751 Translate(center); 735 752 } … … 775 792 }; 776 793 777 /** Determines center of gravity(yet not considering atom masses).778 * \param Center OfGravityreference to return vector779 */ 780 void molecule::DetermineCenter OfGravity(vector &CenterOfGravity)794 /** Determines center of molecule (yet not considering atom masses). 795 * \param Center reference to return vector 796 */ 797 void molecule::DetermineCenter(vector &Center) 781 798 { 782 799 atom *Walker = start; … … 788 805 789 806 do { 790 Center OfGravity.Zero();807 Center.Zero(); 791 808 flag = true; 792 809 while (Walker->next != end) { … … 815 832 TestVector.AddVector(&TranslationVector); 816 833 TestVector.MatrixMultiplication(matrix); 817 Center OfGravity.AddVector(&TestVector);834 Center.AddVector(&TestVector); 818 835 cout << Verbose(1) << "Vector is: "; 819 836 TestVector.Output((ofstream *)&cout); … … 828 845 TestVector.AddVector(&TranslationVector); 829 846 TestVector.MatrixMultiplication(matrix); 830 Center OfGravity.AddVector(&TestVector);847 Center.AddVector(&TestVector); 831 848 cout << Verbose(1) << "Hydrogen Vector is: "; 832 849 TestVector.Output((ofstream *)&cout); … … 838 855 } 839 856 } while (!flag); 840 Free((void **)&matrix, "molecule::DetermineCenterOfGravity: *matrix"); 841 CenterOfGravity.Scale(1./(double)AtomCount); 857 Free((void **)&matrix, "molecule::DetermineCenter: *matrix"); 858 Center.Scale(1./(double)AtomCount); 859 }; 860 861 /** Transforms/Rotates the given molecule into its principal axis system. 862 * \param *out output stream for debugging 863 * \param DoRotate whether to rotate (true) or only to determine the PAS. 864 */ 865 void molecule::PrincipalAxisSystem(ofstream *out, bool DoRotate) 866 { 867 atom *ptr = start; // start at first in list 868 double InertiaTensor[NDIM*NDIM]; 869 vector *CenterOfGravity = DetermineCenterOfGravity(out); 870 871 CenterGravity(out, CenterOfGravity); 872 873 // reset inertia tensor 874 for(int i=0;i<NDIM*NDIM;i++) 875 InertiaTensor[i] = 0.; 876 877 // sum up inertia tensor 878 while (ptr->next != end) { 879 ptr = ptr->next; 880 vector x; 881 x.CopyVector(&ptr->x); 882 //x.SubtractVector(CenterOfGravity); 883 InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]); 884 InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]); 885 InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]); 886 InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]); 887 InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]); 888 InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]); 889 InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]); 890 InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]); 891 InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]); 892 } 893 // print InertiaTensor for debugging 894 *out << "The inertia tensor is:" << endl; 895 for(int i=0;i<NDIM;i++) { 896 for(int j=0;j<NDIM;j++) 897 *out << InertiaTensor[i*NDIM+j] << " "; 898 *out << endl; 899 } 900 *out << endl; 901 902 // diagonalize to determine principal axis system 903 gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM); 904 gsl_matrix_view m = gsl_matrix_view_array(InertiaTensor, NDIM, NDIM); 905 gsl_vector *eval = gsl_vector_alloc(NDIM); 906 gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM); 907 gsl_eigen_symmv(&m.matrix, eval, evec, T); 908 gsl_eigen_symmv_free(T); 909 gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC); 910 911 for(int i=0;i<NDIM;i++) { 912 *out << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i); 913 *out << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl; 914 } 915 916 // check whether we rotate or not 917 if (DoRotate) { 918 *out << Verbose(1) << "Transforming molecule into PAS ... "; 919 // the eigenvectors specify the transformation matrix 920 ptr = start; 921 while (ptr->next != end) { 922 ptr = ptr->next; 923 ptr->x.MatrixMultiplication(evec->data); 924 } 925 *out << "done." << endl; 926 927 // summing anew for debugging (resulting matrix has to be diagonal!) 928 // reset inertia tensor 929 for(int i=0;i<NDIM*NDIM;i++) 930 InertiaTensor[i] = 0.; 931 932 // sum up inertia tensor 933 ptr = start; 934 while (ptr->next != end) { 935 ptr = ptr->next; 936 vector x; 937 x.CopyVector(&ptr->x); 938 //x.SubtractVector(CenterOfGravity); 939 InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]); 940 InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]); 941 InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]); 942 InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]); 943 InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]); 944 InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]); 945 InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]); 946 InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]); 947 InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]); 948 } 949 // print InertiaTensor for debugging 950 *out << "The inertia tensor is:" << endl; 951 for(int i=0;i<NDIM;i++) { 952 for(int j=0;j<NDIM;j++) 953 *out << InertiaTensor[i*NDIM+j] << " "; 954 *out << endl; 955 } 956 *out << endl; 957 } 958 959 // free everything 960 delete(CenterOfGravity); 961 gsl_vector_free(eval); 962 gsl_matrix_free(evec); 842 963 }; 843 964 … … 1234 1355 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 1235 1356 *out << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl; 1236 Subgraphs = DepthFirstSearchAnalysis(out, false,MinimumRingSize);1357 Subgraphs = DepthFirstSearchAnalysis(out, MinimumRingSize); 1237 1358 while (Subgraphs->next != NULL) { 1238 1359 Subgraphs = Subgraphs->next; … … 1249 1370 return No; 1250 1371 }; 1251 1252 1372 /** Returns Shading as a char string. 1253 1373 * \param color the Shading … … 1453 1573 for(j=0;j<NumberOfBondsPerAtom[Walker->nr];j++) 1454 1574 NoBonds += ListOfBondsPerAtom[Walker->nr][j]->BondDegree; 1455 //*out << Verbose(3) << "Walker: " << (int)Walker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;1575 *out << Verbose(3) << "Walker: " << (int)Walker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 1456 1576 if ((int)(Walker->type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check NoBonds of other atom 1457 1577 // count valence of second partner … … 1459 1579 for(j=0;j<NumberOfBondsPerAtom[OtherWalker->nr];j++) 1460 1580 NoBonds += ListOfBondsPerAtom[OtherWalker->nr][j]->BondDegree; 1461 //*out << Verbose(3) << "OtherWalker: " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;1581 *out << Verbose(3) << "OtherWalker: " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 1462 1582 if ((int)(OtherWalker->type->NoValenceOrbitals) > NoBonds) // increase bond degree by one 1463 1583 ListOfBondsPerAtom[Walker->nr][i]->BondDegree++; … … 1471 1591 *out << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << bonddistance << "." << endl; 1472 1592 1473 //// output bonds for debugging (if bond chain list was correctly installed)1474 //*out << Verbose(1) << endl << "From contents of bond chain list:";1475 //bond *Binder = first;1476 //while(Binder->next != last) {1477 //Binder = Binder->next;1478 //*out << *Binder << "\t" << endl;1479 //}1480 //*out << endl;1593 // output bonds for debugging (if bond chain list was correctly installed) 1594 *out << Verbose(1) << endl << "From contents of bond chain list:"; 1595 bond *Binder = first; 1596 while(Binder->next != last) { 1597 Binder = Binder->next; 1598 *out << *Binder << "\t" << endl; 1599 } 1600 *out << endl; 1481 1601 } else 1482 1602 *out << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl; … … 1490 1610 * We use the algorithm from [Even, Graph Algorithms, p.62]. 1491 1611 * \param *out output stream for debugging 1492 * \param ReturnStack true - return pointer to atom stack of separable components, false - return NULL1493 1612 * \param *&MinimumRingSize contains smallest ring size in molecular structure on return or -1 if no rings were found 1494 1613 * \return list of each disconnected subgraph as an individual molecule class structure 1495 1614 */ 1496 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(ofstream *out, bool ReturnStack,int *&MinimumRingSize)1615 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(ofstream *out, int *&MinimumRingSize) 1497 1616 { 1498 1617 class StackClass<atom *> *AtomStack; … … 2006 2125 * \param *path path to file 2007 2126 * \param *FragmentList empty, filled on return 2008 * \param IsAngstroem whether we have Ansgtroem or bohrradius2009 2127 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL) 2010 2128 */ 2011 bool molecule::ParseKeySetFile(ofstream *out, char *path, Graph *&FragmentList , bool IsAngstroem)2129 bool molecule::ParseKeySetFile(ofstream *out, char *path, Graph *&FragmentList) 2012 2130 { 2013 2131 bool status = true; … … 2186 2304 { 2187 2305 ifstream File; 2188 stringstream line;2306 stringstream filename; 2189 2307 bool status = true; 2190 2308 char *buffer = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer"); 2191 2309 2192 line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;2193 File.open( line.str().c_str(), ios::out);2310 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 2311 File.open(filename.str().c_str(), ios::out); 2194 2312 *out << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "; 2195 2313 if (File != NULL) { … … 2493 2611 2494 2612 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== 2495 Subgraphs = DepthFirstSearchAnalysis(out, false,MinimumRingSize);2613 Subgraphs = DepthFirstSearchAnalysis(out, MinimumRingSize); 2496 2614 // fill the bond structure of the individually stored subgraphs 2497 2615 Subgraphs->next->FillBondStructureFromReference(out, this, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 2498 2616 2499 2617 // ===== 3. if structure still valid, parse key set file and others ===== 2500 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, ParsedFragmentList , configuration->GetIsAngstroem());2618 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, ParsedFragmentList); 2501 2619 2502 2620 // ===== 4. check globally whether there's something to do actually (first adaptivity check) … … 3013 3131 // *out << ", who has no son in this fragment molecule." << endl; 3014 3132 #ifdef ADDHYDROGEN 3015 //*out << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;3133 //*out << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl; 3016 3134 Leaf->AddHydrogenReplacementAtom(out, ListOfBondsPerAtom[FatherOfRunner->nr][i], Runner, FatherOfRunner, OtherFather, ListOfBondsPerAtom[FatherOfRunner->nr],NumberOfBondsPerAtom[FatherOfRunner->nr], IsAngstroem); 3017 3135 #endif … … 3421 3539 KeyStack AtomStack; 3422 3540 atom **PredecessorList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::PowerSetGenerator: **PredecessorList"); 3423 KeySet::iterator runner;3424 3541 int RootKeyNr = FragmentSearch.Root->nr; 3425 3542 int Counter = FragmentSearch.FragmentCounter; … … 3816 3933 { 3817 3934 Graph ***FragmentLowerOrdersList = NULL; 3818 int Order,NumLevels, NumMolecules, TotalNumMolecules = 0, *NumMoleculesOfOrder = NULL;3819 int counter = 0 ;3935 int NumLevels, NumMolecules, TotalNumMolecules = 0, *NumMoleculesOfOrder = NULL; 3936 int counter = 0, Order; 3820 3937 int UpgradeCount = RootStack.size(); 3821 3938 KeyStack FragmentRootStack; … … 3831 3948 3832 3949 // initialise the fragments structure 3833 FragmentSearch.BondsPerSPList = (bond **) Malloc(sizeof(bond *)*Order*2, "molecule::PowerSetGenerator: ***BondsPerSPList");3834 FragmentSearch.BondsPerSPCount = (int *) Malloc(sizeof(int)*Order, "molecule::PowerSetGenerator: *BondsPerSPCount");3835 3950 FragmentSearch.ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::PowerSetGenerator: *ShortestPathList"); 3836 3951 FragmentSearch.Labels = (int *) Malloc(sizeof(int)*AtomCount, "molecule::PowerSetGenerator: *Labels"); … … 4059 4174 if (result) { 4060 4175 *out << Verbose(5) << "Calculating Centers of Gravity" << endl; 4061 DetermineCenter OfGravity(CenterOfGravity);4062 OtherMolecule->DetermineCenter OfGravity(OtherCenterOfGravity);4176 DetermineCenter(CenterOfGravity); 4177 OtherMolecule->DetermineCenter(OtherCenterOfGravity); 4063 4178 *out << Verbose(5) << "Center of Gravity: "; 4064 4179 CenterOfGravity.Output(out); -
TabularUnified src/molecules.hpp ¶
rd250b2 r8a3e45 13 13 #include <gsl/gsl_vector.h> 14 14 #include <gsl/gsl_matrix.h> 15 #include <gsl/gsl_eigen.h> 15 16 #include <gsl/gsl_heapsort.h> 16 17 … … 39 40 #define KeySet set<int> 40 41 #define NumberValuePair pair<int, double> 41 #define Graph map <KeySet, NumberValuePair, KeyCompare >42 #define GraphPair pair <KeySet, NumberValuePair >42 #define Graph map <KeySet, NumberValuePair, KeyCompare > 43 #define GraphPair pair <KeySet, NumberValuePair > 43 44 #define KeySetTestPair pair<KeySet::iterator, bool> 44 45 #define GraphTestPair pair<Graph::iterator, bool> … … 265 266 void CenterEdge(ofstream *out, vector *max); 266 267 void CenterOrigin(ofstream *out, vector *max); 267 void CenterGravity(ofstream *out, vector *max); 268 void CenterGravity(ofstream *out, vector *max); 268 269 void Translate(const vector *x); 269 270 void Mirror(const vector *x); 270 271 void Align(vector *n); 271 272 void Scale(double **factor); 272 void DetermineCenterOfGravity(vector &CenterOfGravity); 273 void DetermineCenter(vector ¢er); 274 vector * DetermineCenterOfGravity(ofstream *out); 273 275 void SetBoxDimension(vector *dim); 274 276 double * ReturnFullMatrixforSymmetric(double *cell_size); 275 277 void ScanForPeriodicCorrection(ofstream *out); 276 278 void PrincipalAxisSystem(ofstream *out, bool DoRotate); 279 double VolumeOfConvexEnvelope(ofstream *out, bool IsAngstroem); 280 277 281 bool CheckBounds(const vector *x) const; 278 282 void GetAlignVector(struct lsq_params * par) const; … … 283 287 284 288 // Graph analysis 285 MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, bool ReturnStack,int *&MinimumRingSize);289 MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, int *&MinimumRingSize); 286 290 void CyclicStructureAnalysis(ofstream *out, class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize); 287 291 bond * FindNextUnused(atom *vertex); … … 303 307 bool ParseOrderAtSiteFromFile(ofstream *out, char *path); 304 308 bool StoreOrderAtSiteFile(ofstream *out, char *path); 305 bool ParseKeySetFile(ofstream *out, char *filename, Graph *&FragmentList , bool IsAngstroem);309 bool ParseKeySetFile(ofstream *out, char *filename, Graph *&FragmentList); 306 310 bool StoreKeySetFile(ofstream *out, Graph &KeySetList, char *path); 307 311 bool StoreForcesFile(ofstream *out, MoleculeListClass *BondFragments, char *path, int *SortIndex); … … 392 396 char *configpath; 393 397 char *configname; 398 bool FastParsing; 394 399 395 400 private: -
TabularUnified src/periodentafel.cpp ¶
rd250b2 r8a3e45 217 217 218 218 // fill valence DB per element 219 strncat(filename, path, MAXSTRINGSIZE); 220 strncpy(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename)); 219 strncpy(filename, path, MAXSTRINGSIZE); 220 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 221 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename)); 221 222 infile.open(filename); 222 223 if (infile != NULL) { … … 226 227 infile >> FindElement((int)tmp)->Valence; 227 228 infile >> ws; 228 //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->Valence << " valence electrons." << endl;229 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl; 229 230 } 230 231 infile.close(); … … 234 235 235 236 // fill valence DB per element 236 strncat(filename, path, MAXSTRINGSIZE); 237 strncpy(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 237 strncpy(filename, path, MAXSTRINGSIZE); 238 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 239 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 238 240 infile.open(filename); 239 241 if (infile != NULL) { … … 243 245 infile >> FindElement((int)tmp)->NoValenceOrbitals; 244 246 infile >> ws; 245 //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;247 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 246 248 } 247 249 infile.close(); … … 251 253 252 254 // fill H-BondDistance DB per element 253 strncat(filename, path, MAXSTRINGSIZE); 254 strncpy(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename)); 255 strncpy(filename, path, MAXSTRINGSIZE); 256 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 257 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename)); 255 258 infile.open(filename); 256 259 if (infile != NULL) { … … 263 266 infile >> ptr->HBondDistance[2]; 264 267 infile >> ws; 265 //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;268 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 266 269 } 267 270 infile.close(); … … 271 274 272 275 // fill H-BondAngle DB per element 273 strncat(filename, path, MAXSTRINGSIZE); 274 strncpy(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename)); 276 strncpy(filename, path, MAXSTRINGSIZE); 277 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 278 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename)); 275 279 infile.open(filename); 276 280 if (infile != NULL) { … … 289 293 otherstatus = false; 290 294 295 if (!otherstatus) 296 cerr << "ERROR: Something went wrong while parsing the databases!" << endl; 297 291 298 return status; 292 299 }; … … 298 305 bool result = true; 299 306 ofstream f; 300 301 if (filename == NULL) 302 f.open("elements.db"); 307 char file[MAXSTRINGSIZE]; 308 309 if (filename == STANDARDELEMENTSDB) 310 f.open(file); 303 311 else 304 312 f.open(filename); -
TabularUnified src/vector.cpp ¶
rd250b2 r8a3e45 13 13 */ 14 14 vector::vector() { x[0] = x[1] = x[2] = 0.; }; 15 16 /** Constructor of class vector. 17 */ 18 vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; }; 15 19 16 20 /** Desctructor of class vector. … … 111 115 }; 112 116 117 /** projects this vector onto plane defined by \a *y. 118 * \param *y array to normal vector of plane 119 * \return \f$\langle x, y \rangle\f$ 120 */ 121 void vector::ProjectOntoPlane(const vector *y) 122 { 123 vector tmp; 124 tmp.CopyVector(y); 125 tmp.Scale(Projection(y)); 126 this->SubtractVector(&tmp); 127 }; 128 113 129 /** Calculates the projection of a vector onto another \a *y. 114 130 * \param *y array to second vector … … 117 133 double vector::Projection(const vector *y) const 118 134 { 119 return (ScalarProduct(y) /Norm()/y->Norm());135 return (ScalarProduct(y)); 120 136 }; 121 137 … … 150 166 }; 151 167 168 /** Zeros all components of this vector. 169 */ 170 void vector::One(double one) 171 { 172 for (int i=NDIM;i--;) 173 this->x[i] = one; 174 }; 175 176 /** Initialises all components of this vector. 177 */ 178 void vector::Init(double x1, double x2, double x3) 179 { 180 x[0] = x1; 181 x[1] = x2; 182 x[2] = x3; 183 }; 184 152 185 /** Calculates the angle between this and another vector. 153 186 * \param *y array to second vector 154 * \return \f$\ frac{\langle x, y \rangle}{|x||y|}\f$187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 155 188 */ 156 189 double vector::Angle(vector *y) const 157 190 { 158 return (this->ScalarProduct(y)/(this->Norm()*y->Norm()));191 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); 159 192 }; 160 193 … … 354 387 { 355 388 double projection; 356 projection = ScalarProduct(n)/ ((vector *)n)->ScalarProduct(n); // remove constancy from n (keep as logical one)389 projection = ScalarProduct(n)/n->ScalarProduct(n); // remove constancy from n (keep as logical one) 357 390 // withdraw projected vector twice from original one 358 391 cout << Verbose(1) << "Vector: "; … … 385 418 return false; 386 419 } 387 cout << Verbose(4) << "relative, first plane coordinates:";388 x1.Output((ofstream *)&cout);389 cout << endl;390 cout << Verbose(4) << "second plane coordinates:";391 x2.Output((ofstream *)&cout);392 cout << endl;420 // cout << Verbose(4) << "relative, first plane coordinates:"; 421 // x1.Output((ofstream *)&cout); 422 // cout << endl; 423 // cout << Verbose(4) << "second plane coordinates:"; 424 // x2.Output((ofstream *)&cout); 425 // cout << endl; 393 426 394 427 this->x[0] = (x1.x[1]*x2.x[2] - x1.x[2]*x2.x[1]); … … 419 452 return false; 420 453 } 421 cout << Verbose(4) << "relative, first plane coordinates:";422 x1.Output((ofstream *)&cout);423 cout << endl;424 cout << Verbose(4) << "second plane coordinates:";425 x2.Output((ofstream *)&cout);426 cout << endl;454 // cout << Verbose(4) << "relative, first plane coordinates:"; 455 // x1.Output((ofstream *)&cout); 456 // cout << endl; 457 // cout << Verbose(4) << "second plane coordinates:"; 458 // x2.Output((ofstream *)&cout); 459 // cout << endl; 427 460 428 461 this->x[0] = (x1.x[1]*x2.x[2] - x1.x[2]*x2.x[1]); … … 458 491 * \return true - success, false - failure (null vector given) 459 492 */ 460 bool vector::GetOneNormalVector(const vector * vector)493 bool vector::GetOneNormalVector(const vector *GivenVector) 461 494 { 462 495 int Components[NDIM]; // contains indices of non-zero components … … 466 499 467 500 cout << Verbose(4); 468 vector->Output((ofstream *)&cout);501 GivenVector->Output((ofstream *)&cout); 469 502 cout << endl; 470 503 for (j=NDIM;j--;) … … 472 505 // find two components != 0 473 506 for (j=0;j<NDIM;j++) 474 if (fabs( vector->x[j]) > MYEPSILON)507 if (fabs(GivenVector->x[j]) > MYEPSILON) 475 508 Components[Last++] = j; 476 509 cout << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl; … … 479 512 case 3: // threecomponent system 480 513 case 2: // two component system 481 norm = sqrt(1./( vector->x[Components[1]]*vector->x[Components[1]]) + 1./(vector->x[Components[0]]*vector->x[Components[0]]));514 norm = sqrt(1./(GivenVector->x[Components[1]]*GivenVector->x[Components[1]]) + 1./(GivenVector->x[Components[0]]*GivenVector->x[Components[0]])); 482 515 x[Components[2]] = 0.; 483 516 // in skp both remaining parts shall become zero but with opposite sign and third is zero 484 x[Components[1]] = -1./ vector->x[Components[1]] / norm;485 x[Components[0]] = 1./ vector->x[Components[0]] / norm;517 x[Components[1]] = -1./GivenVector->x[Components[1]] / norm; 518 x[Components[0]] = 1./GivenVector->x[Components[0]] / norm; 486 519 return true; 487 520 break; … … 498 531 }; 499 532 533 /** Determines paramter needed to multiply this vector to obtain intersection point with plane defined by \a *A, \a *B and \a *C. 534 * \param *A first plane vector 535 * \param *B second plane vector 536 * \param *C third plane vector 537 * \return scaling parameter for this vector 538 */ 539 double vector::CutsPlaneAt(vector *A, vector *B, vector *C) 540 { 541 // cout << Verbose(3) << "For comparison: "; 542 // cout << "A " << A->Projection(this) << "\t"; 543 // cout << "B " << B->Projection(this) << "\t"; 544 // cout << "C " << C->Projection(this) << "\t"; 545 // cout << endl; 546 return A->Projection(this); 547 }; 548 500 549 /** Creates a new vector as the one with least square distance to a given set of \a vectors. 501 550 * \param *vectors set of vectors … … 519 568 gsl_multimin_fminimizer_nmsimplex; 520 569 gsl_multimin_fminimizer *s = NULL; 521 gsl_vector *ss, * x;570 gsl_vector *ss, *y; 522 571 gsl_multimin_function minex_func; 523 572 … … 528 577 /* Initial vertex size vector */ 529 578 ss = gsl_vector_alloc (np); 530 x= gsl_vector_alloc (np);579 y = gsl_vector_alloc (np); 531 580 532 581 /* Set all step sizes to 1 */ … … 538 587 539 588 for (i=NDIM;i--;) 540 gsl_vector_set( x, i, (vectors[0]->x[i] - vectors[1]->x[i])/2.);589 gsl_vector_set(y, i, (vectors[0]->x[i] - vectors[1]->x[i])/2.); 541 590 542 591 /* Initialize method and iterate */ … … 546 595 547 596 s = gsl_multimin_fminimizer_alloc (T, np); 548 gsl_multimin_fminimizer_set (s, &minex_func, x, ss);597 gsl_multimin_fminimizer_set (s, &minex_func, y, ss); 549 598 550 599 do … … 575 624 for (i=(size_t)np;i--;) 576 625 this->x[i] = gsl_vector_get(s->x, i); 577 gsl_vector_free( x);626 gsl_vector_free(y); 578 627 gsl_vector_free(ss); 579 628 gsl_multimin_fminimizer_free (s); -
TabularUnified src/vector.hpp ¶
rd250b2 r8a3e45 10 10 11 11 vector(); 12 vector(double x1, double x2, double x3); 12 13 ~vector(); 13 14 … … 23 24 void CopyVector(const vector *y); 24 25 void RotateVector(const vector *y, const double alpha); 26 void ProjectOntoPlane(const vector *y); 25 27 void Zero(); 28 void One(double one); 29 void Init(double x1, double x2, double x3); 26 30 void Normalize(); 27 31 void Translate(const vector *x); … … 35 39 void LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors); 36 40 41 double CutsPlaneAt(vector *A, vector *B, vector *C); 37 42 bool GetOneNormalVector(const vector *x1); 38 43 bool MakeNormalVector(const vector *y1);
Note:
See TracChangeset
for help on using the changeset viewer.