[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3476] contrib/py/scripts/addons/ add_mesh_clusters:
Clemens Barth
barth at root-1.de
Fri Jun 8 19:57:15 CEST 2012
Revision: 3476
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3476
Author: blendphys
Date: 2012-06-08 17:57:07 +0000 (Fri, 08 Jun 2012)
Log Message:
-----------
New cluster shape: Icosahedron
The Icosahedron has a special shape and is important for nanometer sized
clusters in physics. It has (111) facets and a specific atomic lattice.
Blendphys.
Modified Paths:
--------------
contrib/py/scripts/addons/add_mesh_clusters/__init__.py
contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py
Modified: contrib/py/scripts/addons/add_mesh_clusters/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/__init__.py 2012-06-08 09:00:03 UTC (rev 3475)
+++ contrib/py/scripts/addons/add_mesh_clusters/__init__.py 2012-06-08 17:57:07 UTC (rev 3476)
@@ -18,24 +18,25 @@
#
# Main author : Clemens Barth (Blendphys at root-1.de)
-# Authors : Clemens Barth, ...
+# Authors : Clemens Barth, Christine Mottet (Icosahedra), ...
#
# Homepage(Wiki) : http://development.root-1.de/Atomic_Blender.php
# Tracker : ...
#
# Start of project : 2012-03-25 by Clemens Barth
-# First publication in Blender : 2012-05-27
-# Last modified : 2012-05-27
+# First publication in Blender : 2012-05-27 by Clemens Barth
+# Last modified : 2012-06-08
#
#
#
# To do:
# ======
#
-# 1. Include other shapes: icosahedron, dodecahedron
-# 2. ...
+# 1. Include other shapes: dodecahedron, ...
+# 2. Skin option for parabolic shaped clusters
+# 3. Skin option for icosahedron
+# 4. Icosahedron: unlimited size ...
#
-#
bl_info = {
"name": "Atomic Blender - Cluster",
@@ -118,6 +119,9 @@
row.prop(scn, "parabol_diameter")
row = box.row()
row.prop(scn, "parabol_height")
+ elif scn.shape in ["icosahedron"]:
+ row = box.row()
+ row.prop(scn, "icosahedron_size")
else:
row = box.row()
row.prop(scn, "size")
@@ -189,6 +193,9 @@
parabol_height = FloatProperty(
name = "Height", default=30.0, min=0.1,
description = "Height in Angstroem")
+ icosahedron_size = IntProperty(
+ name = "Size", default=1, min=1, max=13,
+ description = "Size n: 1 (13 atoms), 2 (55 atoms), 3 (147 atoms), 4 (309 atoms), 5 (561 atoms), ..., 13 (8217 atoms)")
shape = EnumProperty(
name="",
description="Choose the shape of the cluster",
@@ -199,12 +206,13 @@
('pyramide_hex_abc', "Pyramide - Tetraeder", "Pyramide: tetraeder (abcabc-lattice)"),
('octahedron', "Octahedron", "Octahedron"),
('truncated_octahedron', "Truncated octahedron", "Truncated octahedron"),
+ ('icosahedron', "Icosahedron", "Icosahedron"),
('parabolid_square', "Paraboloid: square", "Paraboloid with square lattice"),
('parabolid_ab', "Paraboloid: hex ab", "Paraboloid with ab-lattice"),
('parabolid_abc', "Paraboloid: hex abc", "Paraboloid with abc-lattice")),
default='sphere_square',)
lattice_parameter = FloatProperty(
- name = "Lattice", default=4.0, min=1.0,
+ name = "Lattice", default=4.08, min=1.0,
description = "Lattice parameter in Angstroem")
element = StringProperty(name="Element",
default="Gold", description = "Enter the name of the element")
@@ -269,6 +277,8 @@
elif scn.shape in ["octahedron", "truncated_octahedron"]:
parameter1 = scn.size * 1.4
parameter2 = scn.skin
+ elif scn.shape in ["icosahedron"]:
+ parameter1 = scn.icosahedron_size
else:
parameter1 = scn.size
parameter2 = scn.skin
@@ -294,6 +304,11 @@
parameter2,
scn.lattice_parameter)
+ if scn.shape in ["icosahedron"]:
+ numbers = add_mesh_cluster.create_icosahedron(
+ parameter1,
+ scn.lattice_parameter)
+
DEF_atom_draw_atoms(scn.element,
scn.radius_type,
scn.scale_radius,
Modified: contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py 2012-06-08 09:00:03 UTC (rev 3475)
+++ contrib/py/scripts/addons/add_mesh_clusters/add_mesh_cluster.py 2012-06-08 17:57:07 UTC (rev 3476)
@@ -1075,3 +1075,247 @@
print("Atom positions calculated")
return (atom_number_total, atom_number_drawn)
+
+
+
+# -----------------------------------------------------------------------------
+# Routine for the icosahedron
+
+
+# Note that the icosahedron needs a special treatment since it requires a
+# non-common crystal lattice. The faces are (111) facets and the geometry
+# is five-fold. So far, a max size of 8217 atoms can be chosen.
+# More details can be found in:
+#
+# 1. C. Mottet, G. Tréglia, B. Legrand, Surface Science 383 (1997) L719-L727
+# 2. C. R. Henry, Surface Science Reports 31 (1998) 231-325
+
+# This routine is a translation from an existing Fortran code into Python.
+# The Fortran code has been created by Christine Mottet and translated by
+# Clemens Barth.
+
+# Although a couple of code lines are non-typical for Python, it is best to
+# leave the code as is.
+#
+# To do:
+#
+# 1. Unlimited cluster size
+# 2. Skin effect
+
+def create_icosahedron(size, lattice):
+
+ natot = int(1 + (10*size*size+15*size+11)*size/3)
+
+ x = list(range(natot+1))
+ y = list(range(natot+1))
+ z = list(range(natot+1))
+
+ xs = list(range(12+1))
+ ys = list(range(12+1))
+ zs = list(range(12+1))
+
+ xa = [[[ [] for i in range(12+1)] for j in range(12+1)] for k in range(20+1)]
+ ya = [[[ [] for i in range(12+1)] for j in range(12+1)] for k in range(20+1)]
+ za = [[[ [] for i in range(12+1)] for j in range(12+1)] for k in range(20+1)]
+
+ naret = [[ [] for i in range(12+1)] for j in range(12+1)]
+ nfacet = [[[ [] for i in range(12+1)] for j in range(12+1)] for k in range(12+1)]
+
+ rac2 = sqrt(2.0)
+ rac5 = sqrt(5.0)
+ tdef = (rac5+1.0)/2.0
+
+ rapp = sqrt(2.0*(1.0-tdef/(tdef*tdef+1.0)))
+ nats = 2 * (5*size*size+1)
+ nat = 13
+ epsi = 0.01
+
+ x[1] = 0.0
+ y[1] = 0.0
+ z[1] = 0.0
+
+ for i in range(2, 5+1):
+ z[i] = 0.0
+ y[i+4] = 0.0
+ x[i+8] = 0.0
+
+ for i in range(2, 3+1):
+ x[i] = tdef
+ x[i+2] = -tdef
+ x[i+4] = 1.0
+ x[i+6] = -1.0
+ y[i+8] = tdef
+ y[i+10] = -tdef
+
+ for i in range(2, 4+1, 2):
+ y[i] = 1.0
+ y[i+1] = -1.0
+ z[i+4] = tdef
+ z[i+5] = -tdef
+ z[i+8] = 1.0
+ z[i+9] = -1.0
+
+ xdef = rac2 / sqrt(tdef * tdef + 1)
+
+ for i in range(2, 13+1):
+ x[i] = x[i] * xdef / 2.0
+ y[i] = y[i] * xdef / 2.0
+ z[i] = z[i] * xdef / 2.0
+
+ if size > 1:
+
+ for n in range (2, size+1):
+ ifacet = 0
+ iaret = 0
+ inatf = 0
+ for i in range(1, 12+1):
+ for j in range(1, 12+1):
+ naret[i][j] = 0
+ for k in range (1, 12+1):
+ nfacet[i][j][k] = 0
+
+ nl1 = 6
+ nl2 = 8
+ nl3 = 9
+ k1 = 0
+ k2 = 0
+ k3 = 0
+ k12 = 0
+ for i in range(1, 12+1):
+ nat += 1
+ xs[i] = n * x[i+1]
+ ys[i] = n * y[i+1]
+ zs[i] = n * z[i+1]
+ x[nat] = xs[i]
+ y[nat] = ys[i]
+ z[nat] = zs[i]
+ k1 += 1
+
+ for i in range(1, 12+1):
+ for j in range(2, 12+1):
+ if j <= i:
+ continue
+
+ xij = xs[j] - xs[i]
+ yij = ys[j] - ys[i]
+ zij = zs[j] - zs[i]
+ xij2 = xij * xij
+ yij2 = yij * yij
+ zij2 = zij * zij
+ dij2 = xij2 + yij2 + zij2
+ dssn = n * rapp / rac2
+ dssn2 = dssn * dssn
+ diffij = abs(dij2-dssn2)
+ if diffij >= epsi:
+ continue
+
+ for k in range(3, 12+1):
+ if k <= j:
+ continue
+
+ xjk = xs[k] - xs[j]
+ yjk = ys[k] - ys[j]
+ zjk = zs[k] - zs[j]
+ xjk2 = xjk * xjk
+ yjk2 = yjk * yjk
+ zjk2 = zjk * zjk
+ djk2 = xjk2 + yjk2 + zjk2
+ diffjk = abs(djk2-dssn2)
+ if diffjk >= epsi:
+ continue
+
+ xik = xs[k] - xs[i]
+ yik = ys[k] - ys[i]
+ zik = zs[k] - zs[i]
+ xik2 = xik * xik
+ yik2 = yik * yik
+ zik2 = zik * zik
+ dik2 = xik2 + yik2 + zik2
+ diffik = abs(dik2-dssn2)
+ if diffik >= epsi:
+ continue
+
+ if nfacet[i][j][k] != 0:
+ continue
+
+ ifacet += 1
+ nfacet[i][j][k] = ifacet
+
+ if naret[i][j] == 0:
+ iaret += 1
+ naret[i][j] = iaret
+ for l in range(1,n-1+1):
+ nat += 1
+ xa[i][j][l] = xs[i]+l*(xs[j]-xs[i]) / n
+ ya[i][j][l] = ys[i]+l*(ys[j]-ys[i]) / n
+ za[i][j][l] = zs[i]+l*(zs[j]-zs[i]) / n
+ x[nat] = xa[i][j][l]
+ y[nat] = ya[i][j][l]
+ z[nat] = za[i][j][l]
+
+ if naret[i][k] == 0:
+ iaret += 1
+ naret[i][k] = iaret
+ for l in range(1, n-1+1):
+ nat += 1
+ xa[i][k][l] = xs[i]+l*(xs[k]-xs[i]) / n
+ ya[i][k][l] = ys[i]+l*(ys[k]-ys[i]) / n
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list