Changeset bd0159 for src/Dynamics/ForceAnnealing.hpp
- Timestamp:
- Jul 5, 2017, 7:45:46 PM (8 years ago)
- Branches:
- ForceAnnealing_oldresults
- Children:
- 8754b1
- Parents:
- 84f449
- git-author:
- Frederik Heber <heber@…> (04/06/17 05:09:37)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/05/17 19:45:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Dynamics/ForceAnnealing.hpp
r84f449 rbd0159 32 32 * 33 33 * Sadly, we have to use some static instances as so far values cannot be passed 34 * between actions. Hence, we need to store the current step and the adaptive 34 * between actions. Hence, we need to store the current step and the adaptive- 35 35 * step width (we cannot perform a linesearch, as we have no control over the 36 36 * calculation of the forces). … … 42 42 /** Constructor of class ForceAnnealing. 43 43 * 44 * \note We use a fixed delta t of 1. 45 * 44 46 * \param _atoms set of atoms to integrate 45 47 * \param _Deltat time step width in atomic units … … 49 51 ForceAnnealing( 50 52 AtomSetMixin<T> &_atoms, 51 double _Deltat,52 53 bool _IsAngstroem, 53 54 const size_t _maxSteps) : 54 AtomicForceManipulator<T>(_atoms, _Deltat, _IsAngstroem),55 AtomicForceManipulator<T>(_atoms, 1., _IsAngstroem), 55 56 maxSteps(_maxSteps) 56 57 {} … … 89 90 iter != AtomicForceManipulator<T>::atoms.end(); ++iter) { 90 91 // atom's force vector gives steepest descent direction 92 const Vector oldPosition = (*iter)->getPositionAtStep(NextStep-2 >= 0 ? NextStep - 2 : 0); 91 93 const Vector currentPosition = (*iter)->getPosition(); 94 const Vector oldGradient = (*iter)->getAtomicForceAtStep(NextStep-2 >= 0 ? NextStep - 2 : 0); 92 95 const Vector currentGradient = (*iter)->getAtomicForce(); 93 96 LOG(4, "DEBUG: Force for atom " << **iter << " is " << currentGradient); 94 97 95 // artificial update: deltat may be considered as 1/2 s^2 units, mass 96 // is neglected deliberately as this makes all atoms equally fast or 97 // hydrogens slower (and they need to wait for other atoms to arrive at 98 // final position). 99 Vector PositionUpdate = currentDeltat * currentGradient; 98 // we use Barzilai-Borwein update with position reversed to get descent 99 const Vector GradientDifference = (currentGradient - oldGradient); 100 const double stepwidth = 101 fabs((currentPosition - oldPosition).ScalarProduct(GradientDifference))/ 102 GradientDifference.NormSquared(); 103 Vector PositionUpdate = stepwidth * currentGradient; 104 if (fabs(stepwidth) < 1e-10) { 105 // dont' warn in first step, deltat usage normal 106 if (currentStep != 1) 107 ELOG(1, "INFO: Barzilai-Borwein stepwidth is zero, using deltat " << currentDeltat << " instead."); 108 PositionUpdate = currentDeltat * currentGradient; 109 } 100 110 LOG(3, "DEBUG: Update would be " << PositionUpdate); 101 111
Note:
See TracChangeset
for help on using the changeset viewer.