Changeset 1d2d01e for src/LinkedCell
- Timestamp:
- Apr 17, 2013, 6:56:06 PM (12 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:
- 79d0b9
- Parents:
- 0773bd
- git-author:
- Frederik Heber <heber@…> (03/18/13 18:39:07)
- git-committer:
- Frederik Heber <heber@…> (04/17/13 18:56:06)
- Location:
- src/LinkedCell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/LinkedCell/LinkedCell_Controller.cpp
r0773bd r1d2d01e 116 116 } 117 117 118 /** Internal function to decide whether a suitable model is present or not. 119 * 120 * Here, the heuristic for deciding whether a new linked cell structure has to 121 * be constructed or not is implemented. The current heuristic is as follows: 122 * -# the best model should have at least half the desired length (such 123 * that most we have to look two neighbor shells wide and not one). 124 * -# the best model should have at most twice the desired length but 125 * no less than 1 angstroem. 126 * 127 * \note Dealing out a pointer is here (hopefully) safe because the function is 128 * internal and we - inside this class - know what we are doing. 129 * 130 * @param distance edge length of the requested linked cell structure 131 * @return NULL - there is no fitting LinkedCell_Model, else - pointer to instance 132 */ 133 const LinkedCell_Model *LinkedCell_Controller::getBestModel(double distance) const 118 static size_t checkLengthsLess( 119 const Vector &Lengths, 120 const double min_distance) 121 { 122 size_t counter=0; 123 for (size_t i=0;i<NDIM;++i) { 124 if (Lengths[i] < min_distance) 125 ++counter; 126 } 127 return counter; 128 } 129 130 /** Given some given \a distance return it such that it is larger equal than some minimum 131 * sensible value with respect to the current domain. 132 * 133 * The sensible minimum distance \f$\Delta\f$ is computed as follows: 134 * \f$ \frac {l_1} \Delta \frac {l_2} \Delta \frac {l_3} \Delta \leq M \f$, where M is the 135 * maximum number of linked cells. Where some additional thought must be given 136 * to rounding issues. Hence, we calculate \f$ (\frac {l_i} d)^{\frac 1 d}+.5\f$, 137 * where d is the assumed dimensionality of the domain: d=3 for cubic, d=2 for 138 * a planar, d=1 for a bar-like system. 139 * 140 * \param distance distance compared with minimum value 141 * \return minimum sensible value or \a distance if larger 142 */ 143 double LinkedCell_Controller::getMinimumSensibleLength(double distance) const 134 144 { 135 145 // first check the box with respect to the given distance … … 141 151 UnitMatrix *= M; 142 152 Vector Lengths = UnitMatrix.transformToEigenbasis(); 143 double min_distance = std::numeric_limits<double>::max();144 153 double max_length = 0.; 145 for (size_t i=0;i<NDIM;++i) { 146 min_distance = std::min(Lengths[i], min_distance); 147 max_length = std::max(Lengths[i], max_length); 148 } 149 min_distance *= 1e-3; // at most 1000 cells per axis 154 double volume = 1.; 155 double min_distance = lower_threshold; 156 for (size_t dim=NDIM; dim>0; --dim) { 157 const double fraction = pow(MAX_LINKEDCELLNODES+1., 1./(double)dim); 158 for (size_t i=0;i<NDIM;++i) { 159 max_length = std::max(Lengths[i], max_length); 160 // the length dropping out for dimensionality less than 3 must appear 161 // just as factor of 1 not less. 162 if (Lengths[i] < min_distance) 163 volume *= pow(min_distance, 1./(double)dim)+.5; 164 else 165 volume *= pow(Lengths[i], 1./(double)dim)+.5; //.5 for rounding issues 166 } 167 min_distance = volume/fraction; 168 // assuming a (cubic-like) 3d system 169 if (checkLengthsLess(Lengths, min_distance) == 0) 170 break; 171 } 150 172 if (distance < min_distance) { 151 173 LOG(1, "INFO: Setting LC distance from given " << distance … … 153 175 distance = min_distance; 154 176 } 155 177 return distance; 178 } 179 180 /** Internal function to decide whether a suitable model is present or not. 181 * 182 * Here, the heuristic for deciding whether a new linked cell structure has to 183 * be constructed or not is implemented. The current heuristic is as follows: 184 * -# the best model should have at least half the desired length (such 185 * that most we have to look two neighbor shells wide and not one). 186 * -# the best model should have at most twice the desired length but 187 * no less than 1 angstroem. 188 * 189 * \note Dealing out a pointer is here (hopefully) safe because the function is 190 * internal and we - inside this class - know what we are doing. 191 * 192 * @param distance edge length of the requested linked cell structure 193 * @return NULL - there is no fitting LinkedCell_Model, else - pointer to instance 194 */ 195 const LinkedCell_Model *LinkedCell_Controller::getBestModel(double distance) const 196 { 156 197 /// Bound distance to be within [lower_threshold, upper_threshold). 157 198 /// Note that we need to stay away from upper boundary a bit, … … 159 200 if (distance < lower_threshold) 160 201 distance = lower_threshold; 161 if (distance > max_length)162 distance = max_length- std::numeric_limits<double>::round_error();202 if (distance > upper_threshold) 203 distance = upper_threshold - std::numeric_limits<double>::round_error(); 163 204 164 205 /// Look for all models within [0.5 distance, 2. distance). … … 210 251 LinkedCell_View LinkedCell_Controller::getView(const double distance, IPointCloud &set) 211 252 { 253 // distance should be a given minimum length dependent on domain at least 254 const double ConstraintDistance = getMinimumSensibleLength(distance); 255 212 256 /// Look for best instance. 213 const LinkedCell_Model * const LCModel_best = getBestModel( distance);257 const LinkedCell_Model * const LCModel_best = getBestModel(ConstraintDistance); 214 258 215 259 /// Construct new instance if none found, 216 260 if (LCModel_best == NULL) { 217 LinkedCell_Model * const LCModel_new = new LinkedCell_Model( distance, domain);261 LinkedCell_Model * const LCModel_new = new LinkedCell_Model(ConstraintDistance, domain); 218 262 LCModel_new->insertPointCloud(set); 219 insertNewModel( distance, LCModel_new);263 insertNewModel(ConstraintDistance, LCModel_new); 220 264 LinkedCell_View view(*LCModel_new); 221 265 return view; -
src/LinkedCell/LinkedCell_Controller.hpp
r0773bd r1d2d01e 61 61 void updateModels(); 62 62 63 double getMinimumSensibleLength(double distance) const; 64 63 65 private: 64 66 //!> typedef for the (edge length, model) map
Note:
See TracChangeset
for help on using the changeset viewer.