Changeset a7b761b for src/molecule_dynamics.cpp
- Timestamp:
- May 27, 2010, 10:46:54 AM (16 years ago)
- Branches:
- 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, Candidate_v1.7.0, 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
- Children:
- 1024cb
- Parents:
- 8f215d (diff), 05a97c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/molecule_dynamics.cpp (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_dynamics.cpp
r8f215d ra7b761b 28 28 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 29 29 gsl_vector *x = gsl_vector_alloc(NDIM); 30 atom * Runner = mol->start;31 30 atom *Sprinter = NULL; 32 31 Vector trajectory1, trajectory2, normal, TestVector; 33 32 double Norm1, Norm2, tmp, result = 0.; 34 33 35 while (Runner->next != mol->end) { 36 Runner = Runner->next; 37 if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++) 34 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 35 if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++) 38 36 break; 39 37 // determine normalized trajectories direction vector (n1, n2) … … 42 40 trajectory1.Normalize(); 43 41 Norm1 = trajectory1.Norm(); 44 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point45 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);42 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 43 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 46 44 trajectory2.Normalize(); 47 45 Norm2 = trajectory1.Norm(); 48 46 // check whether either is zero() 49 47 if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) { 50 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));48 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 51 49 } else if (Norm1 < MYEPSILON) { 52 50 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 53 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);51 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 54 52 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 55 53 trajectory1 -= trajectory2; // project the part in norm direction away 56 54 tmp = trajectory1.Norm(); // remaining norm is distance 57 55 } else if (Norm2 < MYEPSILON) { 58 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point56 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 59 57 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep); // copy second offset 60 58 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything … … 66 64 // Log() << Verbose(0) << " and "; 67 65 // Log() << Verbose(0) << trajectory2; 68 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));66 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 69 67 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 70 68 } else { // determine distance by finding minimum distance 71 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << * Runner<< " are linear independent ";69 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent "; 72 70 // Log() << Verbose(0) << endl; 73 71 // Log() << Verbose(0) << "First Trajectory: "; … … 85 83 gsl_matrix_set(A, 1, i, trajectory2[i]); 86 84 gsl_matrix_set(A, 2, i, normal[i]); 87 gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));85 gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i])); 88 86 } 89 87 // solve the linear system by Householder transformations … … 96 94 trajectory2.Scale(gsl_vector_get(x,1)); 97 95 normal.Scale(gsl_vector_get(x,2)); 98 TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal96 TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal 99 97 - (Walker->Trajectory.R.at(Params.startstep) + trajectory1); 100 98 if (TestVector.Norm() < MYEPSILON) { … … 125 123 { 126 124 double result = 0.; 127 atom * Runner = mol->start; 128 while (Runner->next != mol->end) { 129 Runner = Runner->next; 130 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) { 125 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 126 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) { 131 127 // atom *Sprinter = PermutationMap[Walker->nr]; 132 // Log() << Verbose(0) << *Walker << " and " << * Runner<< " are heading to the same target at ";128 // Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at "; 133 129 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 134 130 // Log() << Verbose(0) << ", penalting." << endl; … … 161 157 // go through every atom 162 158 atom *Runner = NULL; 163 atom *Walker = start; 164 while (Walker->next != end) { 165 Walker = Walker->next; 159 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 166 160 // first term: distance to target 167 Runner = Params.PermutationMap[ Walker->nr]; // find target point168 tmp = ( Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));161 Runner = Params.PermutationMap[(*iter)->nr]; // find target point 162 tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep))); 169 163 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 170 164 result += Params.PenaltyConstants[0] * tmp; … … 172 166 173 167 // second term: sum of distances to other trajectories 174 result += SumDistanceOfTrajectories( Walker, this, Params);168 result += SumDistanceOfTrajectories((*iter), this, Params); 175 169 176 170 // third term: penalty for equal targets 177 result += PenalizeEqualTargets( Walker, this, Params);171 result += PenalizeEqualTargets((*iter), this, Params); 178 172 } 179 173 … … 213 207 void FillDistanceList(molecule *mol, struct EvaluatePotential &Params) 214 208 { 215 for (int i=mol-> AtomCount; i--;) {209 for (int i=mol->getAtomCount(); i--;) { 216 210 Params.DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom 217 211 Params.DistanceList[i]->clear(); 218 212 } 219 213 220 atom *Runner = NULL; 221 atom *Walker = mol->start; 222 while (Walker->next != mol->end) { 223 Walker = Walker->next; 224 Runner = mol->start; 225 while(Runner->next != mol->end) { 226 Runner = Runner->next; 227 Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)), Runner) ); 214 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 215 for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) { 216 Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) ); 228 217 } 229 218 } … … 237 226 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 238 227 { 239 atom *Walker = mol->start; 240 while (Walker->next != mol->end) { 241 Walker = Walker->next; 242 Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // stores the step to the next iterator that could be a possible next target 243 Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second; // always pick target with the smallest distance 244 Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 245 Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // and remember which one we picked 246 DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl); 228 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 229 Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // stores the step to the next iterator that could be a possible next target 230 Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second; // always pick target with the smallest distance 231 Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 232 Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // and remember which one we picked 233 DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl); 247 234 } 248 235 }; … … 285 272 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 286 273 { 287 atom *Walker = mol->start;274 molecule::const_iterator iter = mol->begin(); 288 275 DistanceMap::iterator NewBase; 289 276 double Potential = fabs(mol->ConstrainedPotential(Params)); 290 277 278 if (mol->empty()) { 279 eLog() << Verbose(1) << "Molecule is empty." << endl; 280 return; 281 } 291 282 while ((Potential) > Params.PenaltyConstants[2]) { 292 PrintPermutationMap(mol-> AtomCount, Params);293 Walker = Walker->next;294 if ( Walker == mol->end) // round-robin at the end295 Walker = mol->start->next;296 if (Params.DoubleList[Params.DistanceIterators[ Walker->nr]->second->nr] <= 1) // no need to make those injective that aren't283 PrintPermutationMap(mol->getAtomCount(), Params); 284 iter++; 285 if (iter == mol->end()) // round-robin at the end 286 iter = mol->begin(); 287 if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1) // no need to make those injective that aren't 297 288 continue; 298 289 // now, try finding a new one 299 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);300 } 301 for (int i=mol-> AtomCount; i--;) // now each single entry in the DoubleList should be <=1290 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 291 } 292 for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1 302 293 if (Params.DoubleList[i] > 1) { 303 294 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); … … 338 329 double Potential, OldPotential, OlderPotential; 339 330 struct EvaluatePotential Params; 340 Params.PermutationMap = Calloc<atom*>( AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");341 Params.DistanceList = Malloc<DistanceMap*>( AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");342 Params.DistanceIterators = Malloc<DistanceMap::iterator>( AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");343 Params.DoubleList = Calloc<int>( AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");344 Params.StepList = Malloc<DistanceMap::iterator>( AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");331 Params.PermutationMap = Calloc<atom*>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.**PermutationMap"); 332 Params.DistanceList = Malloc<DistanceMap*>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.**DistanceList"); 333 Params.DistanceIterators = Malloc<DistanceMap::iterator>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators"); 334 Params.DoubleList = Calloc<int>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*DoubleList"); 335 Params.StepList = Malloc<DistanceMap::iterator>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*StepList"); 345 336 int round; 346 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;337 atom *Sprinter = NULL; 347 338 DistanceMap::iterator Rider, Strider; 348 339 … … 371 362 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 372 363 OlderPotential = OldPotential; 364 molecule::const_iterator iter; 373 365 do { 374 Walker = start; 375 while (Walker->next != end) { // pick one 376 Walker = Walker->next; 377 PrintPermutationMap(AtomCount, Params); 378 Sprinter = Params.DistanceIterators[Walker->nr]->second; // store initial partner 379 Strider = Params.DistanceIterators[Walker->nr]; //remember old iterator 380 Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr]; 381 if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on 382 Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin(); 366 iter = begin(); 367 for (; iter != end(); ++iter) { 368 PrintPermutationMap(getAtomCount(), Params); 369 Sprinter = Params.DistanceIterators[(*iter)->nr]->second; // store initial partner 370 Strider = Params.DistanceIterators[(*iter)->nr]; //remember old iterator 371 Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr]; 372 if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on 373 Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin(); 383 374 break; 384 375 } 385 //Log() << Verbose(2) << "Current Walker: " << * Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;376 //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl; 386 377 // find source of the new target 387 Runner = start->next;388 while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)389 if (Params.PermutationMap[ Runner->nr] == Params.DistanceIterators[Walker->nr]->second) {390 //Log() << Verbose(2) << "Found the corresponding owner " << * Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;378 molecule::const_iterator runner = begin(); 379 for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already) 380 if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) { 381 //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl; 391 382 break; 392 383 } 393 Runner = Runner->next;394 384 } 395 if ( Runner != end) { // we found the other source385 if (runner != end()) { // we found the other source 396 386 // then look in its distance list for Sprinter 397 Rider = Params.DistanceList[ Runner->nr]->begin();398 for (; Rider != Params.DistanceList[ Runner->nr]->end(); Rider++)387 Rider = Params.DistanceList[(*runner)->nr]->begin(); 388 for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++) 399 389 if (Rider->second == Sprinter) 400 390 break; 401 if (Rider != Params.DistanceList[ Runner->nr]->end()) { // if we have found one402 //Log() << Verbose(2) << "Current Other: " << * Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;391 if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one 392 //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl; 403 393 // exchange both 404 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap405 Params.PermutationMap[ Runner->nr] = Sprinter; // and hand the old target to its respective owner406 PrintPermutationMap( AtomCount, Params);394 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap 395 Params.PermutationMap[(*runner)->nr] = Sprinter; // and hand the old target to its respective owner 396 PrintPermutationMap(getAtomCount(), Params); 407 397 // calculate the new potential 408 398 //Log() << Verbose(2) << "Checking new potential ..." << endl; … … 410 400 if (Potential > OldPotential) { // we made everything worse! Undo ... 411 401 //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl; 412 //Log() << Verbose(3) << "Setting " << * Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;402 //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl; 413 403 // Undo for Runner (note, we haven't moved the iteration yet, we may use this) 414 Params.PermutationMap[ Runner->nr] = Params.DistanceIterators[Runner->nr]->second;404 Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second; 415 405 // Undo for Walker 416 Params.DistanceIterators[ Walker->nr] = Strider; // take next farther distance target417 //Log() << Verbose(3) << "Setting " << * Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;418 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second;406 Params.DistanceIterators[(*iter)->nr] = Strider; // take next farther distance target 407 //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl; 408 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; 419 409 } else { 420 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list410 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 421 411 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 422 412 OldPotential = Potential; … … 428 418 //Log() << Verbose(0) << endl; 429 419 } else { 430 DoeLog(1) && (eLog()<< Verbose(1) << * Runner << " was not the owner of " << *Sprinter << "!" << endl);420 DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl); 431 421 exit(255); 432 422 } 433 423 } else { 434 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!424 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source! 435 425 } 436 Params.StepList[ Walker->nr]++; // take next farther distance target426 Params.StepList[(*iter)->nr]++; // take next farther distance target 437 427 } 438 } while ( Walker->next != end);428 } while (++iter != end()); 439 429 } while ((OlderPotential - OldPotential) > 1e-3); 440 430 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 442 432 443 433 /// free memory and return with evaluated potential 444 for (int i= AtomCount; i--;)434 for (int i=getAtomCount(); i--;) 445 435 Params.DistanceList[i]->clear(); 446 436 Free(&Params.DistanceList); … … 483 473 // Get the Permutation Map by MinimiseConstrainedPotential 484 474 atom **PermutationMap = NULL; 485 atom * Walker = NULL, *Sprinter = NULL;475 atom *Sprinter = NULL; 486 476 if (!MapByIdentity) 487 477 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 488 478 else { 489 PermutationMap = Malloc<atom *>( AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");479 PermutationMap = Malloc<atom *>(getAtomCount(), "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap"); 490 480 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 491 481 } … … 502 492 mol = World::getInstance().createMolecule(); 503 493 MoleculePerStep->insert(mol); 504 Walker = start; 505 while (Walker->next != end) { 506 Walker = Walker->next; 494 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 507 495 // add to molecule list 508 Sprinter = mol->AddCopyAtom( Walker);496 Sprinter = mol->AddCopyAtom((*iter)); 509 497 for (int n=NDIM;n--;) { 510 Sprinter->x[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);498 Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps); 511 499 // add to Trajectories 512 500 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 513 501 if (step < MaxSteps) { 514 Walker->Trajectory.R.at(step)[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);515 Walker->Trajectory.U.at(step)[n] = 0.;516 Walker->Trajectory.F.at(step)[n] = 0.;502 (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps); 503 (*iter)->Trajectory.U.at(step)[n] = 0.; 504 (*iter)->Trajectory.F.at(step)[n] = 0.; 517 505 } 518 506 } … … 522 510 523 511 // store the list to single step files 524 int *SortIndex = Malloc<int>( AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");525 for (int i= AtomCount; i--; )512 int *SortIndex = Malloc<int>(getAtomCount(), "molecule::LinearInterpolationBetweenConfiguration: *SortIndex"); 513 for (int i=getAtomCount(); i--; ) 526 514 SortIndex[i] = i; 527 515 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); … … 567 555 return false; 568 556 } 569 if (Force.RowCounter[0] != AtomCount) {570 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount<< "." << endl);557 if (Force.RowCounter[0] != getAtomCount()) { 558 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl); 571 559 performCriticalExit(); 572 560 return false; … … 574 562 // correct Forces 575 563 Velocity.Zero(); 576 for(int i=0;i< AtomCount;i++)564 for(int i=0;i<getAtomCount();i++) 577 565 for(int d=0;d<NDIM;d++) { 578 566 Velocity[d] += Force.Matrix[0][i][d+5]; 579 567 } 580 for(int i=0;i< AtomCount;i++)568 for(int i=0;i<getAtomCount();i++) 581 569 for(int d=0;d<NDIM;d++) { 582 Force.Matrix[0][i][d+5] -= Velocity[d]/ (double)AtomCount;570 Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount()); 583 571 } 584 572 // solve a constrained potential if we are meant to … … 683 671 delta_alpha = 0.; 684 672 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 685 delta_alpha = (delta_alpha - (3.* AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);673 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 686 674 configuration.alpha += delta_alpha*configuration.Deltat; 687 675 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.
