Ignore:
Timestamp:
May 27, 2010, 10:46:54 AM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
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.
Message:

Merge branch 'MoleculeStartEndSwitch' into StructureRefactoring

Conflicts:

molecuilder/src/Helpers/Assert.cpp
molecuilder/src/Helpers/Assert.hpp
molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/Patterns/Cacheable.hpp
molecuilder/src/Patterns/Observer.cpp
molecuilder/src/Patterns/Observer.hpp
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule.hpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/ObserverTest.cpp
molecuilder/src/unittests/ObserverTest.hpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_dynamics.cpp

    r8f215d ra7b761b  
    2828  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    2929  gsl_vector *x = gsl_vector_alloc(NDIM);
    30   atom * Runner = mol->start;
    3130  atom *Sprinter = NULL;
    3231  Vector trajectory1, trajectory2, normal, TestVector;
    3332  double Norm1, Norm2, tmp, result = 0.;
    3433
    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++)
    3836      break;
    3937    // determine normalized trajectories direction vector (n1, n2)
     
    4240    trajectory1.Normalize();
    4341    Norm1 = trajectory1.Norm();
    44     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    45     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);
    4644    trajectory2.Normalize();
    4745    Norm2 = trajectory1.Norm();
    4846    // check whether either is zero()
    4947    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));
    5149    } else if (Norm1 < MYEPSILON) {
    5250      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);
    5452      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5553      trajectory1 -= trajectory2;   // project the part in norm direction away
    5654      tmp = trajectory1.Norm();  // remaining norm is distance
    5755    } else if (Norm2 < MYEPSILON) {
    58       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     56      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    5957      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
    6058      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     
    6664  //        Log() << Verbose(0) << " and ";
    6765  //        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));
    6967  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7068    } 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 ";
    7270  //        Log() << Verbose(0) << endl;
    7371  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8583        gsl_matrix_set(A, 1, i, trajectory2[i]);
    8684        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]));
    8886      }
    8987      // solve the linear system by Householder transformations
     
    9694      trajectory2.Scale(gsl_vector_get(x,1));
    9795      normal.Scale(gsl_vector_get(x,2));
    98       TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     96      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    9997                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    10098      if (TestVector.Norm() < MYEPSILON) {
     
    125123{
    126124  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)) {
    131127  //    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 ";
    133129  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    134130  //        Log() << Verbose(0) << ", penalting." << endl;
     
    161157  // go through every atom
    162158  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) {
    166160    // first term: distance to target
    167     Runner = Params.PermutationMap[Walker->nr];   // find target point
    168     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)));
    169163    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    170164    result += Params.PenaltyConstants[0] * tmp;
     
    172166
    173167    // second term: sum of distances to other trajectories
    174     result += SumDistanceOfTrajectories(Walker, this, Params);
     168    result += SumDistanceOfTrajectories((*iter), this, Params);
    175169
    176170    // third term: penalty for equal targets
    177     result += PenalizeEqualTargets(Walker, this, Params);
     171    result += PenalizeEqualTargets((*iter), this, Params);
    178172  }
    179173
     
    213207void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    214208{
    215   for (int i=mol->AtomCount; i--;) {
     209  for (int i=mol->getAtomCount(); i--;) {
    216210    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    217211    Params.DistanceList[i]->clear();
    218212  }
    219213
    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)) );
    228217    }
    229218  }
     
    237226void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    238227{
    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);
    247234  }
    248235};
     
    285272void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    286273{
    287   atom *Walker = mol->start;
     274  molecule::const_iterator iter = mol->begin();
    288275  DistanceMap::iterator NewBase;
    289276  double Potential = fabs(mol->ConstrainedPotential(Params));
    290277
     278  if (mol->empty()) {
     279    eLog() << Verbose(1) << "Molecule is empty." << endl;
     280    return;
     281  }
    291282  while ((Potential) > Params.PenaltyConstants[2]) {
    292     PrintPermutationMap(mol->AtomCount, Params);
    293     Walker = Walker->next;
    294     if (Walker == mol->end) // round-robin at the end
    295       Walker = mol->start->next;
    296     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     283    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
    297288      continue;
    298289    // 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 <=1
     290    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
     291  }
     292  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    302293    if (Params.DoubleList[i] > 1) {
    303294      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
     
    338329  double Potential, OldPotential, OlderPotential;
    339330  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");
    345336  int round;
    346   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     337  atom *Sprinter = NULL;
    347338  DistanceMap::iterator Rider, Strider;
    348339
     
    371362    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    372363    OlderPotential = OldPotential;
     364    molecule::const_iterator iter;
    373365    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();
    383374          break;
    384375        }
    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;
    386377        // 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;
    391382            break;
    392383          }
    393           Runner = Runner->next;
    394384        }
    395         if (Runner != end) { // we found the other source
     385        if (runner != end()) { // we found the other source
    396386          // 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++)
    399389            if (Rider->second == Sprinter)
    400390              break;
    401           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    402             //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;
    403393            // exchange both
    404             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    405             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
    406             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);
    407397            // calculate the new potential
    408398            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    410400            if (Potential > OldPotential) { // we made everything worse! Undo ...
    411401              //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;
    413403              // 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;
    415405              // Undo for Walker
    416               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    417               //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;
    419409            } else {
    420               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     410              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    421411              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    422412              OldPotential = Potential;
     
    428418            //Log() << Verbose(0) << endl;
    429419          } 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);
    431421            exit(255);
    432422          }
    433423        } 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!
    435425        }
    436         Params.StepList[Walker->nr]++; // take next farther distance target
     426        Params.StepList[(*iter)->nr]++; // take next farther distance target
    437427      }
    438     } while (Walker->next != end);
     428    } while (++iter != end());
    439429  } while ((OlderPotential - OldPotential) > 1e-3);
    440430  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    442432
    443433  /// free memory and return with evaluated potential
    444   for (int i=AtomCount; i--;)
     434  for (int i=getAtomCount(); i--;)
    445435    Params.DistanceList[i]->clear();
    446436  Free(&Params.DistanceList);
     
    483473  // Get the Permutation Map by MinimiseConstrainedPotential
    484474  atom **PermutationMap = NULL;
    485   atom *Walker = NULL, *Sprinter = NULL;
     475  atom *Sprinter = NULL;
    486476  if (!MapByIdentity)
    487477    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    488478  else {
    489     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     479    PermutationMap = Malloc<atom *>(getAtomCount(), "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
    490480    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    491481  }
     
    502492    mol = World::getInstance().createMolecule();
    503493    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) {
    507495      // add to molecule list
    508       Sprinter = mol->AddCopyAtom(Walker);
     496      Sprinter = mol->AddCopyAtom((*iter));
    509497      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);
    511499        // add to Trajectories
    512500        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    513501        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.;
    517505        }
    518506      }
     
    522510
    523511  // 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--; )
    526514    SortIndex[i] = i;
    527515  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     
    567555      return false;
    568556    }
    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);
    571559      performCriticalExit();
    572560      return false;
     
    574562    // correct Forces
    575563    Velocity.Zero();
    576     for(int i=0;i<AtomCount;i++)
     564    for(int i=0;i<getAtomCount();i++)
    577565      for(int d=0;d<NDIM;d++) {
    578566        Velocity[d] += Force.Matrix[0][i][d+5];
    579567      }
    580     for(int i=0;i<AtomCount;i++)
     568    for(int i=0;i<getAtomCount();i++)
    581569      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());
    583571      }
    584572    // solve a constrained potential if we are meant to
     
    683671      delta_alpha = 0.;
    684672      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);
    686674      configuration.alpha += delta_alpha*configuration.Deltat;
    687675      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
Note: See TracChangeset for help on using the changeset viewer.