def test_tracing(self): simulation = self.simulation bead = self.bead report = simulation.run() self.plot_bead() plot_traces(report["rays"]["rays"]) axis("equal") show()
def test_tracing(self): simulation = self.simulation # modify the base setup a bit for this test simulation.source = AngleSpanSource(5, Ray=Trace) simulation.setup.append(RayDetector("rays")) report = simulation.run() plot_traces(report["rays"]["rays"]) show()
def test_known_ray(self): simulation = self.simulation bead = self.bead offset = bead.radius / 2.0 source = SingleRaySource(offset, 0, Ray=Trace) simulation.source = source a = bead.radius x_i = offset z_i = self.pre_space + a - np.sqrt(a ** 2 - offset ** 2) th_i = atan(x_i / a) th_r = atan(bead.n_surround / bead.n_bead * sin(th_i)) pathlength_in_bead = 2 * a * cos(th_r) beta = th_i - th_r x_e = x_i - pathlength_in_bead * sin(beta) z_e = z_i + pathlength_in_bead * cos(beta) x_theoretical = array( [ offset, # starting place offset, # hit first plane of the bead object x_i, # interset bead x_e, # exit bead # should add the last one here once I calculate it ] ) z_theoretical = array([0, self.pre_space, z_i, z_e]) report = simulation.run() locations = report["rays"]["rays"][0].locations if PLOTTING: self.plot_bead() plot_traces(report["rays"]["rays"]) plot(z_theoretical, x_theoretical, "r") show() self.assertEqual(locations[0], (x_theoretical[0], z_theoretical[0])) self.assertEqual(locations[1], (x_theoretical[1], z_theoretical[1])) self.assertEqual(locations[2], (x_theoretical[2], z_theoretical[2])) self.assertEqual(locations[3], (x_theoretical[3], z_theoretical[3]))