1 |
gezelter |
1862 |
/* |
2 |
|
|
* Copyright (c) 2013 The University of Notre Dame. All Rights Reserved. |
3 |
|
|
* |
4 |
|
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
|
|
* 1. Redistributions of source code must retain the above copyright |
10 |
|
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
|
* |
12 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
|
* documentation and/or other materials provided with the |
15 |
|
|
* distribution. |
16 |
|
|
* |
17 |
|
|
* This software is provided "AS IS," without a warranty of any |
18 |
|
|
* kind. All express or implied conditions, representations and |
19 |
|
|
* warranties, including any implied warranty of merchantability, |
20 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
21 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
22 |
|
|
* be liable for any damages suffered by licensee as a result of |
23 |
|
|
* using, modifying or distributing the software or its |
24 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
25 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
26 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
27 |
|
|
* damages, however caused and regardless of the theory of liability, |
28 |
|
|
* arising out of the use of or inability to use software, even if the |
29 |
|
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
|
* such damages. |
31 |
|
|
* |
32 |
|
|
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
|
|
* research, please cite the appropriate papers when you publish your |
34 |
|
|
* work. Good starting points are: |
35 |
|
|
* |
36 |
|
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
39 |
|
|
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
|
*/ |
42 |
|
|
|
43 |
|
|
#include "clusters/Decahedron.hpp" |
44 |
|
|
|
45 |
|
|
using namespace std; |
46 |
|
|
|
47 |
|
|
namespace OpenMD { |
48 |
|
|
|
49 |
|
|
Decahedron::Decahedron(int columnAtoms, int shells, int twinAtoms) : |
50 |
|
|
N_(columnAtoms), M_(shells), K_(twinAtoms) { |
51 |
|
|
|
52 |
|
|
Basis.clear(); |
53 |
|
|
Points.clear(); |
54 |
|
|
|
55 |
|
|
// |
56 |
|
|
// Initialize Basis vectors. |
57 |
|
|
// |
58 |
|
|
const RealType phi = 2.0 * M_PI / 5.0; // 72 degrees |
59 |
|
|
const RealType r3o2 = 0.5 * sqrt(3.0); |
60 |
|
|
|
61 |
|
|
Basis.push_back( Vector3d( r3o2*cos(0.0*phi), r3o2*sin(0.0*phi), 0.0 )); |
62 |
|
|
Basis.push_back( Vector3d( r3o2*cos(1.0*phi), r3o2*sin(1.0*phi), 0.0 )); |
63 |
|
|
Basis.push_back( Vector3d( r3o2*cos(2.0*phi), r3o2*sin(2.0*phi), 0.0 )); |
64 |
|
|
Basis.push_back( Vector3d( r3o2*cos(3.0*phi), r3o2*sin(3.0*phi), 0.0 )); |
65 |
|
|
Basis.push_back( Vector3d( r3o2*cos(4.0*phi), r3o2*sin(4.0*phi), 0.0 )); |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
Decahedron::~Decahedron() { |
69 |
|
|
Basis.clear(); |
70 |
|
|
Points.clear(); |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
vector<Vector3d> Decahedron::getPoints() { |
74 |
|
|
// Generate central column of Decahedron |
75 |
|
|
|
76 |
|
|
for (int i = 0; i < N_; i++) { |
77 |
|
|
Points.push_back( Vector3d( 0.0, 0.0, RealType(i) - 0.5 * (N_ - 1) ) ); |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
for (int i = 1; i < M_ + 1; i++) { |
81 |
|
|
// generate the shells of the decahedron: |
82 |
|
|
|
83 |
|
|
vector<Vector3d> ring; |
84 |
|
|
|
85 |
|
|
if (i > K_ - 1) { |
86 |
|
|
ring = truncatedRing(i, i - K_ + 1); |
87 |
|
|
} else { |
88 |
|
|
ring = truncatedRing(i, 0); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
// shift the rings in the z-direction (along the shell) |
92 |
|
|
|
93 |
|
|
for (int j = 0; j < N_ - i; j++) { |
94 |
|
|
Vector3d shift = Vector3d(0, 0, -0.5 * RealType((N_-i)-1) + RealType(j)); |
95 |
|
|
|
96 |
|
|
for (vector<Vector3d>::iterator k = ring.begin(); |
97 |
|
|
k != ring.end(); ++k) { |
98 |
|
|
|
99 |
|
|
Points.push_back( (*k) + shift); |
100 |
|
|
|
101 |
|
|
} |
102 |
|
|
} |
103 |
|
|
} |
104 |
|
|
return Points; |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
vector<Vector3d> Decahedron::truncatedRing( int n, int k ) { |
108 |
|
|
// This function generates the rings of a Decahedron |
109 |
|
|
// n: index of shell (order of ring) |
110 |
|
|
// k: how many atoms are missing from both ends of one side of |
111 |
|
|
// pentagon ring |
112 |
|
|
|
113 |
|
|
vector<Vector3d> ring; |
114 |
|
|
|
115 |
|
|
// Generate atomic coordinates along each side of pentagonal ring |
116 |
|
|
for (int i = 0; i < 5; i++) { |
117 |
|
|
|
118 |
|
|
Vector3d b1 = Basis[i]; |
119 |
|
|
Vector3d b2 = Basis[(i + 1) % 5]; |
120 |
|
|
|
121 |
|
|
if (k == 0) { |
122 |
|
|
// without truncation |
123 |
|
|
for (int j = 0; j < n; j++) { |
124 |
|
|
ring.push_back( RealType(n) * b1 + RealType(j) * (b2-b1)); |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
} else { |
128 |
|
|
for (int j = k; j <= n - k; j++) { |
129 |
|
|
// with truncation |
130 |
|
|
ring.push_back( RealType(n) * b1 + RealType(j) * (b2-b1)); |
131 |
|
|
} |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
return ring; |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
CurlingStoneDecahedron::CurlingStoneDecahedron(int columnAtoms, int shells, |
138 |
|
|
int twinAtoms, |
139 |
|
|
int truncatedPlanes) : |
140 |
|
|
Decahedron(columnAtoms, shells, twinAtoms), T_(truncatedPlanes) {} |
141 |
|
|
|
142 |
|
|
vector<Vector3d> CurlingStoneDecahedron::getPoints() { |
143 |
|
|
|
144 |
|
|
vector<Vector3d> raw = Decahedron::getPoints(); |
145 |
|
|
vector<Vector3d> snipped; |
146 |
|
|
RealType maxZ, minZ; |
147 |
|
|
|
148 |
|
|
maxZ = raw.begin()->z(); |
149 |
|
|
minZ = raw.begin()->z(); |
150 |
|
|
|
151 |
|
|
for (vector<Vector3d>::iterator i = raw.begin(); i != raw.end(); ++i) { |
152 |
|
|
maxZ = max(maxZ, (*i).z()); |
153 |
|
|
minZ = min(minZ, (*i).z()); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
for (vector<Vector3d>::iterator i = raw.begin(); i != raw.end(); ++i) { |
157 |
|
|
if ( ((*i).z() < maxZ - 0.995 * (T_ / 2.0) ) && |
158 |
|
|
((*i).z() > minZ + 0.995 * (T_ / 2.0) ) ){ |
159 |
|
|
snipped.push_back( (*i) ); |
160 |
|
|
} |
161 |
|
|
} |
162 |
|
|
return snipped; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
} |