- Timestamp:
- Jun 13, 2008, 9:18:57 AM (17 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:
- edb650
- Parents:
- 6c5812
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r6c5812 r318bfd 372 372 * \param *out output stream for debugging 373 373 * \param *BoundaryPoints NDIM set of boundary points defining the convex envelope on each projected plane 374 * \param *mol molecule structure representing the cluster 374 375 * \param IsAngstroem whether we have angstroem or atomic units 375 376 * \return NDIM array of the diameters 376 377 */ 377 double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPoints, bool IsAngstroem) 378 { 378 double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem) 379 { 380 // get points on boundary of NULL was given as parameter 381 bool BoundaryFreeFlag = false; 382 Boundaries *BoundaryPoints = BoundaryPtr; 383 if (BoundaryPoints == NULL) { 384 BoundaryFreeFlag = true; 385 BoundaryPoints = GetBoundaryPoints(out, mol); 386 } else { 387 *out << Verbose(1) << "Using given boundary points set." << endl; 388 } 389 379 390 // determine biggest "diameter" of cluster for each axis 380 391 Boundaries::iterator Neighbour, OtherNeighbour; … … 434 445 *out << Verbose(0) << "RESULT: The biggest diameters are " << GreatestDiameter[0] << " and " << GreatestDiameter[1] << " and " << GreatestDiameter[2] << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "." << endl; 435 446 447 // free reference lists 448 if (BoundaryFreeFlag) 449 delete[](BoundaryPoints); 450 436 451 return GreatestDiameter; 437 452 }; … … 452 467 bool BoundaryFreeFlag = false; 453 468 Boundaries *BoundaryPoints = BoundaryPtr; 454 469 double volume = 0.; 470 double PyramidVolume = 0.; 471 double G,h; 472 vector x,y; 473 double a,b,c; 474 455 475 // 1. calculate center of gravity 456 476 *out << endl; … … 473 493 } 474 494 475 // 3d. put into boundary set only those points appearing in each of the NDIM sets 476 int *AtomList = new int[mol->AtomCount]; 477 for (int j=0; j<mol->AtomCount; j++) // reset list 478 AtomList[j] = 0; 479 for (int axis=0; axis<NDIM; axis++) { // fill list when it's on the boundary 495 // 4. fill the boundary point list 496 for (int axis=0;axis<NDIM;axis++) 480 497 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 481 AtomList[runner->second.second->nr]++;498 TesselStruct->AddPoint(runner->second.second); 482 499 } 483 }484 for (int axis=0; axis<NDIM; axis++) {485 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {486 if (AtomList[runner->second.second->nr] < 1) {487 *out << Verbose(1) << "Throwing especially out " << *runner->second.second << " in axial projection of axis " << axis << "." << endl;488 BoundaryPoints[axis].erase(runner);489 }490 }491 }492 delete[](AtomList);493 494 // 4a. fill the boundary point list495 Walker = mol->start;496 while (Walker->next != mol->end) {497 Walker = Walker->next;498 if (AtomList[Walker->nr] > 0) {499 TesselStruct->AddPoint(Walker);500 }501 }502 500 503 501 *out << Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl; … … 512 510 // *out << endl; 513 511 514 // 4b. guess starting triangle512 // 5a. guess starting triangle 515 513 TesselStruct->GuessStartingTriangle(out); 516 514 517 // 5 . go through all lines, that are not yet part of two triangles (only of one so far)515 // 5b. go through all lines, that are not yet part of two triangles (only of one so far) 518 516 TesselStruct->TesselateOnBoundary(out, configuration, mol); 519 517 … … 522 520 // 6a. Every triangle forms a pyramid with the center of gravity as its peak, sum up the volumes 523 521 *out << Verbose(1) << "Calculating the volume of the pyramids formed out of triangles and center of gravity." << endl; 524 double volume = 0.;525 double PyramidVolume = 0.;526 double G,h;527 vector x,y;528 double a,b,c;529 522 for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) { // go through every triangle, calculate volume of its pyramid with CoG as peak 530 523 x.CopyVector(&runner->second->endpoints[0]->node->x); … … 568 561 * \param *configuration needed for path to store convex envelope file 569 562 * \param *mol molecule structure representing the cluster 570 * \param repetition[] number of repeated cluster per axis571 563 * \param celldensity desired average density in final cell 572 564 */ 573 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, int repetition[NDIM], double celldensity) 574 { 565 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double celldensity) 566 { 567 // transform to PAS 568 mol->PrincipalAxisSystem(out, true); 569 575 570 // some preparations beforehand 576 571 bool IsAngstroem = configuration->GetIsAngstroem(); 577 572 Boundaries *BoundaryPoints = GetBoundaryPoints(out, mol); 578 573 double clustervolume = VolumeOfConvexEnvelope(out, configuration, BoundaryPoints, mol); 579 double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, IsAngstroem); 580 double coeffs[NDIM]; 574 double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, IsAngstroem); 575 vector BoxLengths; 576 int repetition[NDIM] = {1, 1, 1}; 581 577 int TotalNoClusters = 1; 582 578 for (int i=0;i<NDIM;i++) … … 602 598 cellvolume = (TotalNoClusters*totalmass/SOLVENTDENSITY_a0 - (totalmass/clustervolume))/(celldensity-1); 603 599 *out << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 600 604 601 double minimumvolume = TotalNoClusters*(GreatestDiameter[0]*GreatestDiameter[1]*GreatestDiameter[2]); 605 602 *out << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 606 if (minimumvolume <cellvolume)603 if (minimumvolume > cellvolume) 607 604 cerr << Verbose(0) << "ERROR: the containing box already has a greater volume than the envisaged cell volume!" << endl; 608 605 609 coeffs[0] = (repetition[0]*GreatestDiameter[0] + repetition[1]*GreatestDiameter[1] + repetition[2]*GreatestDiameter[2]);610 coeffs[1] = (repetition[0]*repetition[1]*GreatestDiameter[0]*GreatestDiameter[1]606 BoxLengths.x[0] = (repetition[0]*GreatestDiameter[0] + repetition[1]*GreatestDiameter[1] + repetition[2]*GreatestDiameter[2]); 607 BoxLengths.x[1] = (repetition[0]*repetition[1]*GreatestDiameter[0]*GreatestDiameter[1] 611 608 + repetition[0]*repetition[2]*GreatestDiameter[0]*GreatestDiameter[2] 612 609 + repetition[1]*repetition[2]*GreatestDiameter[1]*GreatestDiameter[2]); 613 coeffs[2] = minimumvolume - cellvolume;610 BoxLengths.x[2] = minimumvolume - cellvolume; 614 611 double x0 = 0.,x1 = 0.,x2 = 0.; 615 if (gsl_poly_solve_cubic( coeffs[0],coeffs[1],coeffs[2],&x0,&x1,&x2) == 1) // either 1 or 3 on return612 if (gsl_poly_solve_cubic(BoxLengths.x[0],BoxLengths.x[1],BoxLengths.x[2],&x0,&x1,&x2) == 1) // either 1 or 3 on return 616 613 *out << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl; 617 614 else { … … 622 619 cellvolume = 1; 623 620 for(int i=0;i<NDIM;i++) { 624 coeffs[i] = repetition[0] * (x0 + GreatestDiameter[0]); 625 cellvolume *= coeffs[i]; 626 } 627 *out << Verbose(0) << "RESULT: The resulting cell dimensions are: " << coeffs[0] << " and " << coeffs[1] << " and " << coeffs[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 621 BoxLengths.x[i] = repetition[i] * (x0 + GreatestDiameter[i]); 622 cellvolume *= BoxLengths.x[i]; 623 } 624 *out << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 625 626 // set new box dimensions 627 *out << Verbose(0) << "Translating to box with these boundaries." << endl; 628 mol->CenterInBox((ofstream *)&cout, &BoxLengths); 629 // update Box of atoms by boundary 630 mol->SetBoxDimension(&BoxLengths); 631 628 632 }; 629 633 -
src/boundary.hpp
r6c5812 r318bfd 123 123 124 124 double VolumeOfConvexEnvelope(ofstream *out, config *configuration, Boundaries *BoundaryPoints, molecule *mol); 125 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, int repetition[NDIM], double celldensity); 125 double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem); 126 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double celldensity); 126 127 127 128 -
src/builder.cpp
r6c5812 r318bfd 758 758 cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl; 759 759 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; 760 cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl; 760 761 cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl; 761 762 cout << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner and stores config files in same dir as config." << endl; … … 768 769 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl; 769 770 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 771 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl; 770 772 cout << "\t-v/-V\t\tGives version information." << endl; 771 773 cout << "Note: config files must not begin with '-' !" << endl; … … 983 985 ExitFlag = 1; 984 986 cout << Verbose(0) << "Evaluating volume of the convex envelope."; 985 // tmp = atof(argv[argptr++]);986 // if (tmp < 1.0) {987 // cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;988 // tmp = 1.3;989 // }990 987 VolumeOfConvexEnvelope((ofstream *)&cout, &configuration, NULL, mol); 988 break; 989 case 'u': 990 { 991 double tmp; 992 ExitFlag = 1; 993 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."; 994 tmp = atof(argv[argptr++]); 995 if (tmp < 1.0) { 996 cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl; 997 tmp = 1.3; 998 } 999 // for(int i=0;i<NDIM;i++) { 1000 // repetition[i] = atoi(argv[argptr++]); 1001 // if (repetition[i] < 1) 1002 // cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl; 1003 // repetition[i] = 1; 1004 // } 1005 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, tmp); 1006 } 1007 break; 1008 case 'd': 1009 for (int axis = 1; axis <= NDIM; axis++) { 1010 int faktor = atoi(argv[argptr++]); 1011 int count; 1012 element ** Elements; 1013 vector ** Vectors; 1014 if (faktor < 1) { 1015 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl; 1016 faktor = 1; 1017 } 1018 mol->CountAtoms((ofstream *)&cout); // recount atoms 1019 if (mol->AtomCount != 0) { // if there is more than none 1020 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1021 Elements = new element *[count]; 1022 Vectors = new vector *[count]; 1023 j = 0; 1024 first = mol->start; 1025 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 1026 first = first->next; 1027 Elements[j] = first->type; 1028 Vectors[j] = &first->x; 1029 j++; 1030 } 1031 if (count != j) 1032 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl; 1033 x.Zero(); 1034 y.Zero(); 1035 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 1036 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1037 x.AddVector(&y); // per factor one cell width further 1038 for (int k=count;k--;) { // go through every atom of the original cell 1039 first = new atom(); // create a new body 1040 first->x.CopyVector(Vectors[k]); // use coordinate of original atom 1041 first->x.AddVector(&x); // translate the coordinates 1042 first->type = Elements[k]; // insert original element 1043 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 1044 } 1045 } 1046 // free memory 1047 delete[](Elements); 1048 delete[](Vectors); 1049 // correct cell size 1050 if (axis < 0) { // if sign was negative, we have to translate everything 1051 x.Zero(); 1052 x.AddVector(&y); 1053 x.Scale(-(faktor-1)); 1054 mol->Translate(&x); 1055 } 1056 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 1057 } 1058 } 991 1059 break; 992 1060 default: // no match? Step on
Note:
See TracChangeset
for help on using the changeset viewer.