Ignore:
Timestamp:
Mar 19, 2010, 1:29:01 PM (15 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, 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:
e0b6fd
Parents:
80c63d
Message:

FIX: Made AtomCount a Cacheable so that the number of atoms in a molecule will always be correct

All unittests working.
All Complete testcases fail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_dynamics.cpp

    r80c63d rea7176  
    213213void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    214214{
    215   for (int i=mol->AtomCount; i--;) {
     215  for (int i=mol->getAtomCount(); i--;) {
    216216    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    217217    Params.DistanceList[i]->clear();
     
    287287  }
    288288  while ((Potential) > Params.PenaltyConstants[2]) {
    289     PrintPermutationMap(mol->AtomCount, Params);
     289    PrintPermutationMap(mol->getAtomCount(), Params);
    290290    iter++;
    291291    if (iter == mol->end()) // round-robin at the end
     
    296296    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
    297297  }
    298   for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
     298  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    299299    if (Params.DoubleList[i] > 1) {
    300300      eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl;
     
    335335  double Potential, OldPotential, OlderPotential;
    336336  struct EvaluatePotential Params;
    337   Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");
    338   Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");
    339   Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");
    340   Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");
    341   Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");
     337  Params.PermutationMap = Calloc<atom*>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");
     338  Params.DistanceList = Malloc<DistanceMap*>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.**DistanceList");
     339  Params.DistanceIterators = Malloc<DistanceMap::iterator>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");
     340  Params.DoubleList = Calloc<int>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*DoubleList");
     341  Params.StepList = Malloc<DistanceMap::iterator>(getAtomCount(), "molecule::MinimiseConstrainedPotential: Params.*StepList");
    342342  int round;
    343343  atom *Sprinter = NULL;
     
    372372      iter = begin();
    373373      for (; iter != end(); ++iter) {
    374         PrintPermutationMap(AtomCount, Params);
     374        PrintPermutationMap(getAtomCount(), Params);
    375375        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
    376376        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
     
    400400            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
    401401            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
    402             PrintPermutationMap(AtomCount, Params);
     402            PrintPermutationMap(getAtomCount(), Params);
    403403            // calculate the new potential
    404404            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    438438
    439439  /// free memory and return with evaluated potential
    440   for (int i=AtomCount; i--;)
     440  for (int i=getAtomCount(); i--;)
    441441    Params.DistanceList[i]->clear();
    442442  Free(&Params.DistanceList);
     
    483483    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    484484  else {
    485     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     485    PermutationMap = Malloc<atom *>(getAtomCount(), "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
    486486    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    487487  }
     
    516516
    517517  // store the list to single step files
    518   int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");
    519   for (int i=AtomCount; i--; )
     518  int *SortIndex = Malloc<int>(getAtomCount(), "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");
     519  for (int i=getAtomCount(); i--; )
    520520    SortIndex[i] = i;
    521521  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     
    561561      return false;
    562562    }
    563     if (Force.RowCounter[0] != AtomCount) {
    564       eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;
     563    if (Force.RowCounter[0] != getAtomCount()) {
     564      eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl;
    565565      performCriticalExit();
    566566      return false;
     
    568568    // correct Forces
    569569    Velocity.Zero();
    570     for(int i=0;i<AtomCount;i++)
     570    for(int i=0;i<getAtomCount();i++)
    571571      for(int d=0;d<NDIM;d++) {
    572572        Velocity.x[d] += Force.Matrix[0][i][d+5];
    573573      }
    574     for(int i=0;i<AtomCount;i++)
     574    for(int i=0;i<getAtomCount();i++)
    575575      for(int d=0;d<NDIM;d++) {
    576         Force.Matrix[0][i][d+5] -= Velocity.x[d]/(double)AtomCount;
     576        Force.Matrix[0][i][d+5] -= Velocity.x[d]/static_cast<double>(getAtomCount());
    577577      }
    578578    // solve a constrained potential if we are meant to
     
    677677      delta_alpha = 0.;
    678678      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    679       delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
     679      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    680680      configuration.alpha += delta_alpha*configuration.Deltat;
    681681      Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl;
Note: See TracChangeset for help on using the changeset viewer.