source: src/Fragmentation/Exporters/SaturatedFragment.hpp@ 72b467

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator 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_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 72b467 was c6ddcb, checked in by Frederik Heber <heber@…>, 9 years ago

Added getRoughBoundingBox to SaturatedFragment.

  • Property mode set to 100644
File size: 8.5 KB
Line 
1/*
2 * SaturatedFragment.hpp
3 *
4 * Created on: Mar 3, 2013
5 * Author: heber
6 */
7
8#ifndef SATURATEDFRAGMENT_HPP_
9#define SATURATEDFRAGMENT_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <set>
18#include <string>
19
20#include "Atom/atom_bondedparticleinfo.hpp"
21#include "Bond/bond.hpp"
22#include "Fragmentation/KeySet.hpp"
23#include "Fragmentation/HydrogenSaturation_enum.hpp"
24#include "Parser/FormatParserStorage.hpp"
25
26#include "LinearAlgebra/Vector.hpp"
27
28class atom;
29class HydrogenPool;
30
31/** The SaturatedFragment class acts as a wrapper to a KeySet by adding a list
32 * of saturation hydrogens.
33 *
34 * This SaturatedFragment along with a currently leased set of hydrogens from the
35 * HydrogenPool is all that is required to create a fully storable molecular
36 * fragment from a given Keyset.
37 *
38 * The instance notes down its existence in an external container.
39 *
40 */
41class SaturatedFragment
42{
43public:
44 //!> typedef to a container to mark keysets that are in use
45 typedef std::set<KeySet> KeySetsInUse_t;
46
47 //!> List of points giving saturation positions for a single bond neighbor
48 typedef std::list<Vector> SaturationsPositions_t;
49 //!> map for one atom, containing the saturation points for all its neighbors
50 typedef std::map<int, SaturationsPositions_t> SaturationsPositionsPerNeighbor_t;
51 //!> containing the saturation points over all desired atoms required
52 typedef std::map<int, SaturationsPositionsPerNeighbor_t> GlobalSaturationPositions_t;
53
54 /** Constructor of SaturatedFragment requires \a set which we are tightly
55 * associated.
56 *
57 * \param _set KeySet which this instance is associated with
58 * \param _container container to add KeySet as in-use
59 * \param _hydrogens pool with hydrogens for saturation
60 * \param _globalsaturationpositions saturation positions to be used
61 */
62 SaturatedFragment(
63 const KeySet &_set,
64 KeySetsInUse_t &_container,
65 HydrogenPool &_hydrogens,
66 const enum HydrogenTreatment _treatment,
67 const enum HydrogenSaturation saturation,
68 const GlobalSaturationPositions_t &_globalsaturationpositions);
69
70 /** Destructor of class SaturatedFragment.
71 *
72 */
73 ~SaturatedFragment();
74
75 /** Getter for the KeySet this instance is associated with.
76 *
77 * \return const ref to KeySet
78 */
79 const KeySet & getKeySet() const
80 {
81 return set;
82 }
83
84 /** Getter for the FullMolecule this instance is associated with.
85 *
86 * \return const ref to FullMolecule
87 */
88 const KeySet & getFullMolecule() const
89 {
90 return FullMolecule;
91 }
92
93 /** Getter for the SaturationHydrogens this instance is associated with.
94 *
95 * \return const ref to SaturationHydrogens
96 */
97 const KeySet & getSaturationHydrogens() const
98 {
99 return SaturationHydrogens;
100 }
101
102 /** Determines the bounding box of the fragment without performing the hydrogen
103 * saturation but by simply using the atoms whose bonds are cut.
104 *
105 * \return pair of Vector with min and max coordinates
106 */
107 std::pair<Vector, Vector> getRoughBoundingBox() const;
108
109 /** Prints the config of the fragment of \a _type to \a out.
110 *
111 * \param out output stream to write to
112 * \param _type parser type to write config
113 */
114 bool OutputConfig(
115 std::ostream &out,
116 const ParserTypes _type) const;
117
118private:
119 /** Helper function to lease and bring in place saturation hydrogens.
120 *
121 * Here, we use local information to calculate saturation positions.
122 *
123 */
124 void saturate();
125
126 /** Helper function to lease and bring in place saturation hydrogens.
127 *
128 * Here, saturation positions have to be calculated before and are fully
129 * stored in \a _globalsaturationpositions.
130 *
131 * \param_globalsaturationpositions
132 */
133 void saturate(const GlobalSaturationPositions_t &_globalsaturationpositions);
134
135 /** Replaces all cut bonds with respect to the given atom by hydrogens.
136 *
137 * \param _atom atom whose cut bonds to saturate
138 * \param _cutbonds list of cut bonds for \a _atom
139 * \return true - bonds saturated, false - something went wrong
140 */
141 bool saturateAtom(atom * const _atom, const BondList &_cutbonds);
142
143 /** Helper function to get a hydrogen replacement for a given \a replacement.
144 *
145 * \param replacement atom to "replace" with hydrogen in a fragment.
146 * \return ref to leased hydrogen atom
147 */
148 atom * const getHydrogenReplacement(atom * const replacement);
149
150 /** Sets a saturation hydrogen at the given position in place of \a _father.
151 *
152 * \param _OwnerAtom atom "owning" the hydrogen (i.e. the one getting saturated)
153 * \param _position new position relative to \a _OwnerAtom
154 * \param _distance scale factor to the distance (default 1.)
155 * \param _father bond partner of \a _OwnerAtom that is replaced
156 */
157 const atom& setHydrogenReplacement(
158 const atom * const _OwnerAtom,
159 const Vector &_position,
160 const double _distance,
161 atom * const _father);
162
163 /** Leases and adds a Hydrogen atom in replacement for the given atom \a *partner in bond with a *origin.
164 * Here, we have to distinguish between single, double or triple bonds as stated by \a BondDegree, that each demand
165 * a different scheme when adding \a *replacement atom for the given one.
166 * -# Single Bond: Simply add new atom with bond distance rescaled to typical hydrogen one
167 * -# Double Bond: Here, we need the **BondList of the \a *origin atom, by scanning for the other bonds instead of
168 * *Bond, we use the through these connected atoms to determine the plane they lie in, vector::MakeNormalvector().
169 * The orthonormal vector to this plane along with the vector in *Bond direction determines the plane the two
170 * replacing hydrogens shall lie in. Now, all remains to do is take the usual hydrogen double bond angle for the
171 * element of *origin and form the sin/cos admixture of both plane vectors for the new coordinates of the two
172 * hydrogens forming this angle with *origin.
173 * -# Triple Bond: The idea is to set up a tetraoid (C1-H1-H2-H3) (however the lengths \f$b\f$ of the sides of the base
174 * triangle formed by the to be added hydrogens are not equal to the typical bond distance \f$l\f$ but have to be
175 * determined from the typical angle \f$\alpha\f$ for a hydrogen triple connected to the element of *origin):
176 * We have the height \f$d\f$ as the vector in *Bond direction (from triangle C1-H1-H2).
177 * \f[ h = l \cdot \cos{\left (\frac{\alpha}{2} \right )} \qquad b = 2l \cdot \sin{\left (\frac{\alpha}{2} \right)} \quad \rightarrow \quad d = l \cdot \sqrt{\cos^2{\left (\frac{\alpha}{2} \right)}-\frac{1}{3}\cdot\sin^2{\left (\frac{\alpha}{2}\right )}}
178 * \f]
179 * vector::GetNormalvector() creates one orthonormal vector from this *Bond vector and vector::MakeNormalvector creates
180 * the third one from the former two vectors. The latter ones form the plane of the base triangle mentioned above.
181 * The lengths for these are \f$f\f$ and \f$g\f$ (from triangle H1-H2-(center of H1-H2-H3)) with knowledge that
182 * the median lines in an isosceles triangle meet in the center point with a ratio 2:1.
183 * \f[ f = \frac{b}{\sqrt{3}} \qquad g = \frac{b}{2}
184 * \f]
185 * as the coordination of all three atoms in the coordinate system of these three vectors:
186 * \f$\pmatrix{d & f & 0}\f$, \f$\pmatrix{d & -0.5 \cdot f & g}\f$ and \f$\pmatrix{d & -0.5 \cdot f & -g}\f$.
187 *
188 * \param TopBond pointer to bond between \a *origin and \a *replacement
189 * \param Origin atom that is actually contained in the fragment
190 * \param Replacement pointer to the atom which shall be copied as a hydrogen atom in this molecule
191 * \param isAngstroem whether the coordination of the given atoms is in AtomicLength (false) or Angstrom(true)
192 * \return number of atoms added, if < bond::BondDegree then something went wrong
193 */
194 bool AddHydrogenReplacementAtom(
195 bond::ptr TopBond,
196 atom *Origin,
197 atom *Replacement,
198 bool IsAngstroem);
199
200private:
201 //!> container to mark ourselves RAII-style
202 KeySetsInUse_t &container;
203 //!> key set this fragment is associated with.
204 const KeySet &set;
205 //!> pool with saturation hydrogens
206 HydrogenPool &hydrogens;
207 //!> key set containing all atoms used for e.g. storing this to file
208 KeySet FullMolecule;
209 //!> key set containing the ids of all hydrogens added for saturation
210 KeySet SaturationHydrogens;
211 //!> whether hydrogens are generally contained in set or not
212 const enum HydrogenTreatment treatment;
213 //!> whether to actually saturate or not
214 const enum HydrogenSaturation saturation;
215};
216
217#endif /* SATURATEDFRAGMENT_HPP_ */
Note: See TracBrowser for help on using the repository browser.