summaryrefslogtreecommitdiff
path: root/profiles/hamamatsu_12inch.py
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-07-19 15:09:50 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-07-19 15:09:50 -0400
commitf5a328b72ebb643b51cae41a991c934da712f0e5 (patch)
treef90f89c335743d0da239cf413fcca09fb711acd0 /profiles/hamamatsu_12inch.py
parent842e3a9dfecdd6411b1f27084ab6dcbe92fa32b9 (diff)
downloadchroma-f5a328b72ebb643b51cae41a991c934da712f0e5.tar.gz
chroma-f5a328b72ebb643b51cae41a991c934da712f0e5.tar.bz2
chroma-f5a328b72ebb643b51cae41a991c934da712f0e5.zip
removed STL pmt models; pmt models are now built by calling rotate_extrude() on a profile of the PMT model (see build_pmt() in solids/pmts.py). triangle intersection now allows one of the two coefficients multiplying the vectors which span the triangle to float slightly negative (up to -EPSILON; EPSILON is defined in src/intersect.h) in order to eliminate rays passing through the line between two triangles. cleaned up a lot of unused code. pulled duplicate code in view() and render() into functions in view.py. in order to allow view.py and render.py to search pre-defined geometries, solids, meshes, etc. without requiring them to be pre-built, pre-defined geometries, solids, meshes, etc. should be returned by a function tagged by the decorator @buildable(identifier) defined in view.py, where identifier is a string used to identify the object as an argument to either view.py or render.py. optical materials and surfaces are now defined in optics.py. added an image directory to save cool screenshots.
Diffstat (limited to 'profiles/hamamatsu_12inch.py')
-rw-r--r--profiles/hamamatsu_12inch.py112
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)