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