Changeset 318bfd for src/boundary.cpp
- 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
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.