source: src/Dynamics/LinearInterpolationBetweenSteps.hpp@ 47d041

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 47d041 was a9b86d, checked in by Frederik Heber <heber@…>, 13 years ago

Split up modules parser.[ch]pp into one module per class.

  • fixed inclusion of parser.hpp in some other files.
  • for the moment we have to use libMolecuilderUI for joiner and analyzer.
  • Removed inline definition from FixedDigitNumber().
  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * LinearInterpolationBetweenSteps.hpp
3 *
4 * Created on: Feb 23, 2011
5 * Author: heber
6 */
7
8#ifndef LINEARINTERPOLATIONBETWEENSTEPS_HPP_
9#define LINEARINTERPOLATIONBETWEENSTEPS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <vector>
17
18#include "atom.hpp"
19#include "AtomSet.hpp"
20#include "CodePatterns/Assert.hpp"
21#include "CodePatterns/Info.hpp"
22#include "CodePatterns/Log.hpp"
23#include "CodePatterns/toString.hpp"
24#include "CodePatterns/Verbose.hpp"
25#include "Dynamics/MinimiseConstrainedPotential.hpp"
26#include "molecule.hpp"
27#include "World.hpp"
28
29template <class Set>
30class LinearInterpolationBetweenSteps
31{
32public:
33 LinearInterpolationBetweenSteps(AtomSetMixin<Set> &_atoms, unsigned int _MaxOuterStep) :
34 MaxOuterStep(_MaxOuterStep),
35 IsAngstroem(true),
36 atoms(_atoms)
37 {}
38 ~LinearInterpolationBetweenSteps()
39 {}
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 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()
47 */
48 void operator()(int startstep, int endstep, bool MapByIdentity)
49 {
50 // TODO: rewrite permutationMaps using enumeration objects
51 int MaxSteps = MaxOuterStep;
52
53 // Get the Permutation Map by MinimiseConstrainedPotential
54 std::map<atom*, atom *> PermutationMap;
55 if (!MapByIdentity) {
56 LOG(1, "STATUS: Constructing atom mapping from start to end position.");
57 molecule::atomSet atoms_list;
58 copy(atoms.begin(), atoms.end(), atoms_list.begin());
59 MinimiseConstrainedPotential Minimiser(atoms_list, PermutationMap);
60 Minimiser(startstep, endstep, IsAngstroem);
61 } else {
62 LOG(1, "STATUS: Using identity mapping.");
63 // TODO: construction of enumeration goes here
64 for(typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end();++iter){
65 PermutationMap[(*iter)] = (*iter);
66 }
67 }
68
69 // check whether we have sufficient space in Trajectories for each atom
70 LOG(1, "STATUS: Extending trajectories.");
71 for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
72 (*iter)->ResizeTrajectory(MaxSteps);
73 }
74 // push endstep to last one
75 for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
76 (*iter)->CopyStepOnStep(MaxSteps,endstep);
77 }
78 endstep = MaxSteps;
79
80 // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
81 LOG(1, "STATUS: Filling intermediate " << MaxSteps << " steps." << endl);
82 for (int step = 0; step <= MaxSteps; step++) {
83 LOG(2, "INFO: Current step is " << step << "." << endl);
84 for (typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
85 // add to Trajectories
86 ASSERT(PermutationMap.count((*iter)),
87 "LinearInterpolationBetweenSteps::operator() - atom "+toString(**iter)+" not found in PermutationMap.");
88 Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
89 (*iter)->setPositionAtStep(step,temp);
90 (*iter)->setAtomicVelocityAtStep(step, zeroVec);
91 (*iter)->setAtomicForceAtStep(step, zeroVec);
92 LOG(2, "INFO: Adding trajectory point for atom " << **iter << " at " << temp << ".");
93 }
94 }
95
96// // store the list to single step files
97// int *SortIndex = new int[atoms.size()];
98// for (int i=atoms.size(); i--; )
99// SortIndex[i] = i;
100//
101// status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
102// delete[](SortIndex);
103 };
104
105private:
106 unsigned int MaxOuterStep;
107 bool IsAngstroem;
108 AtomSetMixin<Set> atoms;
109
110};
111
112#endif /* LINEARINTERPOLATIONBETWEENSTEPS_HPP_ */
Note: See TracBrowser for help on using the repository browser.