Ignore:
Timestamp:
Mar 1, 2011, 1:17:09 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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:
8009ce
Parents:
9e23a3
git-author:
Frederik Heber <heber@…> (02/25/11 09:39:10)
git-committer:
Frederik Heber <heber@…> (03/01/11 13:17:09)
Message:

Rewrote LinearInterpolationBetweenSteps into a functor in Dynamics/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_dynamics.cpp

    r9e23a3 r20943b  
    3838/************************************* Functions for class molecule *********************************/
    3939
    40 
    41 /** Performs a linear interpolation between two desired atomic configurations with a given number of steps.
    42  * Note, step number is config::MaxOuterStep
    43  * \param *out output stream for debugging
    44  * \param startstep stating initial configuration in molecule::Trajectories
    45  * \param endstep stating final configuration in molecule::Trajectories
    46  * \param &prefix path and prefix
    47  * \param &config configuration structure
    48  * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
    49  * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    50  */
    51 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string prefix, config &configuration, bool MapByIdentity)
    52 {
    53   // TODO: rewrite permutationMaps using enumeration objects
    54   molecule *mol = NULL;
    55   bool status = true;
    56   int MaxSteps = configuration.MaxOuterStep;
    57   MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
    58   // Get the Permutation Map by MinimiseConstrainedPotential
    59   atom **PermutationMap = NULL;
    60   atom *Sprinter = NULL;
    61   if (!MapByIdentity) {
    62     MinimiseConstrainedPotential Minimiser(atoms);
    63     Minimiser(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    64   } else {
    65     // TODO: construction of enumeration goes here
    66     PermutationMap = new atom *[getAtomCount()];
    67     for(internal_iterator iter = atoms.begin(); iter != atoms.end();++iter){
    68       PermutationMap[(*iter)->getNr()] = (*iter);
    69     }
    70   }
    71 
    72   // check whether we have sufficient space in Trajectories for each atom
    73   LOG(1, "STATUS: Extending each trajectory size to " << MaxSteps+1 << ".");
    74   for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::ResizeTrajectory),MaxSteps+1));
    75   // push endstep to last one
    76   for_each(atoms.begin(),atoms.end(),boost::bind(&atom::CopyStepOnStep,_1,MaxSteps,endstep));
    77   endstep = MaxSteps;
    78 
    79   // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
    80   DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
    81   for (int step = 0; step <= MaxSteps; step++) {
    82     mol = World::getInstance().createMolecule();
    83     MoleculePerStep->insert(mol);
    84     for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    85       // add to molecule list
    86       Sprinter = mol->AddCopyAtom((*iter));
    87       // add to Trajectories
    88       Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->getNr()]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
    89       Sprinter->setPosition(temp);
    90       (*iter)->setAtomicVelocityAtStep(step, zeroVec);
    91       (*iter)->setAtomicForceAtStep(step, zeroVec);
    92       //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    93     }
    94   }
    95   MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
    96 
    97   // store the list to single step files
    98   int *SortIndex = new int[getAtomCount()];
    99   for (int i=getAtomCount(); i--; )
    100     SortIndex[i] = i;
    101 
    102   status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
    103   delete[](SortIndex);
    104 
    105   // free and return
    106   delete[](PermutationMap);
    107   delete(MoleculePerStep);
    108   return status;
    109 };
    11040
    11141/** Parses nuclear forces from file and performs Verlet integration.
Note: See TracChangeset for help on using the changeset viewer.