Changeset efd020 for src


Ignore:
Timestamp:
Apr 10, 2018, 6:43:12 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
8c6b68
Parents:
12f16c
git-author:
Frederik Heber <frederik.heber@…> (09/11/17 17:03:27)
git-committer:
Frederik Heber <frederik.heber@…> (04/10/18 06:43:12)
Message:

Readded step-world-time to StructuralOptimization.

  • adapted ForceAnnealing and its Action accordingly, i.e. they receive the old time step as the current step.
  • TESTFIX: needed to add "--step-world-time 1" to ForceAnnealing regression test, results then remained exactly the same.
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/StructuralOptimizationAction.cpp

    r12f16c refd020  
    6969  prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")).clone());
    7070  prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")).clone());
     71  prototype_actions.addAction(AR.getActionByName(std::string("step-world-time")).clone());
    7172  prototype_actions.addAction(AR.getActionByName(std::string("force-annealing")).clone());
    7273  prototype_actions.addAction(AR.getActionByName(std::string("output")).clone());
  • src/Actions/MoleculeAction/ForceAnnealingAction.cpp

    r12f16c refd020  
    9494      params.DampingFactor.get());
    9595  size_t CurrentStep = WorldTime::getInstance().getTime();
     96  if (CurrentStep == 0) {
     97    ELOG(1, "WorldTime must be at least at step 1 already, use step-world-time if necessary.");
     98    return Action::failure;
     99  }
    96100
    97   // parse forces into current step
     101  // parse forces into last step (assuming we stepped on already)
    98102  if (!params.forcesfile.get().string().empty()) {
    99103    LOG(1, "Parsing forces file.");
    100     if (!optimizer.parseForcesFile(params.forcesfile.get().string().c_str(), CurrentStep))
     104    if (!optimizer.parseForcesFile(params.forcesfile.get().string().c_str(), CurrentStep-1))
    101105      LOG(2, "File " << params.forcesfile.get() << " not found.");
    102106    else
     
    104108  }
    105109
    106   // copy current time step to new one and and proceed on this one
    107   {
    108     for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection();
    109         iter != World::getInstance().endAtomSelection();
    110         ++iter) {
    111       atom * const Walker = iter->second;
    112       Walker->setPositionAtStep(CurrentStep+1,
    113           Walker->getPositionAtStep(CurrentStep));
    114       // force have already been calculated, hence copy them
    115       Walker->setAtomicVelocityAtStep(CurrentStep+1,
    116           Walker->getAtomicVelocityAtStep(CurrentStep));
    117       Walker->setAtomicForceAtStep(CurrentStep+1,
    118           Walker->getAtomicForceAtStep(CurrentStep));
    119     }
    120     // increment to next time step: re-creates bond graph
    121     ++CurrentStep;
    122     World::getInstance().setTime(CurrentStep);
    123   }
    124 
    125110  // perform optimization step
    126111  LOG(1, "Structural optimization.");
    127   optimizer(CurrentStep, 1, params.UseBondGraph.get());
     112  optimizer(CurrentStep-1, 1, params.UseBondGraph.get());
    128113  STATUS("Successfully optimized structure by one step.");
    129114
  • src/Dynamics/ForceAnnealing.hpp

    r12f16c refd020  
    139139        iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
    140140      // atom's force vector gives steepest descent direction
    141       const Vector oldPosition = (*iter)->getPositionAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0);
    142       const Vector currentPosition = (*iter)->getPosition();
    143       const Vector oldGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0);
    144       const Vector currentGradient = (*iter)->getAtomicForce();
     141      const Vector oldPosition = (*iter)->getPositionAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
     142      const Vector currentPosition = (*iter)->getPositionAtStep(CurrentTimeStep);
     143      const Vector oldGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
     144      const Vector currentGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep);
    145145      LOG(4, "DEBUG: oldPosition for atom " << **iter << " is " << oldPosition);
    146146      LOG(4, "DEBUG: currentPosition for atom " << **iter << " is " << currentPosition);
     
    197197   *
    198198   *
    199    * \param CurrentTimeStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
     199   * \param CurrentTimeStep current time step (i.e. t where \f$ t + \Delta t \f$ is in the sense of the velocity verlet)
    200200   * \param offset offset in matrix file to the first force component
    201201   * \param maxComponents to be filled with maximum force component over all atoms
     
    226226        iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
    227227      // atom's force vector gives steepest descent direction
    228       const Vector oldPosition = (*iter)->getPositionAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0);
    229       const Vector currentPosition = (*iter)->getPosition();
    230       const Vector oldGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0);
    231       const Vector currentGradient = (*iter)->getAtomicForce();
     228      const Vector oldPosition = (*iter)->getPositionAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
     229      const Vector currentPosition = (*iter)->getPositionAtStep(CurrentTimeStep);
     230      const Vector oldGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
     231      const Vector currentGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep);
    232232      LOG(4, "DEBUG: Force for atom " << **iter << " is " << currentGradient);
    233233
     
    269269        const bond &current_bond = *(*bonditer);
    270270        LOG(2, "DEBUG: Looking at bond " << current_bond);
    271         Vector BondVector = (*iter)->getPosition();
     271        Vector BondVector = (*iter)->getPositionAtStep(CurrentTimeStep);
    272272        BondVector -= ((*iter)->getId() == current_bond.rightatom->getId())
    273             ? current_bond.rightatom->getPosition() : current_bond.leftatom->getPosition();
     273            ? current_bond.rightatom->getPositionAtStep(CurrentTimeStep) : current_bond.leftatom->getPositionAtStep(CurrentTimeStep);
    274274        BondVector.Normalize();
    275275        if (BondVector.ScalarProduct(currentGradient) < 0) {
Note: See TracChangeset for help on using the changeset viewer.