Changeset 1e4f0a


Ignore:
Timestamp:
Sep 13, 2017, 5:20:45 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Children:
1db3520
Parents:
15acdb
Message:

ForceAnnealing returns whether to stop and ForceAnnealingAction stops MakroAction if inside such.

  • this is done by setting the MakroAction's loop variable to the current step which is now accessible.
  • ForceAnnealing currently has a fixed value of 1e-8 when the force components are below to stop annealing.
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/ForceAnnealingAction.cpp

    r15acdb r1e4f0a  
    3535//#include "CodePatterns/MemDebug.hpp"
    3636
     37#include "Actions/ActionExceptions.hpp"
     38#include "Actions/MakroAction.hpp"
    3739#include "Actions/UndoRedoHelpers.hpp"
    3840#include "Atom/atom.hpp"
     
    126128  // perform optimization step
    127129  LOG(1, "Structural optimization.");
    128   optimizer(CurrentStep, 1, params.UseBondGraph.get());
     130  const bool StopStatus = optimizer(CurrentStep, 1, params.UseBondGraph.get());
    129131  STATUS("Successfully optimized structure by one step.");
     132
     133  if (StopStatus && ActionQueue::getInstance().isMakroAction()) {
     134    // send stop signal if we are taking part in MakroAction
     135    MakroAction * const makroaction =
     136        dynamic_cast<MakroAction *>(
     137            const_cast<Action *>(
     138                &ActionQueue::getInstance().getCurrentAction()));
     139    if (makroaction != NULL) {
     140      makroaction->setLoop(makroaction->getStep());
     141    } else {
     142      ELOG(2, "ActionQueue said we are inside process, but current Action is not a process?");
     143      // do nothing
     144    }
     145  }
    130146
    131147  std::vector<AtomicInfo> RedoInfo;
  • src/Dynamics/ForceAnnealing.hpp

    r15acdb r1e4f0a  
    7878    maxSteps(_maxSteps),
    7979    max_distance(_max_distance),
    80     damping_factor(_damping_factor)
     80    damping_factor(_damping_factor),
     81    FORCE_THRESHOLD(1e-8)
    8182  {}
    8283
     
    9495   * \param _TimeStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
    9596   * \param offset offset in matrix file to the first force component
     97   * \return false - need to continue annealing, true - may stop because forces very small
    9698   * \todo This is not yet checked if it is correctly working with DoConstrainedMD set >0.
    9799   */
    98   void operator()(
     100  bool operator()(
    99101      const int _TimeStep,
    100102      const size_t _offset,
     
    134136        << currentStep << " are " << maxComponents);
    135137
     138    // check whether are smaller than threshold
     139    bool AnnealingFinished = false;
     140    double maxcomp = 0.;
     141    for (size_t i=0;i<NDIM;++i)
     142      maxcomp = std::max(maxcomp, fabs(maxComponents[i]));
     143    if (maxcomp < FORCE_THRESHOLD) {
     144      LOG(1, "STATUS: Force components are all less than " << FORCE_THRESHOLD
     145          << ", stopping.");
     146      currentStep = maxSteps;
     147      AnnealingFinished = true;
     148    }
     149
    136150    // are we in final step? Remember to reset static entities
    137151    if (currentStep == maxSteps) {
     
    139153      reset();
    140154    }
     155
     156    return AnnealingFinished;
    141157  }
    142158
     
    627643  //!> the shifted is dampened by this factor with the power of the bond graph distance to the shift causing atom
    628644  const double damping_factor;
     645  //!> threshold for force components to stop annealing
     646  const double FORCE_THRESHOLD;
    629647};
    630648
Note: See TracChangeset for help on using the changeset viewer.