Changeset 0779a9 for molecuilder/src/boundary.cpp
- Timestamp:
- Jun 13, 2008, 2:26:50 PM (17 years ago)
- Children:
- 1f9f1b
- Parents:
- 3f0c46
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/boundary.cpp
r3f0c46 r0779a9 561 561 * \param *configuration needed for path to store convex envelope file 562 562 * \param *mol molecule structure representing the cluster 563 * \param ClusterVolume guesstimated cluster volume, if equal 0 we used VolumeOfConvexEnvelope() instead. 563 564 * \param celldensity desired average density in final cell 564 565 */ 565 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double celldensity)566 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity) 566 567 { 567 568 // transform to PAS … … 571 572 bool IsAngstroem = configuration->GetIsAngstroem(); 572 573 Boundaries *BoundaryPoints = GetBoundaryPoints(out, mol); 573 double clustervolume = VolumeOfConvexEnvelope(out, configuration, BoundaryPoints, mol); 574 double clustervolume; 575 if (ClusterVolume == 0) 576 clustervolume = VolumeOfConvexEnvelope(out, configuration, BoundaryPoints, mol); 577 else 578 clustervolume = ClusterVolume; 574 579 double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, IsAngstroem); 575 580 vector BoxLengths; … … 601 606 double minimumvolume = TotalNoClusters*(GreatestDiameter[0]*GreatestDiameter[1]*GreatestDiameter[2]); 602 607 *out << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 603 if (minimumvolume > cellvolume) 608 if (minimumvolume > cellvolume) { 604 609 cerr << Verbose(0) << "ERROR: the containing box already has a greater volume than the envisaged cell volume!" << endl; 605 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] 608 + repetition[0]*repetition[2]*GreatestDiameter[0]*GreatestDiameter[2] 609 + repetition[1]*repetition[2]*GreatestDiameter[1]*GreatestDiameter[2]); 610 BoxLengths.x[2] = minimumvolume - cellvolume; 611 double x0 = 0.,x1 = 0.,x2 = 0.; 612 if (gsl_poly_solve_cubic(BoxLengths.x[0],BoxLengths.x[1],BoxLengths.x[2],&x0,&x1,&x2) == 1) // either 1 or 3 on return 613 *out << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl; 614 else { 615 *out << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl; 616 x0 = x2; // sorted in ascending order 617 } 618 619 cellvolume = 1; 620 for(int i=0;i<NDIM;i++) { 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); 610 cout << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl; 611 for(int i=0;i<NDIM;i++) 612 BoxLengths.x[i] = GreatestDiameter[i]; 613 mol->CenterEdge(out, &BoxLengths); 614 } else { 615 BoxLengths.x[0] = (repetition[0]*GreatestDiameter[0] + repetition[1]*GreatestDiameter[1] + repetition[2]*GreatestDiameter[2]); 616 BoxLengths.x[1] = (repetition[0]*repetition[1]*GreatestDiameter[0]*GreatestDiameter[1] 617 + repetition[0]*repetition[2]*GreatestDiameter[0]*GreatestDiameter[2] 618 + repetition[1]*repetition[2]*GreatestDiameter[1]*GreatestDiameter[2]); 619 BoxLengths.x[2] = minimumvolume - cellvolume; 620 double x0 = 0.,x1 = 0.,x2 = 0.; 621 if (gsl_poly_solve_cubic(BoxLengths.x[0],BoxLengths.x[1],BoxLengths.x[2],&x0,&x1,&x2) == 1) // either 1 or 3 on return 622 *out << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl; 623 else { 624 *out << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl; 625 x0 = x2; // sorted in ascending order 626 } 627 628 cellvolume = 1; 629 for(int i=0;i<NDIM;i++) { 630 BoxLengths.x[i] = repetition[i] * (x0 + GreatestDiameter[i]); 631 cellvolume *= BoxLengths.x[i]; 632 } 633 634 // set new box dimensions 635 *out << Verbose(0) << "Translating to box with these boundaries." << endl; 636 mol->CenterInBox((ofstream *)&cout, &BoxLengths); 637 } 629 638 // update Box of atoms by boundary 630 639 mol->SetBoxDimension(&BoxLengths); 631 640 *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; 632 641 }; 633 642
Note:
See TracChangeset
for help on using the changeset viewer.