source: src/Dynamics/MinimiseConstrainedPotential.cpp@ 8009ce

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 8009ce was 9e23a3, checked in by Frederik Heber <heber@…>, 14 years ago

Rewrote MinimiseConstrainedPotential into a functor in Dynamics/.

  • Property mode set to 100644
File size: 18.9 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * MinimiseConstrainedPotential.cpp
10 *
11 * Created on: Feb 23, 2011
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include <gsl/gsl_matrix.h>
23#include <gsl/gsl_vector.h>
24#include <gsl/gsl_linalg.h>
25
26#include "atom.hpp"
27#include "config.hpp"
28#include "element.hpp"
29#include "CodePatterns/enumeration.hpp"
30#include "CodePatterns/Info.hpp"
31#include "CodePatterns/Verbose.hpp"
32#include "CodePatterns/Log.hpp"
33#include "molecule.hpp"
34#include "parser.hpp"
35#include "LinearAlgebra/Plane.hpp"
36#include "World.hpp"
37
38#include "Dynamics/MinimiseConstrainedPotential.hpp"
39
40
41MinimiseConstrainedPotential::MinimiseConstrainedPotential(molecule::atomSet &_atoms) :
42 atoms(_atoms)
43{}
44
45MinimiseConstrainedPotential::~MinimiseConstrainedPotential()
46{}
47
48double MinimiseConstrainedPotential::operator()(atom **&PermutationMap, int _startstep, int _endstep, bool IsAngstroem)
49{
50 double Potential, OldPotential, OlderPotential;
51 PermutationMap = new atom *[atoms.size()];
52 DistanceList = new DistanceMap *[atoms.size()];
53 DistanceIterators = new DistanceMap::iterator[atoms.size()];
54 DoubleList = new int[atoms.size()];
55 StepList = new DistanceMap::iterator[atoms.size()];
56 int round;
57 atom *Sprinter = NULL;
58 DistanceMap::iterator Rider, Strider;
59
60 // set to zero
61 for (size_t i=0;i<atoms.size();i++) {
62 PermutationMap[i] = NULL;
63 DoubleList[i] = 0;
64 }
65
66 /// Minimise the potential
67 // set Lagrange multiplier constants
68 PenaltyConstants[0] = 10.;
69 PenaltyConstants[1] = 1.;
70 PenaltyConstants[2] = 1e+7; // just a huge penalty
71 // generate the distance list
72 DoLog(1) && (Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl);
73 FillDistanceList();
74
75 // create the initial PermutationMap (source -> target)
76 CreateInitialLists();
77
78 // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it
79 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
80 MakeInjectivePermutation();
81 delete[](DoubleList);
82
83 // argument minimise the constrained potential in this injective PermutationMap
84 DoLog(1) && (Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl);
85 OldPotential = 1e+10;
86 round = 0;
87 do {
88 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
89 OlderPotential = OldPotential;
90 molecule::atomSet::const_iterator iter;
91 do {
92 iter = atoms.begin();
93 for (; iter != atoms.end(); ++iter) {
94 PrintPermutationMap();
95 Sprinter = DistanceIterators[(*iter)->getNr()]->second; // store initial partner
96 Strider = DistanceIterators[(*iter)->getNr()]; //remember old iterator
97 DistanceIterators[(*iter)->getNr()] = StepList[(*iter)->getNr()];
98 if (DistanceIterators[(*iter)->getNr()] == DistanceList[(*iter)->getNr()]->end()) {// stop, before we run through the list and still on
99 DistanceIterators[(*iter)->getNr()] == DistanceList[(*iter)->getNr()]->begin();
100 break;
101 }
102 //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->getNr()]->second << "." << endl;
103 // find source of the new target
104 molecule::atomSet::const_iterator runner = atoms.begin();
105 for (; runner != atoms.end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
106 if (PermutationMap[(*runner)->getNr()] == DistanceIterators[(*iter)->getNr()]->second) {
107 //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->getNr()] << "." << endl;
108 break;
109 }
110 }
111 if (runner != atoms.end()) { // we found the other source
112 // then look in its distance list for Sprinter
113 Rider = DistanceList[(*runner)->getNr()]->begin();
114 for (; Rider != DistanceList[(*runner)->getNr()]->end(); Rider++)
115 if (Rider->second == Sprinter)
116 break;
117 if (Rider != DistanceList[(*runner)->getNr()]->end()) { // if we have found one
118 //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->getNr()] << "/" << *Rider->second << "." << endl;
119 // exchange both
120 PermutationMap[(*iter)->getNr()] = DistanceIterators[(*iter)->getNr()]->second; // put next farther distance into PermutationMap
121 PermutationMap[(*runner)->getNr()] = Sprinter; // and hand the old target to its respective owner
122 PrintPermutationMap();
123 // calculate the new potential
124 //Log() << Verbose(2) << "Checking new potential ..." << endl;
125 Potential = ConstrainedPotential();
126 if (Potential > OldPotential) { // we made everything worse! Undo ...
127 //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
128 //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *DistanceIterators[(*runner)->getNr()]->second << "." << endl;
129 // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
130 PermutationMap[(*runner)->getNr()] = DistanceIterators[(*runner)->getNr()]->second;
131 // Undo for Walker
132 DistanceIterators[(*iter)->getNr()] = Strider; // take next farther distance target
133 //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *DistanceIterators[(*iter)->getNr()]->second << "." << endl;
134 PermutationMap[(*iter)->getNr()] = DistanceIterators[(*iter)->getNr()]->second;
135 } else {
136 DistanceIterators[(*runner)->getNr()] = Rider; // if successful also move the pointer in the iterator list
137 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
138 OldPotential = Potential;
139 }
140 if (Potential > PenaltyConstants[2]) {
141 DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl);
142 exit(255);
143 }
144 //Log() << Verbose(0) << endl;
145 } else {
146 DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl);
147 exit(255);
148 }
149 } else {
150 PermutationMap[(*iter)->getNr()] = DistanceIterators[(*iter)->getNr()]->second; // new target has no source!
151 }
152 StepList[(*iter)->getNr()]++; // take next farther distance target
153 }
154 } while (++iter != atoms.end());
155 } while ((OlderPotential - OldPotential) > 1e-3);
156 DoLog(1) && (Log() << Verbose(1) << "done." << endl);
157
158
159 /// free memory and return with evaluated potential
160 for (int i=atoms.size(); i--;)
161 DistanceList[i]->clear();
162 delete[](DistanceList);
163 delete[](DistanceIterators);
164 return ConstrainedPotential();
165};
166
167void MinimiseConstrainedPotential::FillDistanceList()
168{
169 for (int i=atoms.size(); i--;) {
170 DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom
171 DistanceList[i]->clear();
172 }
173
174 for (molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
175 for (molecule::atomSet::const_iterator runner = atoms.begin(); runner != atoms.end(); ++runner) {
176 DistanceList[(*iter)->getNr()]->insert( DistancePair((*iter)->getPositionAtStep(startstep).distance((*runner)->getPositionAtStep(endstep)), (*runner)) );
177 }
178 }
179};
180
181void MinimiseConstrainedPotential::CreateInitialLists()
182{
183 for (molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
184 StepList[(*iter)->getNr()] = DistanceList[(*iter)->getNr()]->begin(); // stores the step to the next iterator that could be a possible next target
185 PermutationMap[(*iter)->getNr()] = DistanceList[(*iter)->getNr()]->begin()->second; // always pick target with the smallest distance
186 DoubleList[DistanceList[(*iter)->getNr()]->begin()->second->getNr()]++; // increase this target's source count (>1? not injective)
187 DistanceIterators[(*iter)->getNr()] = DistanceList[(*iter)->getNr()]->begin(); // and remember which one we picked
188 DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << DistanceList[(*iter)->getNr()]->begin()->first << "." << endl);
189 }
190};
191
192void MinimiseConstrainedPotential::MakeInjectivePermutation()
193{
194 molecule::atomSet::const_iterator iter = atoms.begin();
195 DistanceMap::iterator NewBase;
196 double Potential = fabs(ConstrainedPotential());
197
198 if (atoms.empty()) {
199 eLog() << Verbose(1) << "Molecule is empty." << endl;
200 return;
201 }
202 while ((Potential) > PenaltyConstants[2]) {
203 PrintPermutationMap();
204 iter++;
205 if (iter == atoms.end()) // round-robin at the end
206 iter = atoms.begin();
207 if (DoubleList[DistanceIterators[(*iter)->getNr()]->second->getNr()] <= 1) // no need to make those injective that aren't
208 continue;
209 // now, try finding a new one
210 Potential = TryNextNearestNeighbourForInjectivePermutation((*iter), Potential);
211 }
212 for (int i=atoms.size(); i--;) // now each single entry in the DoubleList should be <=1
213 if (DoubleList[i] > 1) {
214 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
215 performCriticalExit();
216 }
217 DoLog(1) && (Log() << Verbose(1) << "done." << endl);
218};
219
220void MinimiseConstrainedPotential::PrintPermutationMap() const
221{
222 stringstream zeile1, zeile2;
223 const int AtomCount = atoms.size();
224 int *DoubleList = new int[AtomCount];
225 for(int i=0;i<AtomCount;i++)
226 DoubleList[i] = 0;
227 int doubles = 0;
228 zeile1 << "PermutationMap: ";
229 zeile2 << " ";
230 for (int i=0;i<AtomCount;i++) {
231 DoubleList[PermutationMap[i]->getNr()]++;
232 zeile1 << i << " ";
233 zeile2 << PermutationMap[i]->getNr() << " ";
234 }
235 for (int i=0;i<AtomCount;i++)
236 if (DoubleList[i] > 1)
237 doubles++;
238 if (doubles >0)
239 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
240 delete[](DoubleList);
241// Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
242};
243
244double MinimiseConstrainedPotential::ConstrainedPotential()
245{
246 double tmp = 0.;
247 double result = 0.;
248 // go through every atom
249 atom *Runner = NULL;
250 for (molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
251 // first term: distance to target
252 Runner = PermutationMap[(*iter)->getNr()]; // find target point
253 tmp = ((*iter)->getPositionAtStep(startstep).distance(Runner->getPositionAtStep(endstep)));
254 tmp *= IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
255 result += PenaltyConstants[0] * tmp;
256 //Log() << Verbose(4) << "Adding " << tmp*constants[0] << "." << endl;
257
258 // second term: sum of distances to other trajectories
259 result += SumDistanceOfTrajectories((*iter));
260
261 // third term: penalty for equal targets
262 result += PenalizeEqualTargets((*iter));
263 }
264
265 return result;
266};
267
268double MinimiseConstrainedPotential::TryNextNearestNeighbourForInjectivePermutation(atom *Walker, double &OldPotential)
269{
270 double Potential = 0;
271 DistanceMap::iterator NewBase = DistanceIterators[Walker->getNr()]; // store old base
272 do {
273 NewBase++; // take next further distance in distance to targets list that's a target of no one
274 } while ((DoubleList[NewBase->second->getNr()] != 0) && (NewBase != DistanceList[Walker->getNr()]->end()));
275 if (NewBase != DistanceList[Walker->getNr()]->end()) {
276 PermutationMap[Walker->getNr()] = NewBase->second;
277 Potential = fabs(ConstrainedPotential());
278 if (Potential > OldPotential) { // undo
279 PermutationMap[Walker->getNr()] = DistanceIterators[Walker->getNr()]->second;
280 } else { // do
281 DoubleList[DistanceIterators[Walker->getNr()]->second->getNr()]--; // decrease the old entry in the doubles list
282 DoubleList[NewBase->second->getNr()]++; // increase the old entry in the doubles list
283 DistanceIterators[Walker->getNr()] = NewBase;
284 OldPotential = Potential;
285 DoLog(3) && (Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl);
286 }
287 }
288 return Potential;
289};
290
291double MinimiseConstrainedPotential::PenalizeEqualTargets(atom *Walker)
292{
293 double result = 0.;
294 for (molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
295 if ((PermutationMap[Walker->getNr()] == PermutationMap[(*iter)->getNr()]) && (Walker->getNr() < (*iter)->getNr())) {
296 // atom *Sprinter = PermutationMap[Walker->nr];
297 // Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
298 // Log() << Verbose(0) << Sprinter->getPosition(endstep);
299 // Log() << Verbose(0) << ", penalting." << endl;
300 result += PenaltyConstants[2];
301 //Log() << Verbose(4) << "Adding " << constants[2] << "." << endl;
302 }
303 }
304 return result;
305};
306
307double MinimiseConstrainedPotential::SumDistanceOfTrajectories(atom *Walker)
308{
309 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
310 gsl_vector *x = gsl_vector_alloc(NDIM);
311 atom *Sprinter = NULL;
312 Vector trajectory1, trajectory2, normal, TestVector;
313 double Norm1, Norm2, tmp, result = 0.;
314
315 for (molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
316 if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
317 break;
318 // determine normalized trajectories direction vector (n1, n2)
319 Sprinter = PermutationMap[Walker->getNr()]; // find first target point
320 trajectory1 = Sprinter->getPositionAtStep(endstep) - Walker->getPositionAtStep(startstep);
321 trajectory1.Normalize();
322 Norm1 = trajectory1.Norm();
323 Sprinter = PermutationMap[(*iter)->getNr()]; // find second target point
324 trajectory2 = Sprinter->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep);
325 trajectory2.Normalize();
326 Norm2 = trajectory1.Norm();
327 // check whether either is zero()
328 if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
329 tmp = Walker->getPositionAtStep(startstep).distance((*iter)->getPositionAtStep(startstep));
330 } else if (Norm1 < MYEPSILON) {
331 Sprinter = PermutationMap[Walker->getNr()]; // find first target point
332 trajectory1 = Sprinter->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep);
333 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
334 trajectory1 -= trajectory2; // project the part in norm direction away
335 tmp = trajectory1.Norm(); // remaining norm is distance
336 } else if (Norm2 < MYEPSILON) {
337 Sprinter = PermutationMap[(*iter)->getNr()]; // find second target point
338 trajectory2 = Sprinter->getPositionAtStep(endstep) - Walker->getPositionAtStep(startstep); // copy second offset
339 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
340 trajectory2 -= trajectory1; // project the part in norm direction away
341 tmp = trajectory2.Norm(); // remaining norm is distance
342 } else if ((fabs(trajectory1.ScalarProduct(trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent
343 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: ";
344 // Log() << Verbose(0) << trajectory1;
345 // Log() << Verbose(0) << " and ";
346 // Log() << Verbose(0) << trajectory2;
347 tmp = Walker->getPositionAtStep(startstep).distance((*iter)->getPositionAtStep(startstep));
348 // Log() << Verbose(0) << " with distance " << tmp << "." << endl;
349 } else { // determine distance by finding minimum distance
350 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
351 // Log() << Verbose(0) << endl;
352 // Log() << Verbose(0) << "First Trajectory: ";
353 // Log() << Verbose(0) << trajectory1 << endl;
354 // Log() << Verbose(0) << "Second Trajectory: ";
355 // Log() << Verbose(0) << trajectory2 << endl;
356 // determine normal vector for both
357 normal = Plane(trajectory1, trajectory2,0).getNormal();
358 // print all vectors for debugging
359 // Log() << Verbose(0) << "Normal vector in between: ";
360 // Log() << Verbose(0) << normal << endl;
361 // setup matrix
362 for (int i=NDIM;i--;) {
363 gsl_matrix_set(A, 0, i, trajectory1[i]);
364 gsl_matrix_set(A, 1, i, trajectory2[i]);
365 gsl_matrix_set(A, 2, i, normal[i]);
366 gsl_vector_set(x,i, (Walker->getPositionAtStep(startstep)[i] - (*iter)->getPositionAtStep(startstep)[i]));
367 }
368 // solve the linear system by Householder transformations
369 gsl_linalg_HH_svx(A, x);
370 // distance from last component
371 tmp = gsl_vector_get(x,2);
372 // Log() << Verbose(0) << " with distance " << tmp << "." << endl;
373 // test whether we really have the intersection (by checking on c_1 and c_2)
374 trajectory1.Scale(gsl_vector_get(x,0));
375 trajectory2.Scale(gsl_vector_get(x,1));
376 normal.Scale(gsl_vector_get(x,2));
377 TestVector = (*iter)->getPositionAtStep(startstep) + trajectory2 + normal
378 - (Walker->getPositionAtStep(startstep) + trajectory1);
379 if (TestVector.Norm() < MYEPSILON) {
380 // Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl;
381 } else {
382 // Log() << Verbose(2) << "Test: failed.\tIntersection is off by ";
383 // Log() << Verbose(0) << TestVector;
384 // Log() << Verbose(0) << "." << endl;
385 }
386 }
387 // add up
388 tmp *= IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
389 if (fabs(tmp) > MYEPSILON) {
390 result += PenaltyConstants[1] * 1./tmp;
391 //Log() << Verbose(4) << "Adding " << 1./tmp*constants[1] << "." << endl;
392 }
393 }
394 return result;
395};
396
397void MinimiseConstrainedPotential::EvaluateConstrainedForces(ForceMatrix *Force)
398{
399 double constant = 10.;
400
401 /// evaluate forces (only the distance to target dependent part) with the final PermutationMap
402 DoLog(1) && (Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl);
403 for(molecule::atomSet::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
404 atom *Sprinter = PermutationMap[(*iter)->getNr()];
405 // set forces
406 for (int i=NDIM;i++;)
407 Force->Matrix[0][(*iter)->getNr()][5+i] += 2.*constant*sqrt((*iter)->getPositionAtStep(startstep).distance(Sprinter->getPositionAtStep(endstep)));
408 }
409 DoLog(1) && (Log() << Verbose(1) << "done." << endl);
410};
411
Note: See TracBrowser for help on using the repository browser.