diff options
Diffstat (limited to 'profiles/hamamatsu_12inch.py')
-rw-r--r-- | profiles/hamamatsu_12inch.py | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/profiles/hamamatsu_12inch.py b/profiles/hamamatsu_12inch.py deleted file mode 100644 index c52c029..0000000 --- a/profiles/hamamatsu_12inch.py +++ /dev/null @@ -1,112 +0,0 @@ -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) |