summaryrefslogtreecommitdiff
path: root/profiles
diff options
context:
space:
mode:
Diffstat (limited to 'profiles')
-rw-r--r--profiles/hamamatsu_12inch.py112
-rw-r--r--profiles/hamamatsu_12inch.txt55
-rw-r--r--profiles/test.py3
3 files changed, 170 insertions, 0 deletions
diff --git a/profiles/hamamatsu_12inch.py b/profiles/hamamatsu_12inch.py
new file mode 100644
index 0000000..c52c029
--- /dev/null
+++ b/profiles/hamamatsu_12inch.py
@@ -0,0 +1,112 @@
+import os
+import sys
+
+dir = os.path.split(os.path.realpath(__file__))[0]
+sys.path.append(dir + '/..')
+
+import numpy as np
+from geometry import Solid
+from make import *
+from view import *
+import matplotlib.pyplot as plt
+from materials import *
+
+f = open('hamamatsu_12inch.txt')
+
+points = []
+for line in f:
+ try:
+ points.append([float(s) for s in line.split(',')])
+ except ValueError:
+ pass
+
+points = np.array(points)
+
+# slice profile in half
+points = points[points[:,0] < 0]
+points[:,0] = -points[:,0]
+# order points from base to face
+points = points[np.argsort(points[:,1])]
+# set x coordinate to 0.0 for first and last points along the profile
+# so that the mesh is closed
+points[0,0] = 0.0
+points[-1,0] = 0.0
+# convert mm -> m
+points /= 1000.0
+
+def offset(points, x):
+ points = np.array([points[0] - (points[1] - points[0])] + list(points) + [points[-1] - (points[-2] - points[-1])])
+
+ offset_points = []
+ for i in range(1,len(points)-1):
+ print '%i' % i
+
+ v1 = np.cross(points[i]-points[i-1], (0,0,1))[:2]
+ v1 /= np.linalg.norm(v1)
+ v1 *= x
+
+ a = points[i-1] + v1
+ b = points[i] + v1
+
+ v2 = np.cross(points[i+1]-points[i], (0,0,1))[:2]
+ v2 /= np.linalg.norm(v2)
+ v2 *= x
+
+ c = points[i] + v2
+ d = points[i+1] + v2
+
+ m = np.empty((2,2))
+ m[:,0] = b-a
+ m[:,1] = c-d
+
+ try:
+ j = np.linalg.solve(m, c-a)[0]
+ except np.linalg.linalg.LinAlgError as e:
+ print e
+ offset_points.append(b)
+ continue
+
+ offset_points.append((a + j*(b-a)))
+
+ return np.array(offset_points)
+
+fig = plt.figure()
+ax = fig.add_subplot(111, aspect='equal')
+
+offset_points = offset(points, -.003)
+
+plt.plot(points[:,0], points[:,1], 'b-', offset_points[:,0], offset_points[:,1], 'g-')
+plt.show()
+
+pmt_outer_mesh = rotate_extrude(points[:,0], points[:,1], np.pi/8)
+pmt_inner_mesh = rotate_extrude(offset_points[:,0], offset_points[:,1], np.pi/8)
+
+# cutaway view
+pmt_outer_mesh.triangles = pmt_outer_mesh.triangles[np.mean(pmt_outer_mesh[:], axis=1)[:,0] > 0]
+
+#pmt_outer_mesh.triangles = pmt_outer_mesh.triangles[np.mean(pmt_outer_mesh[:], axis=1)[:,1] > -1e-3]
+#pmt_inner_mesh.triangles = pmt_inner_mesh.triangles[np.mean(pmt_inner_mesh[:], axis=1)[:,1] > -1e-3]
+
+pmt_outer_solid = Solid(pmt_outer_mesh)
+
+
+pmt_inner_solid = Solid(pmt_inner_mesh, color=0x00ff00)
+
+def get_lc_profile(radii, a, b, d, rmin, rmax):
+ c = -b*np.sqrt(1 - (rmin-d)**2/a**2)
+
+ return -c - b*np.sqrt(1-(radii-d)**2/a**2)
+
+lc_radii = np.linspace(152.4e-3, 209.672e-3 + 152.4e-3 - 127e-3, 10)
+lc_profile = get_lc_profile(lc_radii, 165.97e-3, 584.525e-3, 95.48e-3, 152.4e-3, 209.672e-3 + 152.4e-3 - 127e-3)
+
+face_points = points[points[:,1] > -1e-3]
+
+lc_offset = np.interp(lc_radii[0], list(reversed(face_points[:,0])), list(reversed(face_points[:,1])))
+
+lc_mesh = rotate_extrude(lc_radii, lc_profile + lc_offset, np.pi/8)
+lc_solid = Solid(lc_mesh, color=0xff0000, surface=shiny_surface)
+
+pmt_solid_lc = pmt_inner_solid + pmt_outer_solid + lc_solid
+
+view(pmt_solid_lc)
diff --git a/profiles/hamamatsu_12inch.txt b/profiles/hamamatsu_12inch.txt
new file mode 100644
index 0000000..e896b94
--- /dev/null
+++ b/profiles/hamamatsu_12inch.txt
@@ -0,0 +1,55 @@
+#DataThief /Users/stan/Downloads/./Dimension_of_12inch_bulb_100826.png Monday 16-May-2011 12:22:34 PM
+109.1514, 83.9786
+123.0527, 70.9583
+134.8946, 56.9466
+145.1919, 40.944
+150.8554, 23.4594
+152.4, 3.9922
+150.8554, -15.4649
+145.7067, -32.914
+136.4392, -49.3517
+123.0527, -64.2787
+108.6364, -75.2102
+92.1608, -86.1349
+76.2, -97.0612
+66.4176, -112.0001
+63.3284, -130.9531
+63.3284, -150.9143
+63.3284, -170.3764
+56.6351, -187.8206
+44.7932, -202.7527
+28.8324, -211.1839
+10.8122, -212.6219
+-9.2676, -213.5543
+-28.8324, -210.995
+-45.823, -201.9569
+-57.6649, -186.9473
+-63.8432, -169.96
+-63.8432, -150.4979
+-63.8432, -130.5367
+-66.4176, -111.0661
+-76.7149, -96.0615
+-93.1905, -85.0289
+-108.6364, -74.4987
+-123.0527, -63.4727
+-135.4095, -49.9586
+-144.677, -33.9593
+-150.3405, -16.4747
+-152.9149, 2.4968
+-151.3703, 21.4549
+-146.2216, 39.4031
+-136.4392, 55.34
+-124.0824, 70.2704
+-109.6662, 83.198
+-93.7054, 94.1244
+-76.7149, 103.0513
+-59.2095, 109.4813
+-40.6743, 113.9119
+-21.1095, 117.3411
+-1.0297, 118.2734
+19.05, 117.2096
+38.6149, 114.1513
+57.15, 109.5994
+75.1703, 103.053
+92.1608, 94.5138
+104.0027, 88.4867
diff --git a/profiles/test.py b/profiles/test.py
new file mode 100644
index 0000000..2ff3168
--- /dev/null
+++ b/profiles/test.py
@@ -0,0 +1,3 @@
+hello world
+
+hello world