Changeset b7fe6e for src/Dynamics


Ignore:
Timestamp:
Jul 20, 2017, 9:38:38 AM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_with_BondGraph_continued
Children:
698308
Parents:
3a5de5
git-author:
Frederik Heber <frederik.heber@…> (06/27/17 21:13:13)
git-committer:
Frederik Heber <frederik.heber@…> (07/20/17 09:38:38)
Message:

ForceAnnealing::anneal() now only once reduces deltat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Dynamics/ForceAnnealing.hpp

    r3a5de5 rb7fe6e  
    146146      Vector &maxComponents)
    147147  {
     148    bool deltat_decreased = false;
    148149                for(typename AtomSetMixin<T>::iterator iter = AtomicForceManipulator<T>::atoms.begin();
    149150                    iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
     
    180181                            maxComponents[i] = currentGradient[i];
    181182
    182                         // are we in initial step? Then don't check against velocity
    183                         if ((currentStep > 1) && (!(*iter)->getAtomicVelocity().IsZero()))
    184                                 // update with currentDelta tells us how the current gradient relates to
    185                                 // the last one: If it has become larger, reduce currentDelta
    186                                 if ((PositionUpdate.ScalarProduct((*iter)->getAtomicVelocity()) < 0)
    187                                     && (currentDeltat > MinimumDeltat)) {
    188                                   currentDeltat = .5*currentDeltat;
    189                                   LOG(2, "DEBUG: Upgrade in other direction: " << PositionUpdate.NormSquared()
    190                                       << " > " << (*iter)->getAtomicVelocity().NormSquared()
    191                                       << ", decreasing deltat: " << currentDeltat);
     183                        // steps may go back and forth again (updates are of same magnitude but
     184                        // have different sign: Check whether this is the case and one step with
     185                        // deltat to interrupt this sequence
     186                        if ((currentStep > 1) && (!PositionDifference.IsZero()))
     187                                if ((PositionUpdate.ScalarProduct(PositionDifference) < 0)
     188                                    && (fabs(PositionUpdate.NormSquared()-PositionDifference.NormSquared()) < 1e-3)) {
     189                                  // for convergence we want a null sequence here, too
     190                                  if (!deltat_decreased) {
     191            deltat_decreased = true;
     192            currentDeltat = .5*currentDeltat;
     193                                  }
     194                                  LOG(2, "DEBUG: Upgrade in other direction: " << PositionUpdate
     195                                      << " > " << PositionDifference
     196                                      << ", using deltat: " << currentDeltat);
    192197                                  PositionUpdate = currentDeltat * currentGradient;
    193198                        }
     199
    194200                        // finally set new values
    195201                        (*iter)->setPosition(currentPosition + PositionUpdate);
    196                         (*iter)->setAtomicVelocity(PositionUpdate);
    197                         //std::cout << "Id of atom is " << (*iter)->getId() << std::endl;
    198 //        (*iter)->VelocityVerletUpdateU((*iter)->getId(), CurrentTimeStep-1, Deltat, IsAngstroem);
    199202                }
    200203  }
Note: See TracChangeset for help on using the changeset viewer.