| 1 | /*
 | 
|---|
| 2 |  * SphericalPointDistribution.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: May 29, 2014
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | 
 | 
|---|
| 9 | #ifndef SPHERICALPOINTDISTRIBUTION_HPP_
 | 
|---|
| 10 | #define SPHERICALPOINTDISTRIBUTION_HPP_
 | 
|---|
| 11 | 
 | 
|---|
| 12 | // include config.h
 | 
|---|
| 13 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 14 | #include <config.h>
 | 
|---|
| 15 | #endif
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include "CodePatterns/Assert.hpp"
 | 
|---|
| 18 | 
 | 
|---|
| 19 | #include <cmath>
 | 
|---|
| 20 | #include <list>
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include "LinearAlgebra/Vector.hpp"
 | 
|---|
| 23 | 
 | 
|---|
| 24 | /** contains getters for the VSEPR model for specific number of electrons.
 | 
|---|
| 25 |  *
 | 
|---|
| 26 |  * This struct contains specialized functions returning a list of Vectors
 | 
|---|
| 27 |  * (points in space) to match the VSEPR model for the given number of electrons.
 | 
|---|
| 28 |  *
 | 
|---|
| 29 |  * This is implemented via template specialization of the function get().
 | 
|---|
| 30 |  *
 | 
|---|
| 31 |  * These specializations are taken from the python script \b CreateVspeShapes.py
 | 
|---|
| 32 |  * by Christian Neuen, 07th May 2009.
 | 
|---|
| 33 |  */
 | 
|---|
| 34 | struct SphericalPointDistribution
 | 
|---|
| 35 | {
 | 
|---|
| 36 |   /** Cstor for SphericalPointDistribution, allows setting radius of sphere
 | 
|---|
| 37 |    *
 | 
|---|
| 38 |    * \param _BondLength desired radius of sphere
 | 
|---|
| 39 |    */
 | 
|---|
| 40 |   SphericalPointDistribution(const double _Bondlength = 1.) :
 | 
|---|
| 41 |     Bondlength(_Bondlength),
 | 
|---|
| 42 |     SQRT_3(sqrt(3.0))
 | 
|---|
| 43 |   {}
 | 
|---|
| 44 | 
 | 
|---|
| 45 |   //!> typedef for the list of points
 | 
|---|
| 46 |   typedef std::list<Vector> Polygon_t;
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   /** General getter function for the distribution of points on the surface.
 | 
|---|
| 49 |    *
 | 
|---|
| 50 |    * \warn this function needs to be specialized!
 | 
|---|
| 51 |    *
 | 
|---|
| 52 |    * \return Polygon_t with points on the surface centered at (0,0,0)
 | 
|---|
| 53 |    */
 | 
|---|
| 54 |   template <int N> Polygon_t get()
 | 
|---|
| 55 |   {
 | 
|---|
| 56 |     ASSERT(0, "SphericalPointDistribution::get() - not specialized for "+toString(N)+".");
 | 
|---|
| 57 |   }
 | 
|---|
| 58 | 
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   /** Matches a given spherical distribution with another containing more
 | 
|---|
| 61 |    * points.
 | 
|---|
| 62 |    *
 | 
|---|
| 63 |    * The idea is to produce a matching from all points in \a _polygon to those
 | 
|---|
| 64 |    * in \a _newpolygon in such a way that their distance difference is minimal.
 | 
|---|
| 65 |    * As we just look at numbers of points determined by valency, i.e.
 | 
|---|
| 66 |    * independent of the number of atoms, we simply go through each of the possible
 | 
|---|
| 67 |    * mappings. We stop when the L1 error is below a certain \a threshold,
 | 
|---|
| 68 |    * otherwise we pick the matching with the lowest L2 error.
 | 
|---|
| 69 |    *
 | 
|---|
| 70 |    * This is a helper to determine points where to best insert saturation
 | 
|---|
| 71 |    * hydrogens.
 | 
|---|
| 72 |    *
 | 
|---|
| 73 |    * \param _polygon current occupied positions
 | 
|---|
| 74 |    * \param _newpolygon ideal distribution to match best with current occupied
 | 
|---|
| 75 |    *        positions
 | 
|---|
| 76 |    * \return remaining vacant positions relative to \a _polygon
 | 
|---|
| 77 |    */
 | 
|---|
| 78 |   static Polygon_t matchSphericalPointDistributions(
 | 
|---|
| 79 |       const Polygon_t &_polygon,
 | 
|---|
| 80 |       const Polygon_t &_newpolygon
 | 
|---|
| 81 |       );
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   //!> default radius of the spherical distribution
 | 
|---|
| 84 |   const double Bondlength;
 | 
|---|
| 85 |   //!> precalculated value for root of 3
 | 
|---|
| 86 |   const double SQRT_3;
 | 
|---|
| 87 | };
 | 
|---|
| 88 | 
 | 
|---|
| 89 | // declare specializations
 | 
|---|
| 90 | 
 | 
|---|
| 91 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<0>();
 | 
|---|
| 92 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<1>();
 | 
|---|
| 93 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<2>();
 | 
|---|
| 94 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<3>();
 | 
|---|
| 95 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<4>();
 | 
|---|
| 96 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<5>();
 | 
|---|
| 97 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<6>();
 | 
|---|
| 98 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<7>();
 | 
|---|
| 99 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<8>();
 | 
|---|
| 100 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<9>();
 | 
|---|
| 101 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<10>();
 | 
|---|
| 102 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<11>();
 | 
|---|
| 103 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<12>();
 | 
|---|
| 104 | template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<14>();
 | 
|---|
| 105 | 
 | 
|---|
| 106 | #endif /* SPHERICALPOINTDISTRIBUTION_HPP_ */
 | 
|---|