| 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 | //!> default radius of the spherical distribution
|
|---|
| 60 | const double Bondlength;
|
|---|
| 61 | //!> precalculated value for root of 3
|
|---|
| 62 | const double SQRT_3;
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 | template <>
|
|---|
| 66 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<2>()
|
|---|
| 67 | {
|
|---|
| 68 | Polygon_t polygon;
|
|---|
| 69 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 70 | polygon.push_back( Vector(-Bondlength,0.,0.));
|
|---|
| 71 | ASSERT( polygon.size() == 2,
|
|---|
| 72 | "SphericalPointDistribution::get<2>() - polygon has wrong size.");
|
|---|
| 73 | return polygon;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | template <>
|
|---|
| 77 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<3>()
|
|---|
| 78 | {
|
|---|
| 79 | Polygon_t polygon;
|
|---|
| 80 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 81 | polygon.push_back( Vector(-Bondlength*0.5, SQRT_3*0.5,0.));
|
|---|
| 82 | polygon.push_back( Vector(-Bondlength*0.5, -SQRT_3*0.5,0.));
|
|---|
| 83 | ASSERT( polygon.size() == 3,
|
|---|
| 84 | "SphericalPointDistribution::get<3>() - polygon has wrong size.");
|
|---|
| 85 | return polygon;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | template <>
|
|---|
| 89 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<4>()
|
|---|
| 90 | {
|
|---|
| 91 | Polygon_t polygon;
|
|---|
| 92 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 93 | polygon.push_back( Vector(-Bondlength/3.0, Bondlength*2.0*M_SQRT2/3.0,0.));
|
|---|
| 94 | polygon.push_back( Vector(-Bondlength/3.0, -Bondlength*M_SQRT2/3.0, Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 95 | polygon.push_back( Vector(-Bondlength/3.0, -Bondlength*M_SQRT2/3.0, -Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 96 | ASSERT( polygon.size() == 4,
|
|---|
| 97 | "SphericalPointDistribution::get<4>() - polygon has wrong size.");
|
|---|
| 98 | return polygon;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | template <>
|
|---|
| 102 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<5>()
|
|---|
| 103 | {
|
|---|
| 104 | Polygon_t polygon;
|
|---|
| 105 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 106 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 107 | polygon.push_back( Vector(0.0, Bondlength, 0.0));
|
|---|
| 108 | polygon.push_back( Vector(0.0, -Bondlength*0.5, Bondlength*SQRT_3*0.5));
|
|---|
| 109 | polygon.push_back( Vector(0.0, -Bondlength*0.5, -Bondlength*SQRT_3*0.5));
|
|---|
| 110 | ASSERT( polygon.size() == 5,
|
|---|
| 111 | "SphericalPointDistribution::get<5>() - polygon has wrong size.");
|
|---|
| 112 | return polygon;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | template <>
|
|---|
| 116 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<6>()
|
|---|
| 117 | {
|
|---|
| 118 | Polygon_t polygon;
|
|---|
| 119 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 120 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 121 | polygon.push_back( Vector(0.0, Bondlength, 0.0));
|
|---|
| 122 | polygon.push_back( Vector(0.0, -Bondlength, 0.0));
|
|---|
| 123 | polygon.push_back( Vector(0.0, 0.0, Bondlength));
|
|---|
| 124 | polygon.push_back( Vector(0.0, 0.0, -Bondlength));
|
|---|
| 125 | ASSERT( polygon.size() == 6,
|
|---|
| 126 | "SphericalPointDistribution::get<6>() - polygon has wrong size.");
|
|---|
| 127 | return polygon;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | template <>
|
|---|
| 131 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<7>()
|
|---|
| 132 | {
|
|---|
| 133 | Polygon_t polygon;
|
|---|
| 134 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 135 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 136 | polygon.push_back( Vector(0.0, Bondlength, 0.0));
|
|---|
| 137 | polygon.push_back( Vector(0.0, Bondlength*cos(M_PI*0.4), Bondlength*sin(M_PI*0.4)));
|
|---|
| 138 | polygon.push_back( Vector(0.0, Bondlength*cos(M_PI*0.8), Bondlength*sin(M_PI*0.8)));
|
|---|
| 139 | polygon.push_back( Vector(0.0, Bondlength*cos(M_PI*1.2), Bondlength*sin(M_PI*1.2)));
|
|---|
| 140 | polygon.push_back( Vector(0.0, Bondlength*cos(M_PI*1.6), Bondlength*sin(M_PI*1.6)));
|
|---|
| 141 | ASSERT( polygon.size() == 7,
|
|---|
| 142 | "SphericalPointDistribution::get<7>() - polygon has wrong size.");
|
|---|
| 143 | return polygon;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | template <>
|
|---|
| 147 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<8>()
|
|---|
| 148 | {
|
|---|
| 149 | Polygon_t polygon;
|
|---|
| 150 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 151 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 152 | polygon.push_back( Vector(-Bondlength/3.0, Bondlength*2.0*M_SQRT2/3.0, 0.0));
|
|---|
| 153 | polygon.push_back( Vector(-Bondlength/3.0, -Bondlength*M_SQRT2/3.0, Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 154 | polygon.push_back( Vector(-Bondlength/3.0, -Bondlength*M_SQRT2/3.0, -Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 155 | polygon.push_back( Vector(Bondlength/3.0, -Bondlength*2.0*M_SQRT2/3.0, 0.0));
|
|---|
| 156 | polygon.push_back( Vector(Bondlength/3.0, Bondlength*M_SQRT2/3.0, -Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 157 | polygon.push_back( Vector(Bondlength/3.0, Bondlength*M_SQRT2/3.0, Bondlength*M_SQRT2/SQRT_3));
|
|---|
| 158 | ASSERT( polygon.size() == 8,
|
|---|
| 159 | "SphericalPointDistribution::get<8>() - polygon has wrong size.");
|
|---|
| 160 | return polygon;
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | template <>
|
|---|
| 164 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<9>()
|
|---|
| 165 | {
|
|---|
| 166 | Polygon_t polygon;
|
|---|
| 167 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 168 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), Bondlength*sin(0.4*M_PI), 0.0));
|
|---|
| 169 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), -Bondlength*sin(0.4*M_PI), 0.0));
|
|---|
| 170 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), 0.0, Bondlength*sin(0.4*M_PI)));
|
|---|
| 171 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), 0.0, -Bondlength*sin(0.4*M_PI)));
|
|---|
| 172 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), Bondlength*sin(0.8*M_PI)*sin(0.25*M_PI), Bondlength*sin(0.8*M_PI)*cos(0.25*M_PI)));
|
|---|
| 173 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), Bondlength*sin(0.8*M_PI)*sin(0.75*M_PI), Bondlength*sin(0.8*M_PI)*cos(0.75*M_PI)));
|
|---|
| 174 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), Bondlength*sin(0.8*M_PI)*sin(1.25*M_PI), Bondlength*sin(0.8*M_PI)*cos(1.25*M_PI)));
|
|---|
| 175 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), Bondlength*sin(0.8*M_PI)*sin(1.75*M_PI), Bondlength*sin(0.8*M_PI)*cos(1.75*M_PI)));
|
|---|
| 176 | ASSERT( polygon.size() == 9,
|
|---|
| 177 | "SphericalPointDistribution::get<9>() - polygon has wrong size.");
|
|---|
| 178 | return polygon;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | template <>
|
|---|
| 182 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<10>()
|
|---|
| 183 | {
|
|---|
| 184 | Polygon_t polygon;
|
|---|
| 185 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 186 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 187 | const double temp_Bondlength = Bondlength*0.5*SQRT_3;
|
|---|
| 188 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength, 0.0));
|
|---|
| 189 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, -temp_Bondlength, 0.0));
|
|---|
| 190 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, 0.0, temp_Bondlength));
|
|---|
| 191 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, 0.0, -temp_Bondlength));
|
|---|
| 192 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*sin(0.25*M_PI), temp_Bondlength*cos(0.25*M_PI)));
|
|---|
| 193 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*sin(0.75*M_PI), temp_Bondlength*cos(0.75*M_PI)));
|
|---|
| 194 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*sin(1.25*M_PI), temp_Bondlength*cos(1.25*M_PI)));
|
|---|
| 195 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*sin(1.75*M_PI), temp_Bondlength*cos(1.75*M_PI)));
|
|---|
| 196 | ASSERT( polygon.size() == 10,
|
|---|
| 197 | "SphericalPointDistribution::get<10>() - polygon has wrong size.");
|
|---|
| 198 | return polygon;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | template <>
|
|---|
| 202 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<11>()
|
|---|
| 203 | {
|
|---|
| 204 | Polygon_t polygon;
|
|---|
| 205 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 206 | {
|
|---|
| 207 | const double temp_Bondlength = Bondlength*sin(0.4*M_PI);
|
|---|
| 208 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), temp_Bondlength, 0.0));
|
|---|
| 209 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), temp_Bondlength*cos(0.4*M_PI), temp_Bondlength*sin(0.4*M_PI)));
|
|---|
| 210 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), temp_Bondlength*cos(0.8*M_PI), temp_Bondlength*sin(0.8*M_PI)));
|
|---|
| 211 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), temp_Bondlength*cos(1.2*M_PI), temp_Bondlength*sin(1.2*M_PI)));
|
|---|
| 212 | polygon.push_back( Vector(Bondlength*cos(0.4*M_PI), temp_Bondlength*cos(1.6*M_PI), temp_Bondlength*sin(1.6*M_PI)));
|
|---|
| 213 | }
|
|---|
| 214 | {
|
|---|
| 215 | const double temp_Bondlength = Bondlength*sin(0.8*M_PI);
|
|---|
| 216 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), temp_Bondlength*cos(0.2*M_PI), temp_Bondlength*sin(0.2*M_PI)));
|
|---|
| 217 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), temp_Bondlength*cos(0.6*M_PI), temp_Bondlength*sin(0.6*M_PI)));
|
|---|
| 218 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), temp_Bondlength*cos(1.0*M_PI), temp_Bondlength*sin(1.0*M_PI)));
|
|---|
| 219 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), temp_Bondlength*cos(1.4*M_PI), temp_Bondlength*sin(1.4*M_PI)));
|
|---|
| 220 | polygon.push_back( Vector(Bondlength*cos(0.8*M_PI), temp_Bondlength*cos(1.8*M_PI), temp_Bondlength*sin(1.8*M_PI)));
|
|---|
| 221 | }
|
|---|
| 222 | ASSERT( polygon.size() == 11,
|
|---|
| 223 | "SphericalPointDistribution::get<11>() - polygon has wrong size.");
|
|---|
| 224 | return polygon;
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | template <>
|
|---|
| 228 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<12>()
|
|---|
| 229 | {
|
|---|
| 230 | Polygon_t polygon;
|
|---|
| 231 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 232 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 233 | const double temp_Bondlength = Bondlength*0.5*SQRT_3;
|
|---|
| 234 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength, 0.0));
|
|---|
| 235 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(0.4*M_PI), temp_Bondlength*sin(0.4*M_PI)));
|
|---|
| 236 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(0.8*M_PI), temp_Bondlength*sin(0.8*M_PI)));
|
|---|
| 237 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(1.2*M_PI), temp_Bondlength*sin(1.2*M_PI)));
|
|---|
| 238 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(1.6*M_PI), temp_Bondlength*sin(1.6*M_PI)));
|
|---|
| 239 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, -temp_Bondlength, 0.0));
|
|---|
| 240 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, -temp_Bondlength*cos(0.4*M_PI), -temp_Bondlength*sin(0.4*M_PI)));
|
|---|
| 241 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, -temp_Bondlength*cos(0.8*M_PI), -temp_Bondlength*sin(0.8*M_PI)));
|
|---|
| 242 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, -temp_Bondlength*cos(1.2*M_PI), -temp_Bondlength*sin(1.2*M_PI)));
|
|---|
| 243 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, -temp_Bondlength*cos(1.6*M_PI), -temp_Bondlength*sin(1.6*M_PI)));
|
|---|
| 244 | ASSERT( polygon.size() == 12,
|
|---|
| 245 | "SphericalPointDistribution::get<12>() - polygon has wrong size.");
|
|---|
| 246 | return polygon;
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | template <>
|
|---|
| 250 | SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<14>()
|
|---|
| 251 | {
|
|---|
| 252 | Polygon_t polygon;
|
|---|
| 253 | polygon.push_back( Vector(Bondlength,0.,0.));
|
|---|
| 254 | polygon.push_back( Vector(-Bondlength, 0.0, 0.0));
|
|---|
| 255 | const double temp_Bondlength = Bondlength*0.5*SQRT_3;
|
|---|
| 256 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength, 0.0));
|
|---|
| 257 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(M_PI/3.0), temp_Bondlength*sin(M_PI/3.0)));
|
|---|
| 258 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(2.0*M_PI/3.0), temp_Bondlength*sin(2.0*M_PI/3.0)));
|
|---|
| 259 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, -temp_Bondlength, 0.0));
|
|---|
| 260 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(4.0*M_PI/3.0), temp_Bondlength*sin(4.0*M_PI/3.0)));
|
|---|
| 261 | polygon.push_back( Vector(temp_Bondlength/SQRT_3, temp_Bondlength*cos(5.0*M_PI/3.0), temp_Bondlength*sin(5.0*M_PI/3.0)));
|
|---|
| 262 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(M_PI/6.0), temp_Bondlength*sin(M_PI/6.0)));
|
|---|
| 263 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(M_PI/3.0 +M_PI/6.0), temp_Bondlength*sin(M_PI/3.0+M_PI/6.0)));
|
|---|
| 264 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(2.0*M_PI/3.0 +M_PI/6.0), temp_Bondlength*sin(2.0*M_PI/3.0 +M_PI/6.0)));
|
|---|
| 265 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(3.0*M_PI/3.0 +M_PI/6.0), temp_Bondlength*sin(3.0*M_PI/3.0 +M_PI/6.0)));
|
|---|
| 266 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(4.0*M_PI/3.0 +M_PI/6.0), temp_Bondlength*sin(4.0*M_PI/3.0 +M_PI/6.0)));
|
|---|
| 267 | polygon.push_back( Vector(-temp_Bondlength/SQRT_3, temp_Bondlength*cos(5.0*M_PI/3.0 +M_PI/6.0), temp_Bondlength*sin(5.0*M_PI/3.0 +M_PI/6.0)));
|
|---|
| 268 | ASSERT( polygon.size() == 14,
|
|---|
| 269 | "SphericalPointDistribution::get<14>() - polygon has wrong size.");
|
|---|
| 270 | return polygon;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | #endif /* SPHERICALPOINTDISTRIBUTION_HPP_ */
|
|---|