Changeset 2d701e for src


Ignore:
Timestamp:
Sep 9, 2014, 6:26:21 PM (10 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:
833b15
Parents:
40bb9e
git-author:
Frederik Heber <heber@…> (08/20/14 12:36:11)
git-committer:
Frederik Heber <heber@…> (09/09/14 18:26:21)
Message:

FIX: molecule::Translate() used in CenterInBox(), CenterEdge(), CenterPeriodic(), and CenterAtVector().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_geometry.cpp

    r40bb9e r2d701e  
    7070
    7171  // go through all atoms
    72   for (iterator iter = begin(); iter != end(); ++iter) {
    73     if (DoLog(4) && (*Center != *CenterBox))
    74       LOG(4, "INFO: atom before is at " << **iter);
    75     **iter -= *Center;
    76     **iter += *CenterBox;
    77     if (DoLog(4) && (*Center != *CenterBox))
    78       LOG(4, "INFO: atom after is at " << **iter);
    79   }
     72  const Vector difference = *CenterBox - *Center;
     73  Translate(&difference);
    8074  getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1));
    8175
     
    106100void molecule::CenterEdge(Vector *max)
    107101{
    108 //  Info info(__func__);
    109   Vector *min = new Vector;
    110 
    111   const_iterator iter = begin();  // start at first in list
    112   if (iter != end()) { //list not empty?
    113     for (int i=NDIM;i--;) {
    114       max->at(i) = (*iter)->at(i);
    115       min->at(i) = (*iter)->at(i);
    116     }
    117     for (; iter != end(); ++iter) {// continue with second if present
    118       //(*iter)->Output(1,1,out);
    119       for (int i=NDIM;i--;) {
    120         max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i);
    121         min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i);
     102  const_iterator iter = begin();
     103  if (iter != end()) {   //list not empty?
     104    Vector min = (*begin())->getPosition();
     105    *max = min;
     106    for (;iter != end(); ++iter) { // continue with second if present
     107      const Vector &currentPos = (*iter)->getPosition();
     108      for (size_t i=0;i<NDIM;++i) {
     109        if (min[i] > currentPos[i])
     110          min[i] = currentPos[i];
     111        if ((*max)[i] < currentPos[i])
     112          (*max)[i] = currentPos[i];
    122113      }
    123114    }
    124     LOG(1, "INFO: Maximum is " << *max << ", Minimum is " << *min << ".");
    125     min->Scale(-1.);
    126     (*max) += (*min);
    127     Translate(min);
    128   }
    129   delete(min);
     115    LOG(1, "INFO: Maximum is " << *max << ", Minimum is " << min << ".");
     116    const Vector temp = -1.*min;
     117    Translate(&temp);
     118  }
    130119};
    131120
     
    216205  Vector NewCenter;
    217206  DeterminePeriodicCenter(NewCenter);
    218   // go through all atoms
    219   for (iterator iter = begin(); iter != end(); ++iter) {
    220     **iter -= NewCenter;
    221   }
     207  NewCenter *= -1.;
     208  Translate(&NewCenter);
    222209};
    223210
     
    229216void molecule::CenterAtVector(Vector *newcenter)
    230217{
    231   // go through all atoms
    232   for (iterator iter = begin(); iter != end(); ++iter) {
    233     **iter -= *newcenter;
    234   }
     218  const Vector temp = -1.**newcenter;
     219  Translate(&temp);
    235220};
    236221
Note: See TracChangeset for help on using the changeset viewer.