Changeset 6c5812 for src/boundary.cpp


Ignore:
Timestamp:
Jun 12, 2008, 7:34:36 PM (17 years ago)
Author:
Frederik Heber <heber@…>
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:
318bfd
Parents:
110ceb
Message:

Smaller fixes

CreateClustersinWater is now PrepareClustersinWater (as actual suspension is done in VMD still)
BoundaryPoints can be returned or not in VolumeOfConvexEnvelope

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r110ceb r6c5812  
    169169// ========================================== F U N C T I O N S =================================
    170170
     171/** Finds the endpoint two lines are sharing.
     172 * \param *line1 first line
     173 * \param *line2 second line
     174 * \return point which is shared or NULL if none
     175 */
    171176class BoundaryPointSet * GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2)
    172177{
     
    437442 * \param *out output stream for debugging
    438443 * \param *configuration needed for path to store convex envelope file
     444 * \param *BoundaryPoints NDIM set of boundary points on the projected plane per axis, on return if desired
    439445 * \param *mol molecule structure representing the cluster
    440446 */
    441 double VolumeOfConvexEnvelope(ofstream *out, config *configuration, molecule *mol)
     447double VolumeOfConvexEnvelope(ofstream *out, config *configuration, Boundaries *BoundaryPtr, molecule *mol)
    442448{
    443449  bool IsAngstroem = configuration->GetIsAngstroem();
    444450  atom *Walker = NULL;
    445451  struct Tesselation *TesselStruct = new Tesselation;
    446   Boundaries *BoundaryPoints = NULL;
     452  bool BoundaryFreeFlag = false;
     453  Boundaries *BoundaryPoints = BoundaryPtr;
    447454 
    448455  // 1. calculate center of gravity
     
    459466 
    460467  // 3. Find all points on the boundary
    461   BoundaryPoints = GetBoundaryPoints(out, mol);
     468  if (BoundaryPoints == NULL) {
     469    BoundaryFreeFlag = true;
     470    BoundaryPoints = GetBoundaryPoints(out, mol);
     471  } else {
     472    *out << Verbose(1) << "Using given boundary points set." << endl;
     473  }
    462474 
    463475  // 3d. put into boundary set only those points appearing in each of the NDIM sets
     
    544556
    545557  // free reference lists
    546 
     558  if (BoundaryFreeFlag)
     559    delete[](BoundaryPoints);
     560 
    547561  return volume;
    548562};
     
    550564
    551565/** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
     566 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
    552567 * \param *out output stream for debugging
    553568 * \param *configuration needed for path to store convex envelope file
    554569 * \param *mol molecule structure representing the cluster
    555  * \param clustervolume volume of the convex envelope cluster, \sa VolumeOfConvexEnvelope()
     570 * \param repetition[] number of repeated cluster per axis
    556571 * \param celldensity desired average density in final cell
    557  * \param GreatestDiameter[]  greatest diameter of the cluster, \sa GetDiametersOfCluster()
    558572 */
    559 void CreateClustersinWater(ofstream *out, config *configuration, molecule *mol, double clustervolume, double celldensity, double GreatestDiameter[NDIM])
    560 {
     573void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, int repetition[NDIM], double celldensity)
     574{
     575  // some preparations beforehand
    561576  bool IsAngstroem = configuration->GetIsAngstroem();
     577  Boundaries *BoundaryPoints = GetBoundaryPoints(out, mol);
     578  double clustervolume = VolumeOfConvexEnvelope(out, configuration, BoundaryPoints, mol);
     579  double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, IsAngstroem);
     580  double coeffs[NDIM];
     581  int TotalNoClusters = 1;
     582  for (int i=0;i<NDIM;i++)
     583    TotalNoClusters *= repetition[i];
     584
    562585  // sum up the atomic masses
    563586  double totalmass = 0.;
     
    575598  double cellvolume;
    576599  if (IsAngstroem)
    577     cellvolume = (4*totalmass/SOLVENTDENSITY_A - (totalmass/clustervolume))/(celldensity-1);
     600    cellvolume = (TotalNoClusters*totalmass/SOLVENTDENSITY_A - (totalmass/clustervolume))/(celldensity-1);
    578601  else
    579     cellvolume = (4*totalmass/SOLVENTDENSITY_a0 - (totalmass/clustervolume))/(celldensity-1);
     602    cellvolume = (TotalNoClusters*totalmass/SOLVENTDENSITY_a0 - (totalmass/clustervolume))/(celldensity-1);
    580603  *out << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
    581   double minimumvolume = 4*(GreatestDiameter[0]*GreatestDiameter[1]*GreatestDiameter[2]);
     604  double minimumvolume = TotalNoClusters*(GreatestDiameter[0]*GreatestDiameter[1]*GreatestDiameter[2]);
    582605  *out << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
    583606  if (minimumvolume < cellvolume)
    584607    cerr << Verbose(0) << "ERROR: the containing box already has a greater volume than the envisaged cell volume!" << endl;
    585   double  a = 4*(GreatestDiameter[0]+GreatestDiameter[1]+GreatestDiameter[2]);
    586   double b = 4*(GreatestDiameter[0]*GreatestDiameter[1] + GreatestDiameter[0]*GreatestDiameter[2] + GreatestDiameter[1]*GreatestDiameter[2]);
    587   double c = minimumvolume - cellvolume;
     608 
     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]
     611            + repetition[0]*repetition[2]*GreatestDiameter[0]*GreatestDiameter[2]
     612            + repetition[1]*repetition[2]*GreatestDiameter[1]*GreatestDiameter[2]);
     613  coeffs[2] = minimumvolume - cellvolume;
    588614  double x0 = 0.,x1 = 0.,x2 = 0.;
    589   if (gsl_poly_solve_cubic(a,b,c,&x0,&x1,&x2) == 1) // either 1 or 3 on return
     615  if (gsl_poly_solve_cubic(coeffs[0],coeffs[1],coeffs[2],&x0,&x1,&x2) == 1) // either 1 or 3 on return
    590616    *out << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
    591617  else {
     
    593619    x0 = x2;  // sorted in ascending order
    594620  }
    595  
    596   a = 2 * (x0 + GreatestDiameter[0]);
    597   b = 2 * (x0 + GreatestDiameter[1]);
    598   c = (x0 + GreatestDiameter[2]);
    599   *out << Verbose(0) << "RESULT: The resulting cell dimensions are: " << a << " and " << b << " and " << c << " with total volume of " << a*b*c << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     621
     622  cellvolume = 1;
     623  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;
    600628};
    601629
Note: See TracChangeset for help on using the changeset viewer.