Changeset 0779a9 for molecuilder
- Timestamp:
- Jun 13, 2008, 2:26:50 PM (17 years ago)
- Children:
- 1f9f1b
- Parents:
- 3f0c46
- Location:
- molecuilder/src
- Files:
-
- 3 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 -
molecuilder/src/boundary.hpp
r3f0c46 r0779a9 124 124 double VolumeOfConvexEnvelope(ofstream *out, config *configuration, Boundaries *BoundaryPoints, molecule *mol); 125 125 double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem); 126 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double celldensity);126 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity); 127 127 128 128 -
molecuilder/src/builder.cpp
r3f0c46 r0779a9 736 736 int ExitFlag = 0; 737 737 int j; 738 double volume = 0.; 738 739 enum ConfigStatus config_present = absent; 739 740 clock_t start,end; … … 987 988 VolumeOfConvexEnvelope((ofstream *)&cout, &configuration, NULL, mol); 988 989 break; 990 case 'U': 991 volume = atof(argv[argptr++]); 992 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl; 989 993 case 'u': 990 994 { 991 double tmp;995 double density; 992 996 ExitFlag = 1; 993 997 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."; 994 tmp= atof(argv[argptr++]);995 if ( tmp< 1.0) {998 density = atof(argv[argptr++]); 999 if (density < 1.0) { 996 1000 cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl; 997 tmp= 1.3;1001 density = 1.3; 998 1002 } 999 1003 // for(int i=0;i<NDIM;i++) { … … 1003 1007 // repetition[i] = 1; 1004 1008 // } 1005 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, tmp);1009 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density); 1006 1010 } 1007 1011 break;
Note:
See TracChangeset
for help on using the changeset viewer.