OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Icosahedron.cpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
46
47#include <tuple>
48
49namespace OpenMD {
50
52 Basis.clear();
53 Edges.clear();
54 Facets.clear();
55 Points.clear();
56
57 //
58 // Initialize Basis vectors.
59 //
60 const RealType HGR = (sqrt(5.0) + 1.0) / 4.0; // half of the golden ratio
61
62 Basis.push_back(Vector3d(HGR, 0.0, 0.5));
63 Basis.push_back(Vector3d(HGR, 0.0, -0.5));
64 Basis.push_back(Vector3d(0.5, HGR, 0.0));
65 Basis.push_back(Vector3d(-0.5, HGR, 0.0));
66 Basis.push_back(Vector3d(0.0, 0.5, HGR));
67 Basis.push_back(Vector3d(0.0, -0.5, HGR));
68 Basis.push_back(Vector3d(0.5, -HGR, 0.0));
69 Basis.push_back(Vector3d(0.0, 0.5, -HGR));
70 Basis.push_back(Vector3d(-HGR, 0.0, 0.5));
71 Basis.push_back(Vector3d(0.0, -0.5, -HGR));
72 Basis.push_back(Vector3d(-HGR, 0.0, -0.5));
73 Basis.push_back(Vector3d(-0.5, -HGR, 0.0));
74
75 //
76 // Initialize 30 edges
77 //
78
79 Edges.push_back(std::make_pair(0, 1));
80 Edges.push_back(std::make_pair(0, 2));
81 Edges.push_back(std::make_pair(0, 4));
82 Edges.push_back(std::make_pair(0, 5));
83 Edges.push_back(std::make_pair(0, 6));
84
85 Edges.push_back(std::make_pair(10, 3));
86 Edges.push_back(std::make_pair(10, 7));
87 Edges.push_back(std::make_pair(10, 8));
88 Edges.push_back(std::make_pair(10, 9));
89 Edges.push_back(std::make_pair(10, 11));
90
91 Edges.push_back(std::make_pair(1, 2));
92 Edges.push_back(std::make_pair(1, 6));
93 Edges.push_back(std::make_pair(1, 7));
94 Edges.push_back(std::make_pair(1, 9));
95
96 Edges.push_back(std::make_pair(8, 3));
97 Edges.push_back(std::make_pair(8, 4));
98 Edges.push_back(std::make_pair(8, 5));
99 Edges.push_back(std::make_pair(8, 11));
100
101 Edges.push_back(std::make_pair(2, 3));
102 Edges.push_back(std::make_pair(2, 4));
103 Edges.push_back(std::make_pair(2, 7));
104
105 Edges.push_back(std::make_pair(11, 5));
106 Edges.push_back(std::make_pair(11, 6));
107 Edges.push_back(std::make_pair(11, 9));
108
109 Edges.push_back(std::make_pair(6, 5));
110 Edges.push_back(std::make_pair(6, 9));
111
112 Edges.push_back(std::make_pair(3, 4));
113 Edges.push_back(std::make_pair(3, 7));
114
115 Edges.push_back(std::make_pair(7, 9));
116
117 Edges.push_back(std::make_pair(5, 4));
118
119 //
120 // Initialize 20 facets
121 //
122 Facets.push_back(std::make_tuple(0, 1, 2));
123 Facets.push_back(std::make_tuple(0, 2, 4));
124 Facets.push_back(std::make_tuple(0, 4, 5));
125 Facets.push_back(std::make_tuple(0, 5, 6));
126 Facets.push_back(std::make_tuple(0, 1, 6));
127
128 Facets.push_back(std::make_tuple(10, 3, 7));
129 Facets.push_back(std::make_tuple(10, 3, 8));
130 Facets.push_back(std::make_tuple(10, 8, 11));
131 Facets.push_back(std::make_tuple(10, 9, 11));
132 Facets.push_back(std::make_tuple(10, 7, 9));
133
134 Facets.push_back(std::make_tuple(1, 2, 7));
135 Facets.push_back(std::make_tuple(1, 7, 9));
136 Facets.push_back(std::make_tuple(1, 6, 9));
137
138 Facets.push_back(std::make_tuple(8, 5, 11));
139 Facets.push_back(std::make_tuple(8, 4, 5));
140 Facets.push_back(std::make_tuple(8, 3, 4));
141
142 Facets.push_back(std::make_tuple(2, 3, 7));
143 Facets.push_back(std::make_tuple(2, 3, 4));
144
145 Facets.push_back(std::make_tuple(11, 5, 6));
146 Facets.push_back(std::make_tuple(11, 6, 9));
147 }
148
150 int count = 0;
151 for (int i = 0; i <= n; i++)
152 count += np(i);
153 return count;
154 }
155
156 int Icosahedron::np(int n) {
157 if (n < 0)
158 return -1;
159 else if (n == 0)
160 return 1;
161 else if (n == 1)
162 return 12;
163 else if (n == 2)
164 return 42;
165 else {
166 int count = 0;
167 count += 12; // edge particles
168 count += (n - 1) * 30; // side particles
169 for (int i = 1; i <= n - 2; i++)
170 count += i * 20; // body particles
171 return count;
172 }
173 }
174
175 std::vector<Vector3d> Icosahedron::ih(int n) {
176 if (n < 0) return Points;
177
178 if (n == 0) {
179 // center particle only
180
181 Points.push_back(Vector3d(0.0, 0.0, 0.0));
182 return Points;
183 }
184
185 //
186 // Generate edge particles
187 //
188 for (std::vector<Vector3d>::iterator i = Basis.begin(); i != Basis.end();
189 ++i) {
190 Points.push_back((*i) * RealType(n));
191 }
192
193 //
194 // Generate side particles
195 //
196 if (n < 2) return Points;
197
198 for (std::vector<std::pair<int, int>>::iterator i = Edges.begin();
199 i != Edges.end(); ++i) {
200 Vector3d e1 = Basis[(*i).first] * RealType(n);
201 Vector3d e2 = Basis[(*i).second] * RealType(n);
202
203 for (int j = 1; j <= n - 1; j++) {
204 Points.push_back(e1 + (e2 - e1) * RealType(j) / RealType(n));
205 }
206 }
207
208 //
209 // Generate body particles
210 //
211 if (n < 3) return Points;
212
213 for (const auto& [first, second, third] : Facets) {
214 Vector3d e1 = Basis[first] * RealType(n);
215 Vector3d e2 = Basis[second] * RealType(n);
216 Vector3d e3 = Basis[third] * RealType(n);
217
218 for (int j = 1; j <= n - 2; j++) {
219 Vector3d v1 = e1 + (e2 - e1) * RealType(j + 1) / RealType(n);
220 Vector3d v2 = e1 + (e3 - e1) * RealType(j + 1) / RealType(n);
221
222 for (int k = 1; k <= j; k++) {
223 Points.push_back(v1 + (v2 - v1) * RealType(k) / RealType(j + 1));
224 }
225 }
226 }
227
228 return Points;
229 }
230
231 std::vector<Vector3d> Icosahedron::getPoints(int nshells) {
232 // generate the coordinates
233 for (int i = 0; i <= nshells; i++)
234 ih(i);
235 return Points;
236 }
237} // namespace OpenMD
Icosahedron cluster structure generator.
int np(int n)
Calculate number of particles on the nth layer.
Icosahedron()
Default constructor.
int getNpoints(int nShells)
Calculate number of particles in an icosahedron with nShells shells.
std::vector< Vector3d > getPoints(int nShells)
Get the generated points in an icosahedron with nShells shells.
std::vector< Vector3d > ih(int n)
Create nth layer particles.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.