Changeset 300220 for src/bondgraph.cpp


Ignore:
Timestamp:
Mar 1, 2011, 1:17:08 PM (15 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, Candidate_v1.7.0, 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:
0ec7fe
Parents:
0cbad2
git-author:
Frederik Heber <heber@…> (02/28/11 15:00:34)
git-committer:
Frederik Heber <heber@…> (03/01/11 13:17:08)
Message:

BondGraph::..MinMaxDistance() changed to use range<double>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    r0cbad2 r300220  
    9393}
    9494
    95 double BondGraph::GetBondLength(int firstZ, int secondZ)
     95double BondGraph::GetBondLength(
     96    int firstZ,
     97    int secondZ) const
    9698{
    9799  std::cout << "Request for length between " << firstZ << " and " << secondZ << ": ";
     
    110112}
    111113
    112 
    113 void BondGraph::CovalentMinMaxDistance(const BondedParticle * const Walker, const BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
    114 {
    115   MinDistance = OtherWalker->getType()->getCovalentRadius() + Walker->getType()->getCovalentRadius();
    116   MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
    117   MaxDistance = MinDistance + BondThreshold;
    118   MinDistance -= BondThreshold;
    119 }
    120 
    121 void BondGraph::BondLengthMatrixMinMaxDistance(const BondedParticle * const Walker, const BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
    122 {
    123   ASSERT(BondLengthMatrix != NULL,
    124       "BondGraph::BondLengthMatrixMinMaxDistance() called without NULL BondLengthMatrix.");
    125   MinDistance = GetBondLength(Walker->getType()->getAtomicNumber()-1, OtherWalker->getType()->getAtomicNumber()-1);
    126   MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
    127   MaxDistance = MinDistance + BondThreshold;
    128   MinDistance -= BondThreshold;
    129 }
    130 
    131 void BondGraph::getMinMaxDistance(const BondedParticle * const Walker, const BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
     114void BondGraph::CovalentMinMaxDistance(
     115    const element * const Walker,
     116    const element * const OtherWalker,
     117    range<double> &MinMaxDistance,
     118    bool IsAngstroem) const
     119{
     120  MinMaxDistance.first = OtherWalker->getCovalentRadius() + Walker->getCovalentRadius();
     121  MinMaxDistance.first *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
     122  MinMaxDistance.last = MinMaxDistance.first + BondThreshold;
     123  MinMaxDistance.first -= BondThreshold;
     124}
     125
     126void BondGraph::BondLengthMatrixMinMaxDistance(
     127    const element * const Walker,
     128    const element * const OtherWalker,
     129    range<double> &MinMaxDistance,
     130    bool IsAngstroem) const
     131{
     132  ASSERT(BondLengthMatrix, "BondGraph::BondLengthMatrixMinMaxDistance() called without NULL BondLengthMatrix.");
     133  ASSERT(Walker, "BondGraph::BondLengthMatrixMinMaxDistance() - illegal element given.");
     134  ASSERT(OtherWalker, "BondGraph::BondLengthMatrixMinMaxDistance() - illegal other element given.");
     135  MinMaxDistance.first = GetBondLength(Walker->getAtomicNumber()-1, OtherWalker->getAtomicNumber()-1);
     136  MinMaxDistance.first *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
     137  MinMaxDistance.last = MinMaxDistance.first + BondThreshold;
     138  MinMaxDistance.first -= BondThreshold;
     139}
     140
     141void BondGraph::getMinMaxDistance(
     142    const element * const Walker,
     143    const element * const OtherWalker,
     144    range<double> &MinMaxDistance,
     145    bool IsAngstroem) const
    132146{
    133147  if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet
    134     LOG(2, "INFO: Using Covalent radii criterion for [min,max] distances.");
    135     CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     148    LOG(2, "INFO: Using Covalent radii criterion for [min,max) distances.");
     149    CovalentMinMaxDistance(Walker, OtherWalker, MinMaxDistance, IsAngstroem);
    136150  } else {
    137     LOG(2, "INFO: Using Covalent radii criterion for [min,max] distances.");
    138     BondLengthMatrixMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    139   }
     151    LOG(2, "INFO: Using Covalent radii criterion for [min,max) distances.");
     152    BondLengthMatrixMinMaxDistance(Walker, OtherWalker, MinMaxDistance, IsAngstroem);
     153  }
     154}
     155
     156void BondGraph::getMinMaxDistance(
     157    const BondedParticle * const Walker,
     158    const BondedParticle * const OtherWalker,
     159    range<double> &MinMaxDistance,
     160    bool IsAngstroem) const
     161{
     162  getMinMaxDistance(Walker->getType(), OtherWalker->getType(),MinMaxDistance, IsAngstroem);
     163}
     164
     165void BondGraph::getMinMaxDistanceSquared(
     166    const BondedParticle * const Walker,
     167    const BondedParticle * const OtherWalker,
     168    range<double> &MinMaxDistance,
     169    bool IsAngstroem) const
     170{
     171  // use non-squared version
     172  getMinMaxDistance(Walker, OtherWalker,MinMaxDistance, IsAngstroem);
     173  // and square
     174  MinMaxDistance.first *= MinMaxDistance.first;
     175  MinMaxDistance.last *= MinMaxDistance.last;
    140176}
    141177
     
    145181  atom *OtherWalker = NULL;
    146182  int n[NDIM];
    147   double MinDistance, MaxDistance;
    148183  Box &domain = World::getInstance().getDomain();
    149184
     
    174209                        ASSERT(OtherWalker != NULL,
    175210                            "BondGraph::CreateAdjacency() - TesselPoint that was not an atom retrieved from LinkedNode");
    176                         getMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     211                        range<double> MinMaxDistanceSquared(0.,0.);
     212                        getMinMaxDistanceSquared(Walker, OtherWalker, MinMaxDistanceSquared, IsAngstroem);
    177213                        const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition());
    178                         LOG(2, "INFO: Checking distance " << distance << " against typical bond length of [" << MinDistance * MinDistance << "," << MaxDistance * MaxDistance << "].");
    179                         const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    180                         LOG(3, "INFO: MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << ".");
     214                        LOG(2, "INFO: Checking squared distance " << distance << " against typical bond length of " << MinMaxDistanceSquared << ".");
     215                        const bool status = MinMaxDistanceSquared.isInRange(distance);
    181216                        if (OtherWalker->father > Walker->father ) { // just to not add bonds from both sides
    182217                          if (status) { // create bond if distance is smaller
     
    188223                          } else {
    189224                            LOG(1, "REJECT: Squared distance "
    190                                 << distance << " is out of covalent bounds ["
    191                                 << MinDistance*MinDistance << ","
    192                                 << MaxDistance * MaxDistance << "].");
     225                                << distance << " is out of squared covalent bounds "
     226                                << MinMaxDistanceSquared << ".");
    193227                          }
    194228                        } else {
Note: See TracChangeset for help on using the changeset viewer.