Changeset 014475


Ignore:
Timestamp:
Jul 1, 2010, 1:44:39 PM (14 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
8f822c
Parents:
12cf773
Message:

Made all places use the periodicDistance() and periodicDistanceSquared() methods provided by the Box class

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Box.cpp

    r12cf773 r014475  
    5151}
    5252
    53 Vector Box::translateIn(const Vector &point){
     53Vector Box::translateIn(const Vector &point) const{
    5454  return (*M) * point;
    5555}
    5656
    57 Vector Box::translateOut(const Vector &point){
     57Vector Box::translateOut(const Vector &point) const{
    5858  return (*Minv) * point;
    5959}
    6060
    61 Vector Box::WrapPeriodically(const Vector &point){
     61Vector Box::WrapPeriodically(const Vector &point) const{
    6262  Vector helper = translateOut(point);
    6363  for(int i=NDIM;i--;){
     
    7171}
    7272
    73 VECTORSET(std::list) Box::explode(const Vector &point){
     73VECTORSET(std::list) Box::explode(const Vector &point) const{
    7474  VECTORSET(std::list) res;
    7575
     
    9191}
    9292
    93 double Box::periodicDistanceSquared(const Vector &point1,const Vector &point2){
    94   VectorSet<std::list<Vector> > expansion = explode(point1);
    95   return expansion.minDistSquared(point2);
     93double Box::periodicDistanceSquared(const Vector &point1,const Vector &point2) const{
     94  VECTORSET(std::list) expansion = explode(point1);
     95  double res = expansion.minDistSquared(point2);
     96  return res;
     97}
     98
     99double Box::periodicDistance(const Vector &point1,const Vector &point2) const{
     100  double res;
     101  res = sqrt(periodicDistanceSquared(point1,point2));
     102  return res;
    96103}
    97104
  • src/Box.hpp

    r12cf773 r014475  
    2929  Box &operator=(const Matrix&);
    3030
    31   Vector translateIn(const Vector &point);
    32   Vector translateOut(const Vector &point);
     31  Vector translateIn(const Vector &point) const;
     32  Vector translateOut(const Vector &point) const;
    3333
    34   Vector WrapPeriodically(const Vector &point);
    35   VECTORSET(std::list) explode(const Vector &point);
     34  Vector WrapPeriodically(const Vector &point) const;
     35  VECTORSET(std::list) explode(const Vector &point) const;
    3636
    37   double periodicDistanceSquared(const Vector &point1,const Vector &point2);
     37  double periodicDistanceSquared(const Vector &point1,const Vector &point2) const;
     38  double periodicDistance(const Vector &point1,const Vector &point2) const;
    3839
    3940private:
  • src/VectorSet.hpp

    r12cf773 r014475  
    5757      return std::numeric_limits<double>::infinity();
    5858    std::list<double> helper;
     59    helper.resize(this->size());
    5960    transform(this->begin(),this->end(),
    6061              helper.begin(),
  • src/analysis_correlation.cpp

    r12cf773 r014475  
    3636  PairCorrelationMap *outmap = NULL;
    3737  double distance = 0.;
    38   const Matrix &domain = World::getInstance().getDomain().getM();
     38  Box &domain = World::getInstance().getDomain();
    3939
    4040  if (molecules->ListOfMolecules.empty()) {
     
    7777                for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    7878                  if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    79                     distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  domain);
     79                    distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
    8080                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    8181                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
     
    191191  CorrelationToPointMap *outmap = NULL;
    192192  double distance = 0.;
    193   const Matrix &domain = World::getInstance().getDomain().getM();
     193  Box &domain = World::getInstance().getDomain();
    194194
    195195  if (molecules->ListOfMolecules.empty()) {
     
    207207        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    208208          if ((*type == NULL) || ((*iter)->type == *type)) {
    209             distance = (*iter)->node->PeriodicDistance(*point, domain);
     209            distance = domain.periodicDistance(*(*iter)->node,*point);
    210210            DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    211211            outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
  • src/molecule_graph.cpp

    r12cf773 r014475  
    123123  LinkedCell *LC = NULL;
    124124  bool free_BG = false;
    125   const Matrix &M = World::getInstance().getDomain().getM();
     125  Box &domain = World::getInstance().getDomain();
    126126
    127127  if (BG == NULL) {
     
    180180                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    181181                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    182                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,M);
     182                          const double distance = domain.periodicDistanceSquared(OtherWalker->x,Walker->x);
    183183                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    184184//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
  • src/vector.cpp

    r12cf773 r014475  
    9797  return *this;
    9898}
    99 
    100 /** Calculates distance between this and another vector in a periodic cell.
    101  * \param *y array to second vector
    102  * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
    103  * \return \f$| x - y |\f$
    104  */
    105 double Vector::PeriodicDistance(const Vector &y, const Matrix &cell_size) const
    106 {
    107   return sqrt(PeriodicDistanceSquared(y,cell_size));
    108 };
    109 
    110 /** Calculates distance between this and another vector in a periodic cell.
    111  * \param *y array to second vector
    112  * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
    113  * \return \f$| x - y |^2\f$
    114  */
    115 double Vector::PeriodicDistanceSquared(const Vector &y, const Matrix &cell_size) const
    116 {
    117   double res = DistanceSquared(y), tmp;
    118     Vector Shiftedy, TranslationVector;
    119     int N[NDIM];
    120 
    121     // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
    122     for (N[0]=-1;N[0]<=1;N[0]++)
    123       for (N[1]=-1;N[1]<=1;N[1]++)
    124         for (N[2]=-1;N[2]<=1;N[2]++) {
    125           // create the translation vector
    126           TranslationVector = cell_size * Vector(N[0],N[1],N[2]);
    127           // add onto the original vector to compare with
    128           Shiftedy = y + TranslationVector;
    129           // get distance and compare with minimum so far
    130           tmp = DistanceSquared(Shiftedy);
    131           if (tmp < res) res = tmp;
    132         }
    133     return (res);
    134 };
    13599
    136100/** Calculates scalar product between this and another vector.
  • src/vector.hpp

    r12cf773 r014475  
    4242  double DistanceSquared(const Vector &y) const;
    4343  double DistanceToSpace(const Space& space) const;
    44   double PeriodicDistance(const Vector &y, const Matrix &cell_size) const;
    45   double PeriodicDistanceSquared(const Vector &y, const Matrix &cell_size) const;
    4644  double ScalarProduct(const Vector &y) const;
    4745  double Angle(const Vector &y) const;
Note: See TracChangeset for help on using the changeset viewer.