source: src/Dynamics/MinimiseConstrainedPotential.hpp@ 9e23a3

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 9e23a3 was 9e23a3, checked in by Frederik Heber <heber@…>, 14 years ago

Rewrote MinimiseConstrainedPotential into a functor in Dynamics/.

  • Property mode set to 100644
File size: 8.0 KB
Line 
1/*
2 * MinimiseConstrainedPotential.hpp
3 *
4 * Created on: Feb 23, 2011
5 * Author: heber
6 */
7
8#ifndef MINIMISECONSTRAINEDPOTENTIAL_HPP_
9#define MINIMISECONSTRAINEDPOTENTIAL_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16class atom;
17
18#include <vector>
19#include <map>
20
21#include "molecule.hpp"
22
23/** Structure to contain parameters needed for evaluation of constraint potential.
24 *
25 */
26class MinimiseConstrainedPotential
27{
28public:
29 MinimiseConstrainedPotential(molecule::atomSet &_atoms);
30 ~MinimiseConstrainedPotential();
31
32 /** Minimises the extra potential for constrained molecular dynamics and gives forces and the constrained potential energy.
33 * We do the following:
34 * -# Generate a distance list from all source to all target points
35 * -# Sort this per source point
36 * -# Take for each source point the target point with minimum distance, use this as initial permutation
37 * -# check whether molecule::ConstrainedPotential() is greater than injective penalty
38 * -# If so, we go through each source point, stepping down in the sorted target point distance list and re-checking potential.
39 * -# Next, we only apply transformations that keep the injectivity of the permutations list.
40 * -# Hence, for one source point we step down the ladder and seek the corresponding owner of this new target
41 * point and try to change it for one with lesser distance, or for the next one with greater distance, but only
42 * if this decreases the conditional potential.
43 * -# finished.
44 * -# Then, we calculate the forces by taking the spatial derivative, where we scale the potential to such a degree,
45 * that the total force is always pointing in direction of the constraint force (ensuring that we move in the
46 * right direction).
47 * -# Finally, we calculate the potential energy and return.
48 * \param *out output stream for debugging
49 * \param **PermutationMap on return: mapping between the atom label of the initial and the final configuration
50 * \param startstep current MD step giving initial position between which and \a endstep we perform the constrained MD (as further steps are always concatenated)
51 * \param endstep step giving final position in constrained MD
52 * \param IsAngstroem whether coordinates are in angstroem (true) or bohrradius (false)
53 * \sa molecule::VerletForceIntegration()
54 * \return potential energy (and allocated **PermutationMap (array of molecule::AtomCount ^2)
55 * \todo The constrained potential's constants are set to fixed values right now, but they should scale based on checks of the system in order
56 * to ensure they're properties (e.g. constants[2] always greater than the energy of the system).
57 * \bug this all is not O(N log N) but O(N^2)
58 */
59 double operator()(atom **&PermutationMap, int startstep, int endstep, bool IsAngstroem);
60
61 /** Evaluates the (distance-related part) of the constrained potential for the constrained forces.
62 * \param *out output stream for debugging
63 * \param startstep current MD step giving initial position between which and \a endstep we perform the constrained MD (as further steps are always concatenated)
64 * \param endstep step giving final position in constrained MD
65 * \param **PermutationMap mapping between the atom label of the initial and the final configuration
66 * \param *Force ForceMatrix containing force vectors from the external energy functional minimisation.
67 * \todo the constant for the constrained potential distance part is hard-coded independently of the hard-coded value in MinimiseConstrainedPotential()
68 */
69 void EvaluateConstrainedForces(ForceMatrix *Force);
70
71private:
72 typedef std::pair < double, atom* > DistancePair;
73 typedef std::multimap < double, atom* > DistanceMap;
74 typedef std::pair < DistanceMap::iterator, bool> DistanceTestPair;
75
76 molecule::atomSet atoms;
77 int startstep; //!< start configuration (MDStep in atom::trajectory)
78 int endstep; //!< end configuration (MDStep in atom::trajectory)
79 atom **PermutationMap; //!< gives target ptr for each atom, array of size molecule::AtomCount (this is "x" in \f$ V^{con}(x) \f$ )
80 DistanceMap **DistanceList; //!< distance list of each atom to each atom
81 DistanceMap::iterator *StepList; //!< iterator to ascend through NearestNeighbours \a **DistanceList
82 int *DoubleList; //!< count of which sources want to move to this target, basically the injective measure (>1 -> not injective)
83 DistanceMap::iterator *DistanceIterators; //!< marks which was the last picked target as injective candidate with smallest distance
84 bool IsAngstroem; //!< whether coordinates are in angstroem (true) or bohrradius (false)
85 double *PenaltyConstants; //!< penalty constant in front of each term
86
87 /** \f$O(N^2)\f$ operation of calculation distance between each atom pair and putting into DistanceList.
88 * \param *mol molecule to scan distances in
89 * \param &Params constrained potential parameters
90 */
91 void FillDistanceList();
92
93 /** Initialize lists.
94 * \param *out output stream for debugging
95 * \param *mol molecule to scan distances in
96 * \param &Params constrained potential parameters
97 */
98 void CreateInitialLists();
99
100 /** Permutes \a **&PermutationMap until the penalty is below constants[2].
101 * \param *out output stream for debugging
102 * \param *mol molecule to scan distances in
103 * \param &Params constrained potential parameters
104 */
105 void MakeInjectivePermutation();
106
107 /** Print the current permutation map.
108 * \param *out output stream for debugging
109 * \param &Params constrained potential parameters
110 * \param AtomCount number of atoms
111 */
112 void PrintPermutationMap() const;
113
114 /** Evaluates the potential energy used for constrained molecular dynamics.
115 * \f$V_i^{con} = c^{bond} \cdot | r_{P(i)} - R_i | + sum_{i \neq j} C^{min} \cdot \frac{1}{C_{ij}} + C^{inj} \Bigl (1 - \theta \bigl (\prod_{i \neq j} (P(i) - P(j)) \bigr ) \Bigr )\f$
116 * where the first term points to the target in minimum distance, the second is a penalty for trajectories lying too close to each other (\f$C_{ij}\f$ is minimum distance between
117 * trajectories i and j) and the third term is a penalty for two atoms trying to each the same target point.
118 * Note that for the second term we have to solve the following linear system:
119 * \f$-c_1 \cdot n_1 + c_2 \cdot n_2 + C \cdot n_3 = - p_2 + p_1\f$, where \f$c_1\f$, \f$c_2\f$ and \f$C\f$ are constants,
120 * offset vector \f$p_1\f$ in direction \f$n_1\f$, offset vector \f$p_2\f$ in direction \f$n_2\f$,
121 * \f$n_3\f$ is the normal vector to both directions. \f$C\f$ would be the minimum distance between the two lines.
122 * \sa molecule::MinimiseConstrainedPotential(), molecule::VerletForceIntegration()
123 * \param *out output stream for debugging
124 * \param &Params constrained potential parameters
125 * \return potential energy
126 * \note This routine is scaling quadratically which is not optimal.
127 * \todo There's a bit double counting going on for the first time, bu nothing to worry really about.
128 */
129 double ConstrainedPotential();
130
131 /** Try the next nearest neighbour in order to make the permutation map injective.
132 * \param *out output stream for debugging
133 * \param *mol molecule
134 * \param *Walker atom to change its target
135 * \param &OldPotential old value of constraint potential to see if we do better with new target
136 * \param &Params constrained potential parameters
137 */
138 double TryNextNearestNeighbourForInjectivePermutation(atom *Walker, double &OldPotential);
139
140 /** Penalizes atoms heading to same target.
141 * \param *Walker atom to check against others
142 * \param *mol molecule with other atoms
143 * \param &Params constrained potential parameters
144 * \return \a penalty times the number of equal targets
145 */
146 double PenalizeEqualTargets(atom *Walker);
147
148 /** Penalizes long trajectories.
149 * \param *Walker atom to check against others
150 * \param *mol molecule with other atoms
151 * \param &Params constraint potential parameters
152 * \return penalty times each distance
153 */
154 double SumDistanceOfTrajectories(atom *Walker);
155
156};
157
158
159#endif /* MINIMISECONSTRAINEDPOTENTIAL_HPP_ */
Note: See TracBrowser for help on using the repository browser.