source: src/Fragmentation/Exporters/SaturatedFragment.hpp@ 2ae400

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures 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_ChronosMutex 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 TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 2ae400 was 9445081, checked in by Frederik Heber <heber@…>, 8 years ago

FragmentJobQueue additionally stores the bond graph as an edge set per fragment/job.

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