diff options
author | Andy Mastbaum <mastbaum@hep.upenn.edu> | 2012-05-02 11:05:52 -0400 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:39 -0700 |
commit | ef5645baef14b53ed8ca3d72941c364ef5586e50 (patch) | |
tree | 72b27fbe8b8bbddfd4a99131c5cedfc121f63a2b /test/test_reemission.py | |
parent | 8a4a94466930205826c638a69a3501b6aecd5006 (diff) | |
download | chroma-ef5645baef14b53ed8ca3d72941c364ef5586e50.tar.gz chroma-ef5645baef14b53ed8ca3d72941c364ef5586e50.tar.bz2 chroma-ef5645baef14b53ed8ca3d72941c364ef5586e50.zip |
make bulk reemission isotropic
Diffstat (limited to 'test/test_reemission.py')
-rw-r--r-- | test/test_reemission.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/test/test_reemission.py b/test/test_reemission.py index 4ad5fef..861d412 100644 --- a/test/test_reemission.py +++ b/test/test_reemission.py @@ -19,19 +19,19 @@ class TestReemission(unittest.TestCase): shifting sphere, forcing reemission, and check that the final wavelength distribution matches the wls spectrum. ''' - nphotons = 1000 + nphotons = 1e6 # set up detector -- a sphere of 'scintillator' surrounded by a # detecting sphere scint = Material('scint') scint.set('refractive_index', 1) - scint.set('absorption_length', 1) + scint.set('absorption_length', 1.0) scint.set('scattering_length', 1e7) scint.set('reemission_prob', 1) x = np.arange(0,1000,10) norm = scipy.stats.norm(scale=50, loc=600) - pdf = nphotons * 10 * norm.pdf(x) + pdf = 10 * norm.pdf(x) cdf = norm.cdf(x) scint.reemission_cdf = np.array(zip(x, cdf)) @@ -40,7 +40,7 @@ class TestReemission(unittest.TestCase): world = Geometry(vacuum) world.add_solid(Solid(sphere(1000), vacuum, vacuum, surface=detector)) - world.add_solid(Solid(sphere(100), scint, vacuum)) + world.add_solid(Solid(sphere(500), scint, vacuum)) w = create_geometry_from_obj(world, update_bvh_cache=False) sim = Simulation(w, geant4_processes=0) @@ -62,16 +62,18 @@ class TestReemission(unittest.TestCase): # compare wavelength distribution to scintillator's reemission pdf hist, edges = np.histogram(final_wavelengths, bins=x) - print 'detected', sum(hist), 'of', nphotons, 'photons' + print 'detected', hist.sum(), 'of', nphotons, 'photons' + hist_norm = 1.0 * hist / (1.0 * hist.sum() / 1000) + pdf /= (1.0 * pdf.sum() / 1000) - chi2 = scipy.stats.chisquare(hist, pdf[:-1])[1] + chi2 = scipy.stats.chisquare(hist_norm, pdf[:-1])[1] print 'chi2 =', chi2 # show histogram comparison #plt.figure(1) #width = edges[1] - edges[0] #plt.bar(left=edges, height=pdf, width=width, color='red') - #plt.bar(left=edges[:-1], height=hist, width=width) + #plt.bar(left=edges[:-1], height=hist_norm, width=width) #plt.show() self.assertTrue(chi2 > 0.75) |