summaryrefslogtreecommitdiff
path: root/detectors
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 /detectors
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 'detectors')
-rw-r--r--detectors/__init__.py23
-rw-r--r--detectors/lbne.py90
2 files changed, 57 insertions, 56 deletions
diff --git a/detectors/__init__.py b/detectors/__init__.py
index eeb2e07..2d7f250 100644
--- a/detectors/__init__.py
+++ b/detectors/__init__.py
@@ -1,4 +1,12 @@
-from lbne import LBNE
+from lbne import build_lbne
+
+import os
+import sys
+
+dir = os.path.split(os.path.realpath(__file__))[0]
+sys.path.append(dir + '/..')
+
+from view import buildable
# from Water Cherenkov case study
radius = 65.0/2
@@ -7,11 +15,10 @@ nstrings = 229
pmts_per_string = 90
endcap_spacing = 0.8912
-minilbne = LBNE(radius/10, height/10, nstrings//10, pmts_per_string//10, endcap_spacing)
-microlbne = LBNE(radius/40, height/40, nstrings//40, pmts_per_string//40, endcap_spacing)
+@buildable('lbne')
+def build_lbne_200kton():
+ return build_lbne(radius, height, nstrings, pmts_per_string, endcap_spacing)
-minilbne_cut = LBNE(radius/10, height/10, nstrings//10, pmts_per_string//10, endcap_spacing,
- cut_pmt=True)
-microlbne_cut = LBNE(radius/40, height/40, nstrings//40, pmts_per_string//40, endcap_spacing,
- cut_pmt=True)
-lbne_cut = LBNE(radius, height, nstrings, pmts_per_string, endcap_spacing, cut_pmt=True)
+@buildable('minilbne')
+def build_minilbne():
+ return build_lbne(radius/10, height/10, nstrings//10, pmts_per_string//10, endcap_spacing)
diff --git a/detectors/lbne.py b/detectors/lbne.py
index 2833ebe..2b940d6 100644
--- a/detectors/lbne.py
+++ b/detectors/lbne.py
@@ -5,54 +5,48 @@ import numpy as np
dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.append(dir + '/..')
-import models
from geometry import *
-from materials import *
-from solids import *
+from solids import build_12inch_pmt, build_12inch_pmt_with_lc
+from optics import *
from transform import rotate, make_rotation_matrix
from itertools import product
-import make
-
-class LBNE(Geometry):
- def __init__(self, radius, height, nstrings, pmts_per_string, endcap_spacing,
- cut_pmt=False):
- super(LBNE, self).__init__()
-
- if cut_pmt:
- pmt_mesh = r11708_cut
- else:
- pmt_mesh = r11708
-
- # outer cylinder
- cylinder_mesh = \
- make.cylinder(radius, radius, height+height/(pmts_per_string-1))
- cylinder_mesh.vertices = rotate(cylinder_mesh.vertices, np.pi/2, (-1,0,0))
- cylinder_solid = Solid(cylinder_mesh, lightwater_sno, vacuum, black_surface, 0x0000ff)
- self.add_solid(cylinder_solid)
-
- self.pmtids = []
-
- # construct the barrel
- for i in range(pmts_per_string):
- for j in range(nstrings):
- rotation = make_rotation_matrix(j*2*np.pi/nstrings, (0,0,1))
- displacement = rotate((0,-radius,-height/2+i*height/(pmts_per_string-1)), j*2*np.pi/nstrings, (0,0,1))
- self.pmtids.append(self.add_solid(pmt_mesh, rotation, displacement))
-
- # construct the top endcap
- for x, y in np.array(tuple(product(\
- np.arange(-radius+0.075, radius, endcap_spacing),
- np.arange(-radius+0.075, radius, endcap_spacing)))):
- if np.sqrt(x**2 + y**2) <= radius:
- rotation = make_rotation_matrix(+np.pi/2, (1,0,0))
- displacement = (x,y,+height/2+height/(pmts_per_string-1)/2)
- self.pmtids.append(self.add_solid(pmt_mesh, rotation, displacement))
-
- # construct the bottom endcap
- for x, y in np.array(tuple(product(\
- np.arange(-radius+0.075, radius, endcap_spacing),
- np.arange(-radius+0.075, radius, endcap_spacing)))):
- if np.sqrt(x**2 + y**2) <= radius:
- rotation = make_rotation_matrix(-np.pi/2, (1,0,0))
- displacement = (x,y,-height/2-height/(pmts_per_string-1)/2)
- self.pmtids.append(self.add_solid(pmt_mesh, rotation, displacement))
+from make import cylinder
+
+def build_lbne(radius, height, nstrings, pmts_per_string, endcap_spacing):
+ pmt = build_12inch_pmt_with_lc()
+
+ lbne = Geometry()
+
+ # outer cylinder
+ cylinder_mesh = cylinder(radius, radius, height+height/(pmts_per_string-1))
+ cylinder_mesh.vertices = rotate(cylinder_mesh.vertices, np.pi/2, (-1,0,0))
+ lbne.add_solid(Solid(cylinder_mesh, water, vacuum, black_surface, 0xff))
+
+ lbne.pmtids = []
+
+ # construct the barrel
+ for i in range(pmts_per_string):
+ for j in range(nstrings):
+ rotation = make_rotation_matrix(j*2*np.pi/nstrings, (0,0,1))
+ displacement = rotate((0,-radius,-height/2+i*height/(pmts_per_string-1)), j*2*np.pi/nstrings, (0,0,1))
+ lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement))
+
+ # construct the top endcap
+ for x, y in np.array(tuple(product(\
+ np.arange(-radius+0.075, radius, endcap_spacing),
+ np.arange(-radius+0.075, radius, endcap_spacing)))):
+ if np.sqrt(x**2 + y**2) < radius - endcap_spacing/2:
+ rotation = make_rotation_matrix(+np.pi/2, (1,0,0))
+ displacement = (x,y,+height/2+height/(pmts_per_string-1)/2)
+ lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement))
+
+ # construct the bottom endcap
+ for x, y in np.array(tuple(product(\
+ np.arange(-radius+0.075, radius, endcap_spacing),
+ np.arange(-radius+0.075, radius, endcap_spacing)))):
+ if np.sqrt(x**2 + y**2) < radius - endcap_spacing/2:
+ rotation = make_rotation_matrix(-np.pi/2, (1,0,0))
+ displacement = (x,y,-height/2-height/(pmts_per_string-1)/2)
+ lbne.pmtids.append(lbne.add_solid(pmt, rotation, displacement))
+
+ return lbne