source: src/Dynamics/ForceAnnealing.hpp@ f433ec

AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Exclude_Hydrogens_annealWithBondGraph ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity PythonUI_with_named_parameters StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since f433ec was f433ec, checked in by Frederik Heber <frederik.heber@…>, 7 years ago

We now obtain weights via levmar minimization.

  • this should yield the best possible weights within the interval of [1/n,1.].
  • note that we cannot always get an exact solution because of this constraint.
  • Property mode set to 100644
File size: 23.6 KB
Line 
1/*
2 * ForceAnnealing.hpp
3 *
4 * Created on: Aug 02, 2014
5 * Author: heber
6 */
7
8#ifndef FORCEANNEALING_HPP_
9#define FORCEANNEALING_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <algorithm>
17#include <functional>
18#include <iterator>
19
20#include <boost/bind.hpp>
21
22#include "Atom/atom.hpp"
23#include "Atom/AtomSet.hpp"
24#include "CodePatterns/Assert.hpp"
25#include "CodePatterns/Info.hpp"
26#include "CodePatterns/Log.hpp"
27#include "CodePatterns/Verbose.hpp"
28#include "Descriptors/AtomIdDescriptor.hpp"
29#include "Dynamics/AtomicForceManipulator.hpp"
30#include "Dynamics/BondVectors.hpp"
31#include "Fragmentation/ForceMatrix.hpp"
32#include "Graph/BoostGraphCreator.hpp"
33#include "Graph/BoostGraphHelpers.hpp"
34#include "Graph/BreadthFirstSearchGatherer.hpp"
35#include "Helpers/helpers.hpp"
36#include "Helpers/defs.hpp"
37#include "LinearAlgebra/LinearSystemOfEquations.hpp"
38#include "LinearAlgebra/MatrixContent.hpp"
39#include "LinearAlgebra/Vector.hpp"
40#include "LinearAlgebra/VectorContent.hpp"
41#include "Thermostats/ThermoStatContainer.hpp"
42#include "Thermostats/Thermostat.hpp"
43#include "World.hpp"
44
45/** This class is the essential build block for performing structural optimization.
46 *
47 * Sadly, we have to use some static instances as so far values cannot be passed
48 * between actions. Hence, we need to store the current step and the adaptive-
49 * step width (we cannot perform a line search, as we have no control over the
50 * calculation of the forces).
51 *
52 * However, we do use the bond graph, i.e. if a single atom needs to be shifted
53 * to the left, then the whole molecule left of it is shifted, too. This is
54 * controlled by the \a max_distance parameter.
55 */
56template <class T>
57class ForceAnnealing : public AtomicForceManipulator<T>
58{
59public:
60 /** Constructor of class ForceAnnealing.
61 *
62 * \note We use a fixed delta t of 1.
63 *
64 * \param _atoms set of atoms to integrate
65 * \param _Deltat time step width in atomic units
66 * \param _IsAngstroem whether length units are in angstroem or bohr radii
67 * \param _maxSteps number of optimization steps to perform
68 * \param _max_distance up to this bond order is bond graph taken into account.
69 */
70 ForceAnnealing(
71 AtomSetMixin<T> &_atoms,
72 const double _Deltat,
73 bool _IsAngstroem,
74 const size_t _maxSteps,
75 const int _max_distance,
76 const double _damping_factor) :
77 AtomicForceManipulator<T>(_atoms, _Deltat, _IsAngstroem),
78 maxSteps(_maxSteps),
79 max_distance(_max_distance),
80 damping_factor(_damping_factor)
81 {}
82
83 /** Destructor of class ForceAnnealing.
84 *
85 */
86 ~ForceAnnealing()
87 {}
88
89 /** Performs Gradient optimization.
90 *
91 * We assume that forces have just been calculated.
92 *
93 *
94 * \param CurrentTimeStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
95 * \param offset offset in matrix file to the first force component
96 * \todo This is not yet checked if it is correctly working with DoConstrainedMD set >0.
97 */
98 void operator()(
99 const int _CurrentTimeStep,
100 const size_t _offset,
101 const bool _UseBondgraph)
102 {
103 // make sum of forces equal zero
104 AtomicForceManipulator<T>::correctForceMatrixForFixedCenterOfMass(
105 _offset,
106 _CurrentTimeStep-1>=0 ? _CurrentTimeStep - 1 : 0);
107
108 // are we in initial step? Then set static entities
109 Vector maxComponents(zeroVec);
110 if (currentStep == 0) {
111 currentDeltat = AtomicForceManipulator<T>::Deltat;
112 currentStep = 1;
113 LOG(2, "DEBUG: Initial step, setting values, current step is #" << currentStep);
114
115 // always use atomic annealing on first step
116 anneal(_CurrentTimeStep, _offset, maxComponents);
117 } else {
118 ++currentStep;
119 LOG(2, "DEBUG: current step is #" << currentStep);
120
121 // bond graph annealing is always followed by a normal annealing
122 if (_UseBondgraph)
123 annealWithBondGraph(_CurrentTimeStep, _offset, maxComponents);
124 anneal(_CurrentTimeStep, _offset, maxComponents);
125 }
126
127
128 LOG(1, "STATUS: Largest remaining force components at step #"
129 << currentStep << " are " << maxComponents);
130
131 // are we in final step? Remember to reset static entities
132 if (currentStep == maxSteps) {
133 LOG(2, "DEBUG: Final step, resetting values");
134 reset();
135 }
136 }
137
138 /** Helper function to calculate the Barzilai-Borwein stepwidth.
139 *
140 * \param _PositionDifference difference in position between current and last step
141 * \param _GradientDifference difference in gradient between current and last step
142 * \return step width according to Barzilai-Borwein
143 */
144 double getBarzilaiBorweinStepwidth(const Vector &_PositionDifference, const Vector &_GradientDifference)
145 {
146 double stepwidth = 0.;
147 if (_GradientDifference.NormSquared() > MYEPSILON)
148 stepwidth = fabs(_PositionDifference.ScalarProduct(_GradientDifference))/
149 _GradientDifference.NormSquared();
150 if (fabs(stepwidth) < 1e-10) {
151 // dont' warn in first step, deltat usage normal
152 if (currentStep != 1)
153 ELOG(1, "INFO: Barzilai-Borwein stepwidth is zero, using deltat " << currentDeltat << " instead.");
154 stepwidth = currentDeltat;
155 }
156 return stepwidth;
157 }
158
159 /** Performs Gradient optimization on the atoms.
160 *
161 * We assume that forces have just been calculated.
162 *
163 * \param CurrentTimeStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
164 * \param offset offset in matrix file to the first force component
165 * \param maxComponents to be filled with maximum force component over all atoms
166 */
167 void anneal(
168 const int CurrentTimeStep,
169 const size_t offset,
170 Vector &maxComponents)
171 {
172 bool deltat_decreased = false;
173 for(typename AtomSetMixin<T>::iterator iter = AtomicForceManipulator<T>::atoms.begin();
174 iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
175 // atom's force vector gives steepest descent direction
176 const Vector oldPosition = (*iter)->getPositionAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
177 const Vector currentPosition = (*iter)->getPositionAtStep(CurrentTimeStep);
178 const Vector oldGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0);
179 const Vector currentGradient = (*iter)->getAtomicForceAtStep(CurrentTimeStep);
180 LOG(4, "DEBUG: oldPosition for atom " << **iter << " is " << oldPosition);
181 LOG(4, "DEBUG: currentPosition for atom " << **iter << " is " << currentPosition);
182 LOG(4, "DEBUG: oldGradient for atom " << **iter << " is " << oldGradient);
183 LOG(4, "DEBUG: currentGradient for atom " << **iter << " is " << currentGradient);
184// LOG(4, "DEBUG: Force for atom " << **iter << " is " << currentGradient);
185
186 // we use Barzilai-Borwein update with position reversed to get descent
187 const double stepwidth = getBarzilaiBorweinStepwidth(
188 currentPosition - oldPosition, currentGradient - oldGradient);
189 Vector PositionUpdate = stepwidth * currentGradient;
190 LOG(3, "DEBUG: Update would be " << stepwidth << "*" << currentGradient << " = " << PositionUpdate);
191
192 // extract largest components for showing progress of annealing
193 for(size_t i=0;i<NDIM;++i)
194 maxComponents[i] = std::max(maxComponents[i], fabs(currentGradient[i]));
195
196 // steps may go back and forth again (updates are of same magnitude but
197 // have different sign: Check whether this is the case and one step with
198 // deltat to interrupt this sequence
199 const Vector PositionDifference = currentPosition - oldPosition;
200 if ((currentStep > 1) && (!PositionDifference.IsZero()))
201 if ((PositionUpdate.ScalarProduct(PositionDifference) < 0)
202 && (fabs(PositionUpdate.NormSquared()-PositionDifference.NormSquared()) < 1e-3)) {
203 // for convergence we want a null sequence here, too
204 if (!deltat_decreased) {
205 deltat_decreased = true;
206 currentDeltat = .5*currentDeltat;
207 }
208 LOG(2, "DEBUG: Upgrade in other direction: " << PositionUpdate
209 << " > " << PositionDifference
210 << ", using deltat: " << currentDeltat);
211 PositionUpdate = currentDeltat * currentGradient;
212 }
213
214 // finally set new values
215 (*iter)->setPosition(currentPosition + PositionUpdate);
216 }
217 }
218
219 // knowing the number of bonds in total, we can setup the storage for the
220 // projected forces
221 enum whichatom_t {
222 leftside=0,
223 rightside=1,
224 MAX_sides
225 };
226
227 /** Helper function to put bond force into a container.
228 *
229 * \param _walker atom
230 * \param _current_bond current bond of \a _walker
231 * \param _timestep time step
232 * \param _force calculated bond force
233 * \param _bv bondvectors for obtaining the correct index
234 * \param _projected_forces container
235 */
236 static void ForceStore(
237 const atom &_walker,
238 const bond::ptr &_current_bond,
239 const size_t &_timestep,
240 const double _force,
241 const BondVectors &_bv,
242 std::vector< // time step
243 std::vector< // which bond side
244 std::vector<double> > // over all bonds
245 > &_projected_forces)
246 {
247 std::vector<double> &forcelist = (&_walker == _current_bond->leftatom) ?
248 _projected_forces[_timestep][leftside] : _projected_forces[_timestep][rightside];
249 const size_t index = _bv.getIndexForBond(_current_bond);
250 ASSERT( index != (size_t)-1,
251 "ForceAnnealing() - could not find bond "+toString(*_current_bond)
252 +" in bondvectors");
253 forcelist[index] = _force;
254 }
255
256 /** Performs Gradient optimization on the bonds.
257 *
258 * We assume that forces have just been calculated. These forces are projected
259 * onto the bonds and these are annealed subsequently by moving atoms in the
260 * bond neighborhood on either side conjunctively.
261 *
262 *
263 * \param CurrentTimeStep current time step (i.e. \f$ t + \Delta t \f$ in the sense of the velocity verlet)
264 * \param offset offset in matrix file to the first force component
265 * \param maxComponents to be filled with maximum force component over all atoms
266 */
267 void annealWithBondGraph(
268 const int CurrentTimeStep,
269 const size_t offset,
270 Vector &maxComponents)
271 {
272 // get nodes on either side of selected bond via BFS discovery
273 BoostGraphCreator BGcreator;
274 BGcreator.createFromRange(
275 AtomicForceManipulator<T>::atoms.begin(),
276 AtomicForceManipulator<T>::atoms.end(),
277 AtomicForceManipulator<T>::atoms.size(),
278 BreadthFirstSearchGatherer::AlwaysTruePredicate);
279 BreadthFirstSearchGatherer NodeGatherer(BGcreator);
280
281 /// We assume that a force is local, i.e. a bond is too short yet and hence
282 /// the atom needs to be moved. However, all the adjacent (bound) atoms might
283 /// already be at the perfect distance. If we just move the atom alone, we ruin
284 /// all the other bonds. Hence, it would be sensible to move every atom found
285 /// through the bond graph in the direction of the force as well by the same
286 /// PositionUpdate. This is almost what we are going to do.
287
288 /// One issue is: If we need to shorten bond, then we use the PositionUpdate
289 /// also on the the other bond partner already. This is because it is in the
290 /// direction of the bond. Therefore, the update is actually performed twice on
291 /// each bond partner, i.e. the step size is twice as large as it should be.
292 /// This problem only occurs when bonds need to be shortened, not when they
293 /// need to be made longer (then the force vector is facing the other
294 /// direction than the bond vector).
295 /// As a remedy we need to average the force on either end of the bond and
296 /// check whether each gradient points inwards out or outwards with respect
297 /// to the bond and then shift accordingly.
298
299 /// One more issue is that the projection onto the bond directions does not
300 /// recover the gradient but may be larger as the bond directions are a
301 /// generating system and not a basis (e.g. 3 bonds on a plane where 2 would
302 /// suffice to span the plane). To this end, we need to account for the
303 /// overestimation and obtain a weighting for each bond.
304
305 // initialize helper class for bond vectors using bonds from range of atoms
306 BondVectors bv;
307 bv.setFromAtomRange< T >(
308 AtomicForceManipulator<T>::atoms.begin(),
309 AtomicForceManipulator<T>::atoms.end(),
310 CurrentTimeStep);
311 const BondVectors::container_t &sorted_bonds = bv.getSorted();
312
313 std::vector< // time step
314 std::vector< // which bond side
315 std::vector<double> > // over all bonds
316 > projected_forces(2); // one for leftatoms, one for rightatoms (and for both time steps)
317 for (size_t i=0;i<2;++i) {
318 projected_forces[i].resize(MAX_sides);
319 for (size_t j=0;j<MAX_sides;++j)
320 projected_forces[i][j].resize(sorted_bonds.size(), 0.);
321 }
322
323 // for each atom we need to gather weights and then project the gradient
324 typedef std::map<atomId_t, BondVectors::weights_t > weights_per_atom_t;
325 std::vector<weights_per_atom_t> weights_per_atom(2);
326 typedef std::map<atomId_t, Vector> RemnantGradient_per_atom_t;
327 RemnantGradient_per_atom_t RemnantGradient_per_atom;
328 for (size_t timestep = 0; timestep <= 1; ++timestep) {
329 const size_t CurrentStep = CurrentTimeStep-timestep-1 >= 0 ? CurrentTimeStep-timestep-1 : 0;
330 LOG(2, "DEBUG: CurrentTimeStep is " << CurrentTimeStep
331 << ", timestep is " << timestep
332 << ", and CurrentStep is " << CurrentStep);
333
334 for(typename AtomSetMixin<T>::const_iterator iter = AtomicForceManipulator<T>::atoms.begin();
335 iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
336 const atom &walker = *(*iter);
337 const Vector &walkerGradient = walker.getAtomicForceAtStep(CurrentStep);
338 LOG(3, "DEBUG: Gradient of atom #" << walker.getId() << ", namely "
339 << walker << " is " << walkerGradient << " with magnitude of "
340 << walkerGradient.Norm());
341
342 const BondList& ListOfBonds = walker.getListOfBonds();
343 if (walkerGradient.Norm() > MYEPSILON) {
344
345 // gather subset of BondVectors for the current atom
346 const std::vector<Vector> BondVectors =
347 bv.getAtomsBondVectorsAtStep(walker, CurrentStep);
348
349 // go through all its bonds and calculate what magnitude is represented
350 // by the others i.e. sum of scalar products against other bonds
351 const std::pair<weights_per_atom_t::iterator, bool> inserter =
352 weights_per_atom[timestep].insert(
353 std::make_pair(walker.getId(),
354 bv.getWeightsForAtomAtStep(walker, BondVectors, CurrentStep)) );
355 ASSERT( inserter.second,
356 "ForceAnnealing::operator() - weight map for atom "+toString(walker)
357 +" and time step "+toString(timestep)+" already filled?");
358 BondVectors::weights_t &weights = inserter.first->second;
359 ASSERT( weights.size() == ListOfBonds.size(),
360 "ForceAnnealing::operator() - number of weights "
361 +toString(weights.size())+" does not match number of bonds "
362 +toString(ListOfBonds.size())+", error in calculation?");
363
364 // projected gradient over all bonds and place in one of projected_forces
365 // using the obtained weights
366 BondVectors::forcestore_t forcestoring =
367 boost::bind(&ForceAnnealing::ForceStore, _1, _2, _3, _4,
368 boost::cref(bv), boost::ref(projected_forces));
369 const Vector RemnantGradient = bv.getRemnantGradientForAtomAtStep(
370 walker, BondVectors, weights, timestep, forcestoring
371 );
372 RemnantGradient_per_atom.insert( std::make_pair(walker.getId(), RemnantGradient) );
373 } else {
374 LOG(2, "DEBUG: Gradient is " << walkerGradient << " less than "
375 << MYEPSILON << " for atom " << walker);
376 // note that projected_forces is initialized to full length and filled
377 // with zeros. Hence, nothing to do here
378 }
379 }
380 }
381
382 // step through each bond and shift the atoms
383 std::map<atomId_t, Vector> GatheredUpdates; //!< gathers all updates which are applied at the end
384
385 LOG(3, "DEBUG: current step is " << currentStep << ", given time step is " << CurrentTimeStep);
386 const BondVectors::mapped_t bondvectors = bv.getBondVectorsAtStep(CurrentTimeStep);
387
388 for (BondVectors::container_t::const_iterator bondsiter = sorted_bonds.begin();
389 bondsiter != sorted_bonds.end(); ++bondsiter) {
390 const bond::ptr &current_bond = *bondsiter;
391 const size_t index = bv.getIndexForBond(current_bond);
392 const atom* bondatom[MAX_sides] = {
393 current_bond->leftatom,
394 current_bond->rightatom
395 };
396
397 // remove the edge
398#ifndef NDEBUG
399 const bool status =
400#endif
401 BGcreator.removeEdge(bondatom[leftside]->getId(), bondatom[rightside]->getId());
402 ASSERT( status, "ForceAnnealing() - edge to found bond is not present?");
403
404 // gather nodes for either atom
405 BoostGraphHelpers::Nodeset_t bondside_set[MAX_sides];
406 BreadthFirstSearchGatherer::distance_map_t distance_map[MAX_sides];
407 for (size_t side=leftside;side<MAX_sides;++side) {
408 bondside_set[side] = NodeGatherer(bondatom[side]->getId(), max_distance);
409 distance_map[side] = NodeGatherer.getDistances();
410 std::sort(bondside_set[side].begin(), bondside_set[side].end());
411 }
412
413 // re-add edge
414 BGcreator.addEdge(bondatom[leftside]->getId(), bondatom[rightside]->getId());
415
416 // do for both leftatom and rightatom of bond
417 for (size_t side = leftside; side < MAX_sides; ++side) {
418 const double &bondforce = projected_forces[0][side][index];
419 const double &oldbondforce = projected_forces[1][side][index];
420 const double bondforcedifference = fabs(bondforce - oldbondforce);
421 LOG(4, "DEBUG: bondforce for " << (side == leftside ? "left" : "right")
422 << " side of bond is " << bondforce);
423 LOG(4, "DEBUG: oldbondforce for " << (side == leftside ? "left" : "right")
424 << " side of bond is " << oldbondforce);
425 // if difference or bondforce itself is zero, do nothing
426 if ((fabs(bondforce) < MYEPSILON) || (fabs(bondforcedifference) < MYEPSILON))
427 continue;
428
429 // get BondVector to bond
430 const BondVectors::mapped_t::const_iterator bviter =
431 bondvectors.find(current_bond);
432 ASSERT( bviter != bondvectors.end(),
433 "ForceAnnealing() - cannot find current_bond ?");
434 ASSERT( fabs(bviter->second.Norm() -1.) < MYEPSILON,
435 "ForceAnnealing() - norm of BondVector is not one");
436 const Vector &BondVector = bviter->second;
437
438 // calculate gradient and position differences for stepwidth
439 const Vector currentGradient = bondforce * BondVector;
440 LOG(4, "DEBUG: current projected gradient for "
441 << (side == leftside ? "left" : "right") << " side of bond is " << currentGradient);
442 const Vector &oldPosition = bondatom[side]->getPositionAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0);
443 const Vector &currentPosition = bondatom[side]->getPositionAtStep(CurrentTimeStep-1>=0 ? CurrentTimeStep - 1 : 0);
444 const Vector PositionDifference = currentPosition - oldPosition;
445 LOG(4, "DEBUG: old position is " << oldPosition);
446 LOG(4, "DEBUG: current position is " << currentPosition);
447 LOG(4, "DEBUG: difference in position is " << PositionDifference);
448 LOG(4, "DEBUG: bondvector is " << BondVector);
449 const double projected_PositionDifference = PositionDifference.ScalarProduct(BondVector);
450 LOG(4, "DEBUG: difference in position projected onto bondvector is "
451 << projected_PositionDifference);
452 LOG(4, "DEBUG: abs. difference in forces is " << bondforcedifference);
453
454 // calculate step width
455 double stepwidth =
456 fabs(projected_PositionDifference)/bondforcedifference;
457 if (fabs(stepwidth) < 1e-10) {
458 // dont' warn in first step, deltat usage normal
459 if (currentStep != 1)
460 ELOG(1, "INFO: Barzilai-Borwein stepwidth is zero, using deltat " << currentDeltat << " instead.");
461 stepwidth = currentDeltat;
462 }
463 Vector PositionUpdate = stepwidth * currentGradient;
464 LOG(3, "DEBUG: Update would be " << stepwidth << "*" << currentGradient << " = " << PositionUpdate);
465
466 // add PositionUpdate for all nodes in the bondside_set
467 for (BoostGraphHelpers::Nodeset_t::const_iterator setiter = bondside_set[side].begin();
468 setiter != bondside_set[side].end(); ++setiter) {
469 const BreadthFirstSearchGatherer::distance_map_t::const_iterator diter
470 = distance_map[side].find(*setiter);
471 ASSERT( diter != distance_map[side].end(),
472 "ForceAnnealing() - could not find distance to an atom.");
473 const double factor = pow(damping_factor, diter->second+1);
474 LOG(3, "DEBUG: Update for atom #" << *setiter << " will be "
475 << factor << "*" << PositionUpdate);
476 if (GatheredUpdates.count((*setiter))) {
477 GatheredUpdates[(*setiter)] += factor*PositionUpdate;
478 } else {
479 GatheredUpdates.insert(
480 std::make_pair(
481 (*setiter),
482 factor*PositionUpdate) );
483 }
484 }
485 }
486 }
487
488 for(typename AtomSetMixin<T>::iterator iter = AtomicForceManipulator<T>::atoms.begin();
489 iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
490 atom &walker = *(*iter);
491 // extract largest components for showing progress of annealing
492 const Vector currentGradient = walker.getAtomicForceAtStep(CurrentTimeStep-1>=0 ? CurrentTimeStep-1 : 0);
493 for(size_t i=0;i<NDIM;++i)
494 maxComponents[i] = std::max(maxComponents[i], fabs(currentGradient[i]));
495
496 // reset force vector for next step except on final one
497 if (currentStep != maxSteps)
498 walker.setAtomicForce(zeroVec);
499 }
500
501 // apply the gathered updates and set remnant gradients for atomic annealing
502 for (std::map<atomId_t, Vector>::const_iterator iter = GatheredUpdates.begin();
503 iter != GatheredUpdates.end(); ++iter) {
504 const atomId_t &atomid = iter->first;
505 const Vector &update = iter->second;
506 atom* const walker = World::getInstance().getAtom(AtomById(atomid));
507 ASSERT( walker != NULL,
508 "ForceAnnealing() - walker with id "+toString(atomid)+" has suddenly disappeared.");
509 LOG(3, "DEBUG: Applying update " << update << " to atom #" << atomid
510 << ", namely " << *walker);
511 walker->setPosition(
512 walker->getPositionAtStep(CurrentTimeStep-1>=0 ? CurrentTimeStep - 1 : 0)
513 + update);
514 walker->setAtomicVelocity(update);
515 walker->setAtomicForce( RemnantGradient_per_atom[walker->getId()] );
516 }
517 }
518
519 /** Reset function to unset static entities and artificial velocities.
520 *
521 */
522 void reset()
523 {
524 currentDeltat = 0.;
525 currentStep = 0;
526 }
527
528private:
529 //!> contains the current step in relation to maxsteps
530 static size_t currentStep;
531 //!> contains the maximum number of steps, determines initial and final step with currentStep
532 size_t maxSteps;
533 static double currentDeltat;
534 //!> minimum deltat for internal while loop (adaptive step width)
535 static double MinimumDeltat;
536 //!> contains the maximum bond graph distance up to which shifts of a single atom are spread
537 const int max_distance;
538 //!> the shifted is dampened by this factor with the power of the bond graph distance to the shift causing atom
539 const double damping_factor;
540};
541
542template <class T>
543double ForceAnnealing<T>::currentDeltat = 0.;
544template <class T>
545size_t ForceAnnealing<T>::currentStep = 0;
546template <class T>
547double ForceAnnealing<T>::MinimumDeltat = 1e-8;
548
549#endif /* FORCEANNEALING_HPP_ */
Note: See TracBrowser for help on using the repository browser.