summaryrefslogtreecommitdiff
path: root/tests/test_rayleigh.py
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-09-02 12:12:38 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-09-02 12:12:38 -0400
commit707ca1b366f11032682cc864ca2848905e6b485c (patch)
treee0e66c498cb29168acb0f8fab8479b12489b2f30 /tests/test_rayleigh.py
parent7e2a7e988031c22898249f3801aa0d3c690bb729 (diff)
downloadchroma-707ca1b366f11032682cc864ca2848905e6b485c.tar.gz
chroma-707ca1b366f11032682cc864ca2848905e6b485c.tar.bz2
chroma-707ca1b366f11032682cc864ca2848905e6b485c.zip
update event structure. break gpu.GPU class into separate smaller independent classes.
Diffstat (limited to 'tests/test_rayleigh.py')
-rw-r--r--tests/test_rayleigh.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/test_rayleigh.py b/tests/test_rayleigh.py
index 4394ada..7e5fc92 100644
--- a/tests/test_rayleigh.py
+++ b/tests/test_rayleigh.py
@@ -13,43 +13,43 @@ ROOT.gROOT.SetBatch(1)
class TestRayleigh(unittest.TestCase):
def setUp(self):
- self.cube = Geometry()
+ self.cube = Geometry(water_wcsim)
self.cube.add_solid(Solid(box(100,100,100), water_wcsim, water_wcsim))
self.cube.pmtids = [0]
- self.sim = Simulation(self.cube, water_wcsim, bvh_bits=4, geant4_processes=0,
+ self.sim = Simulation(self.cube, bvh_bits=4, geant4_processes=0,
use_cache=False)
nphotons = 100000
- positions = np.tile([0,0,0], (nphotons,1)).astype(np.float32)
- directions = np.tile([0,0,1], (nphotons,1)).astype(np.float32)
- polarizations = np.zeros_like(positions)
+ pos = np.tile([0,0,0], (nphotons,1)).astype(np.float32)
+ dir = np.tile([0,0,1], (nphotons,1)).astype(np.float32)
+ pol = np.zeros_like(pos)
phi = np.random.uniform(0, 2*np.pi, nphotons).astype(np.float32)
- polarizations[:,0] = np.cos(phi)
- polarizations[:,1] = np.sin(phi)
- times = np.zeros(nphotons, dtype=np.float32)
+ pol[:,0] = np.cos(phi)
+ pol[:,1] = np.sin(phi)
+ t = np.zeros(nphotons, dtype=np.float32)
wavelengths = np.empty(nphotons, np.float32)
wavelengths.fill(400.0)
- self.photons = Photons(positions=positions, directions=directions, polarizations=polarizations,
- times=times, wavelengths=wavelengths)
+ self.photons = Photons(pos=pos, dir=dir, pol=pol, t=t, wavelengths=wavelengths)
def testAngularDistributionPolarized(self):
# Fully polarized photons
- self.photons.polarizations[:] = [1.0, 0.0, 0.0]
+ self.photons.pol[:] = [1.0, 0.0, 0.0]
- photon_stop = self.sim.propagate_photons(self.photons, max_steps=1)
- aborted = (photon_stop.histories & (1 << 31)) > 0
+ photons_end = self.sim.simulate([self.photons], keep_photons_end=True, max_steps=1).next().photons_end
+ aborted = (photons_end.flags & (1 << 31)) > 0
self.assertFalse(aborted.any())
- # Compute the dot product between initial and final directions
- rayleigh_scatters = (photon_stop.histories & (1 << 4)) > 0
- cos_scatter = (self.photons.directions[rayleigh_scatters] * photon_stop.directions[rayleigh_scatters]).sum(axis=1)
+ # Compute the dot product between initial and final dir
+ rayleigh_scatters = (photons_end.flags & (1 << 4)) > 0
+ cos_scatter = (self.photons.dir[rayleigh_scatters] * photons_end.dir[rayleigh_scatters]).sum(axis=1)
theta_scatter = np.arccos(cos_scatter)
h = histogram.Histogram(bins=100, range=(0, np.pi))
h.fill(theta_scatter)
h = rootify(h)
- # The functional form for polarized light should be (1 + \cos^2 \theta)\sin \theta
- # according to GEANT4 physics reference manual
+ # The functional form for polarized light should be
+ # (1 + \cos^2 \theta)\sin \theta according to GEANT4 physics
+ # reference manual.
f = ROOT.TF1("pol_func", "[0]*(1+cos(x)**2)*sin(x)", 0, np.pi)
h.Fit(f)
self.assertGreater(f.GetProb(), 1e-3)