summaryrefslogtreecommitdiff
path: root/chroma/demo
diff options
context:
space:
mode:
Diffstat (limited to 'chroma/demo')
-rw-r--r--chroma/demo/__init__.py13
-rw-r--r--chroma/demo/checkerboard.py19
-rw-r--r--chroma/demo/optics.py6
-rw-r--r--chroma/demo/pmt.py2
4 files changed, 21 insertions, 19 deletions
diff --git a/chroma/demo/__init__.py b/chroma/demo/__init__.py
index edd344a..7df7df7 100644
--- a/chroma/demo/__init__.py
+++ b/chroma/demo/__init__.py
@@ -7,10 +7,10 @@ import numpy.linalg
from chroma.make import sphere
from chroma.stl import mesh_from_stl
from chroma.geometry import *
-from chroma.transform import rotate, make_rotation_matrix
+from chroma.transform import rotate, make_rotation_matrix, normalize
from chroma.demo.pmt import build_8inch_pmt_with_lc
-from chroma.demo.optics import water
+from chroma.demo.optics import water, black_surface
from chroma.demo.checkerboard import build_checkerboard_scene as checkerboard_scene
@@ -24,22 +24,23 @@ def spherical_spiral(radius, spacing):
while t < np.pi:
yield np.array([sin(t) * sin(a*t), sin(t) * cos(a*t), cos(t)])*radius
- dt = spacing / sqrt(1 + a**2 * sin(t) ** 2)
+ dt = dl / sqrt(1 + a**2 * sin(t) ** 2)
t += dt
-def detector(pmt_radius=30.0, sphere_radius=30.5, spiral_step=0.14):
+def detector(pmt_radius=14000.0, sphere_radius=14500.0, spiral_step=350.0):
pmt = build_8inch_pmt_with_lc()
geo = Geometry(water)
geo.add_solid(Solid(sphere(sphere_radius,nsteps=200),
water, water,
+ surface=black_surface,
color=0xBBFFFFFF))
geo.pmtids = []
for position in spherical_spiral(pmt_radius, spiral_step):
- direction = -position/numpy.linalg.norm(position)
+ direction = -normalize(position)
# Orient PMT that starts facing Y axis
y_axis = np.array((0.0,1.0,0.0))
@@ -55,5 +56,5 @@ def detector(pmt_radius=30.0, sphere_radius=30.5, spiral_step=0.14):
return geo
def tiny():
- return detector(1.0, 1.5, 0.4)
+ return detector(2000.0, 2500.0, 700.0)
diff --git a/chroma/demo/checkerboard.py b/chroma/demo/checkerboard.py
index dd2e3e1..801f9da 100644
--- a/chroma/demo/checkerboard.py
+++ b/chroma/demo/checkerboard.py
@@ -6,8 +6,8 @@ from chroma.make import sphere
from chroma.demo.optics import *
def build_checkerboard_scene(checkers_per_side=10, squares_per_checker=50):
- x = np.linspace(-5.0, 5.0, checkers_per_side*squares_per_checker+1)
- y = np.linspace(-5.0, 5.0, checkers_per_side*squares_per_checker+1)
+ x = np.linspace(-5000.0, 5000.0, checkers_per_side*squares_per_checker+1)
+ y = np.linspace(-5000.0, 5000.0, checkers_per_side*squares_per_checker+1)
vertices = np.array(tuple(product(x,y,[0])))
@@ -29,14 +29,15 @@ def build_checkerboard_scene(checkers_per_side=10, squares_per_checker=50):
checkerboard = Solid(checkerboard_mesh, vacuum, vacuum, surface=checkerboard_surface, color=checkerboard_color)
- sphere1 = Solid(sphere(nsteps=512), water, vacuum)
- sphere2 = Solid(sphere(nsteps=512), vacuum, vacuum, surface=shiny_surface)
- sphere3 = Solid(sphere(nsteps=512), vacuum, vacuum, surface=lambertian_surface)
+ sphere1 = Solid(sphere(1000.0, nsteps=512), water, vacuum)
+ sphere2 = Solid(sphere(1000.0, nsteps=512), vacuum, vacuum,
+ surface=shiny_surface)
+ sphere3 = Solid(sphere(1000.0, nsteps=512), vacuum, vacuum, surface=lambertian_surface)
checkerboard_scene = Geometry()
- checkerboard_scene.add_solid(checkerboard, displacement=(0,0,-1.5))
- checkerboard_scene.add_solid(sphere1, displacement=(2.0,-2.0,0))
- checkerboard_scene.add_solid(sphere2, displacement=(-2.0,-2.0,0))
- checkerboard_scene.add_solid(sphere3, displacement=(0.0,2.0,0))
+ checkerboard_scene.add_solid(checkerboard, displacement=(0,0,-1500.0))
+ checkerboard_scene.add_solid(sphere1, displacement=(2000.0,-2000.0,0))
+ checkerboard_scene.add_solid(sphere2, displacement=(-2000.0,-2000.0,0))
+ checkerboard_scene.add_solid(sphere3, displacement=(0.0,2000.0,0))
return checkerboard_scene
diff --git a/chroma/demo/optics.py b/chroma/demo/optics.py
index 2fd34d0..db14032 100644
--- a/chroma/demo/optics.py
+++ b/chroma/demo/optics.py
@@ -51,7 +51,7 @@ r7081hqe_photocathode.set('reflect_diffuse', 1.0 - r7081hqe_photocathode.detect[
glass = Material('glass')
glass.set('refractive_index', 1.49)
glass.absorption_length = \
- np.array([(200, 0.1e-6), (300, 0.1e-6), (330, 1.0), (500, 2.0), (600, 1.0), (770, 0.5), (800, 0.1e-6)])
+ np.array([(200, 0.1e-6), (300, 0.1e-6), (330, 1000.0), (500, 2000.0), (600, 1000.0), (770, 500.0), (800, 0.1e-6)])
glass.set('scattering_length', 1e6)
# From WCSim
@@ -99,7 +99,7 @@ water.set('absorption_length',
11751, 8795.34, 8741.23, 7102.37, 6060.68,
4498.56, 3039.56, 2232.2, 1938, 1811.58,
1610.32, 1338.7, 1095.3, 977.525, 965.258,
- 1082.86, 876.434, 633.723, 389.87, 142.011])[::-1] / 100.0 # reversed, cm->m
+ 1082.86, 876.434, 633.723, 389.87, 142.011])[::-1] * 10.0 # reversed, cm->mm
)
water.set('scattering_length',
@@ -123,5 +123,5 @@ water.set('scattering_length',
3960.210, 3473.413, 3032.937,
2635.746, 2278.907, 1959.588,
1675.064, 1422.710, 1200.004,
- 1004.528, 833.9666, 686.1063])[::-1] / 100.0 * 0.625 # reversed, cm -> m, * magic tuning constant
+ 1004.528, 833.9666, 686.1063])[::-1] * 10.0 * 0.625 # reversed, cm -> mm, * magic tuning constant
)
diff --git a/chroma/demo/pmt.py b/chroma/demo/pmt.py
index 17af87a..9b0953f 100644
--- a/chroma/demo/pmt.py
+++ b/chroma/demo/pmt.py
@@ -5,7 +5,7 @@ from chroma.pmt import build_pmt, build_light_collector_from_file
from chroma.demo.optics import water, glass, vacuum, shiny_surface, r7081hqe_photocathode
def build_8inch_pmt(outer_material=water, nsteps=24):
- return build_pmt(dirname(__file__) + '/sno_pmt.txt', 0.003,
+ return build_pmt(dirname(__file__) + '/sno_pmt.txt', 3.0, # 3 mm
outer_material=outer_material,
glass=glass, vacuum=vacuum,
photocathode_surface=r7081hqe_photocathode,