Changeset 1b64b2f
- Timestamp:
- May 8, 2017, 2:04:19 PM (8 years ago)
- Branches:
- ForceAnnealing_goodresults, ForceAnnealing_tocheck
- Children:
- 7ee4b5
- Parents:
- 485eea
- git-author:
- Frederik Heber <heber@…> (04/06/17 05:09:37)
- git-committer:
- Frederik Heber <frederik.heber@…> (05/08/17 14:04:19)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/userguide/userguide.xml
r485eea r1b64b2f 2207 2207 combines the same Actions as <emphasis role="bold">molecular-dynamics</emphasis> does. However, it 2208 2208 uses the <emphasis role="bold">force-annealing</emphasis> action instead of <emphasis role="bold">verlet-integration</emphasis>.</para> 2209 <remark>Because it is a MacroAction we cannot use any more elaborate 2210 line search method during the optimization. In essence, we minimize the 2211 energy function that depends on the nuclei coordinates. The function is 2212 non-linear and non-convex. The best choice, given that we have gradient 2213 information, would be the Conjugate Gradient method (such as Fletcher- 2214 Reeves which work well also for non-linear functions). However, these 2215 methods perform a line search along the gradient direction which we 2216 cannot as our Actions do not contain any internal information (apart 2217 from the state for Undo/Redo). Therefore, we are restricted to the 2218 method of Barzilai-Borwein where no line-search is needed but that also 2219 works well for high-dimensional minimization problems.</remark> 2209 2220 <para>The command below performs a structure optimization of the 2210 2221 currently selected atoms (may also be a subset) for up to 100 time … … 2219 2230 --order 3 \ 2220 2231 --distance 3. \ 2221 --deltat 0.5 \2222 2232 --keep-fixed-CenterOfMass 1 \ 2223 2233 --fragment-executable mpqc \ … … 2227 2237 Otherwise only two time steps would be created: the initial and 2228 2238 the final one containing the optimized structure.</para> 2239 <para>Because of the use of Barzilai-Borwein for computing the 2240 stepwidth we do not need any 'deltat' parameters. If the computed 2241 step width is zero, we use a default step width of 1.</para> 2229 2242 </section> 2230 2243 <section xml:id="dynamics.step-world-time"> -
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r485eea r1b64b2f 92 92 ForceAnnealing<std::vector<atom *> > optimizer( 93 93 set, 94 params.Deltat.get(),95 94 true, 96 95 params.steps.get()); -
src/Actions/MoleculeAction/ForceAnnealingAction.def
r485eea r1b64b2f 16 16 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 17 17 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 18 #define paramtypes (boost::filesystem::path)( double)(unsigned int)(bool)19 #define paramtokens ("forces-file")(" deltat")("steps")("output-every-step")20 #define paramdescriptions ("file containing")(" time step width")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang")21 #define paramdefaults (PARAM_DEFAULT(""))( PARAM_DEFAULT(0.1))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))22 #define paramreferences (forcesfile)( Deltat)(steps)(DoOutput)18 #define paramtypes (boost::filesystem::path)(unsigned int)(bool) 19 #define paramtokens ("forces-file")("steps")("output-every-step") 20 #define paramdescriptions ("file containing")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang") 21 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0")) 22 #define paramreferences (forcesfile)(steps)(DoOutput) 23 23 #define paramvalids \ 24 24 (DummyValidator< boost::filesystem::path >()) \ 25 (PositiveValidator< double >()) \26 25 (NotZeroValidator< unsigned int >()) \ 27 26 (DummyValidator<bool>()) -
src/Dynamics/ForceAnnealing.hpp
r485eea r1b64b2f 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 -
tests/GuiChecks/Molecules/ForceAnnealing/testsuite-molecules-force-annealing.at
r485eea r1b64b2f 25 25 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 26 26 AT_CHECK([chmod u+w $file], 0) 27 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 -- deltat 0.01 --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr])27 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr]) 28 28 AT_CHECK([grep -v "Command.*DryRun" session-molecules-force-annealing.py >session-molecules-force-annealing_new.py], 0, [ignore], [ignore]) 29 29 AT_CHECK([../../molecuilderguitest session-molecules-force-annealing_new.py], 0, [stdout], [stderr]) … … 40 40 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 41 41 AT_CHECK([chmod u+w $file], 0) 42 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 -- deltat 0.01 --undo --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr])42 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --undo --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr]) 43 43 AT_CHECK([grep -v "Command.*DryRun" session-molecules-force-annealing.py >session-molecules-force-annealing_new.py], 0, [ignore], [ignore]) 44 44 AT_CHECK([../../molecuilderguitest session-molecules-force-annealing_new.py], 0, [stdout], [stderr]) … … 55 55 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 56 56 AT_CHECK([chmod u+w $file], 0) 57 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 -- deltat 0.01 --undo --redo --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr])57 AT_CHECK([../../molecuilder --dry-run -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --undo --redo --no-dry-run --store-session session-molecules-force-annealing.py --session-type python], 0, [stdout], [stderr]) 58 58 AT_CHECK([grep -v "Command.*DryRun" session-molecules-force-annealing.py >session-molecules-force-annealing_new.py], 0, [ignore], [ignore]) 59 59 AT_CHECK([../../molecuilderguitest session-molecules-force-annealing_new.py], 0, [stdout], [stderr]) -
tests/regression/Molecules/ForceAnnealing/testsuite-molecules-force-annealing.at
r485eea r1b64b2f 25 25 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 26 26 AT_CHECK([chmod u+w $file], 0) 27 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --deltat 0.01], 0, [stdout], [stderr])27 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1], 0, [stdout], [stderr]) 28 28 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/post/test.conf], 0, [ignore], [ignore]) 29 29 … … 38 38 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 39 39 AT_CHECK([chmod u+w $file], 0) 40 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 -- deltat 0.01 --undo], 0, [stdout], [stderr])40 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --undo], 0, [stdout], [stderr]) 41 41 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/post/test-undo.conf], 0, [ignore], [ignore]) 42 42 … … 51 51 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0) 52 52 AT_CHECK([chmod u+w $file], 0) 53 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 -- deltat 0.01 --undo --redo], 0, [stdout], [stderr])53 AT_CHECK([../../molecuilder -i $file --select-all-atoms --force-annealing --forces-file test.forces --steps 1 --undo --redo], 0, [stdout], [stderr]) 54 54 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/post/test.conf], 0, [ignore], [ignore]) 55 55
Note:
See TracChangeset
for help on using the changeset viewer.