summaryrefslogtreecommitdiff
path: root/solids
diff options
context:
space:
mode:
Diffstat (limited to 'solids')
-rw-r--r--solids/__init__.py2
-rw-r--r--solids/hamamatsu_12inch.txt55
-rw-r--r--solids/pmts.py66
-rw-r--r--solids/r11708.py48
-rw-r--r--solids/r11708_cut.py48
5 files changed, 121 insertions, 98 deletions
diff --git a/solids/__init__.py b/solids/__init__.py
deleted file mode 100644
index f4c5812..0000000
--- a/solids/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from r11708 import r11708
-from r11708_cut import r11708_cut
diff --git a/solids/hamamatsu_12inch.txt b/solids/hamamatsu_12inch.txt
new file mode 100644
index 0000000..e896b94
--- /dev/null
+++ b/solids/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/solids/pmts.py b/solids/pmts.py
new file mode 100644
index 0000000..6b10522
--- /dev/null
+++ b/solids/pmts.py
@@ -0,0 +1,66 @@
+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 rotate_extrude
+from optics import *
+from tools import read_csv, offset
+
+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)
+
+def build_light_collector(pmt, a, b, d, rmin, rmax, npoints=10):
+ if not isinstance(pmt, Solid):
+ raise Exception('`pmt` must be an instance of %s' % Solid)
+
+ lc_radii = np.linspace(rmin, rmax, npoints)
+ lc_profile = get_lc_profile(lc_radii, a, b, d, rmin, rmax)
+
+ pmt_face_profile = pmt.profile[pmt.profile[:,1] > -1e-3]
+
+ lc_offset = np.interp(lc_radii[0], list(reversed(pmt_face_profile[:,0])), list(reversed(pmt_face_profile[:,1])))
+
+ lc_mesh = rotate_extrude(lc_radii, lc_profile + lc_offset, pmt.theta)
+
+ return Solid(lc_mesh, pmt.outer_material, pmt.outer_material, color=0xff0000, surface=shiny_surface)
+
+def build_pmt(filename, glass_thickness, outer_material=water, theta=np.pi/8):
+ profile = read_csv(filename)
+
+ # slice profile in half
+ profile = profile[profile[:,0] < 0]
+ profile[:,0] = -profile[:,0]
+ # order profile from base to face
+ profile = profile[np.argsort(profile[:,1])]
+ # set x coordinate to 0.0 for first and last profile along the profile
+ # so that the mesh is closed
+ profile[0,0] = 0.0
+ profile[-1,0] = 0.0
+ # convert mm -> m
+ profile /= 1000.0
+
+ offset_profile = offset(profile, -glass_thickness)
+
+ outer_envelope_mesh = rotate_extrude(profile[:,0], profile[:,1], theta)
+ inner_envelope_mesh = rotate_extrude(offset_profile[:,0], offset_profile[:,1], theta)
+
+ outer_envelope = Solid(outer_envelope_mesh, glass, outer_material)
+
+ photocathode = np.mean(inner_envelope_mesh[:], axis=1)[:,1] > 0
+
+ inner_envelope = Solid(inner_envelope_mesh, vacuum, glass, surface=np.where(photocathode, r7081hqe_photocathode, shiny_surface), color=np.where(photocathode, 0xff00, 0xff0000))
+
+ pmt = outer_envelope + inner_envelope
+
+ # profile points, outer_material, and theta are used to construct the
+ # light collector
+ pmt.profile = profile
+ pmt.outer_material = outer_material
+ pmt.theta = theta
+
+ return pmt
diff --git a/solids/r11708.py b/solids/r11708.py
deleted file mode 100644
index d1a5514..0000000
--- a/solids/r11708.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import os
-import sys
-import numpy as np
-
-dir = os.path.split(os.path.realpath(__file__))[0]
-sys.path.append(dir + '/..')
-
-import models
-from stl import mesh_from_stl
-from geometry import *
-from materials import *
-
-r11708_outer_mesh = mesh_from_stl(models.dir + '/hamamatsu_12inch_outer.stl')
-r11708_inner_mesh = mesh_from_stl(models.dir + '/hamamatsu_12inch_inner.stl')
-
-photocathode_triangles = np.mean(r11708_inner_mesh[:], axis=1)[:,1] > 0
-
-inner_color = np.empty(len(r11708_inner_mesh.triangles), np.uint32)
-inner_color[photocathode_triangles] = 0xff0000
-inner_color[~photocathode_triangles] = 0x00ff00
-
-inner_surface = np.empty(len(r11708_inner_mesh.triangles), np.object)
-inner_surface[photocathode_triangles] = r7081hqe_photocathode
-inner_surface[~photocathode_triangles] = shiny_surface
-
-r11708_inner_solid = Solid(r11708_inner_mesh, vacuum, glass, inner_surface, color=inner_color)
-r11708_outer_solid = Solid(r11708_outer_mesh, glass, lightwater_sno)
-
-r11708 = r11708_inner_solid + r11708_outer_solid
-
-if __name__ == '__main__':
- from view import view
- from copy import deepcopy
-
- r11708_outer_mesh_cutaway = deepcopy(r11708_outer_mesh)
- r11708_outer_mesh_cutaway.triangles = \
- r11708_outer_mesh_cutaway.triangles[\
- np.mean(r11708_outer_mesh_cutaway[:], axis=1)[:,0] > 0]
-
- r11708_outer_solid_cutaway = Solid(r11708_outer_mesh_cutaway, glass, lightwater_sno)
-
- r11708_cutaway = r11708_inner_solid + r11708_outer_solid_cutaway
-
- geometry = Geometry()
- geometry.add_solid(r11708_cutaway)
- geometry.build(bits=8)
-
- view(geometry, 'r11708_cutaway')
diff --git a/solids/r11708_cut.py b/solids/r11708_cut.py
deleted file mode 100644
index 14cfff0..0000000
--- a/solids/r11708_cut.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import os
-import sys
-import numpy as np
-
-dir = os.path.split(os.path.realpath(__file__))[0]
-sys.path.append(dir + '/..')
-
-import models
-from stl import mesh_from_stl
-from geometry import *
-from materials import *
-
-r11708_outer_mesh = mesh_from_stl(models.dir + '/hamamatsu_12inch_outer_cut.stl')
-r11708_inner_mesh = mesh_from_stl(models.dir + '/hamamatsu_12inch_inner_cut.stl')
-
-photocathode_triangles = np.mean(r11708_inner_mesh[:], axis=1)[:,1] > 0
-
-inner_color = np.empty(len(r11708_inner_mesh.triangles), np.uint32)
-inner_color[photocathode_triangles] = 0xff0000
-inner_color[~photocathode_triangles] = 0x00ff00
-
-inner_surface = np.empty(len(r11708_inner_mesh.triangles), np.object)
-inner_surface[photocathode_triangles] = r7081hqe_photocathode
-inner_surface[~photocathode_triangles] = shiny_surface
-
-r11708_inner_solid = Solid(r11708_inner_mesh, vacuum, glass, inner_surface, color=inner_color)
-r11708_outer_solid = Solid(r11708_outer_mesh, glass, lightwater_sno)
-
-r11708_cut = r11708_inner_solid + r11708_outer_solid
-
-if __name__ == '__main__':
- from view import view
- from copy import deepcopy
-
- r11708_outer_mesh_cutaway = deepcopy(r11708_outer_mesh)
- r11708_outer_mesh_cutaway.triangles = \
- r11708_outer_mesh_cutaway.triangles[\
- np.mean(r11708_outer_mesh_cutaway[:], axis=1)[:,0] > 0]
-
- r11708_outer_solid_cutaway = Solid(r11708_outer_mesh_cutaway, glass, lightwater_sno)
-
- r11708_cutaway = r11708_inner_solid + r11708_outer_solid_cutaway
-
- geometry = Geometry()
- geometry.add_solid(r11708_cutaway)
- geometry.build(bits=8)
-
- view(geometry, 'r11708_cutaway')