def ray_iterator(): from pyne import dagmc dagmc.load(path) start = [-2, 0, 0] startvol = dagmc.find_volume(start) assert_equal(startvol, 3) direction = [1, 0, 0] expected_vols = [2, 3, 1, 4] expected_dists = [1, 2, 3.156921938, 0] for i, (vol, dist, surf) in enumerate(dagmc.ray_iterator(startvol, start, direction)): assert_equal(expected_vols[i], vol) if expected_dists[i] != 0: assert_almost_equal(expected_dists[i], dist) assert_equal(i, 3) for i, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction, dist_limit=4)): assert_equal(expected_vols[i], vol) if expected_dists[i] != 0: assert_almost_equal(expected_dists[i], dist) assert_equal(i, 1)
def ray_iterator(): from pyne import dagmc dagmc.load(path) start = [-2, 0, 0] startvol = dagmc.find_volume(start) direction = [1, 0, 0] expected_vols = [2, 3, 1, 4] expected_dists = [1, 2, 3.156921938, 0] vols1 = [] dists1 = [] surfs1 = [] for i, (vol, dist, surf) in enumerate(dagmc.ray_iterator(startvol, start, direction)): vols1.append(vol) dists1.append(dist) surfs1.append(surf) vols2 = [] dists2 = [] surfs2 = [] for j, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction, dist_limit=4)): vols2.append(vol) dists2.append(dist) surfs2.append(surf) return [startvol, vols1, dists1, surfs1, i, vols2, dists2, surfs2, j]
def ray_iterator(): from pyne import dagmc dagmc.load(path) start = [-2, 0, 0] startvol = dagmc.find_volume(start) assert_equal(startvol, 3) direction = [1, 0, 0] expected_vols = [2, 3, 1, 4] expected_dists = [1, 2, 3.156921938, 0] for i, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction)): assert_equal(expected_vols[i], vol) if expected_dists[i] != 0: assert_almost_equal(expected_dists[i], dist) assert_equal(i, 3) for i, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction, dist_limit=4)): assert_equal(expected_vols[i], vol) if expected_dists[i] != 0: assert_almost_equal(expected_dists[i], dist) assert_equal(i, 1)
def find_volume(): from pyne import dagmc dagmc.load(path) vol1 = dagmc.find_volume([0, 0, 0]) vol2 = dagmc.find_volume([.9, .9, .9]) # boundary case -- point [1,.1,.1] is on surface between vols 2 and 3 # the behavior on boundaries will vary with uvw, but ensure that # only the two volumes the touch the location are ever returned. vols = [] for uvw in [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0)]: vols.append(dagmc.find_volume([1, .1, .1], uvw)) # boundary case-- exiting volume 3 => in volume 3 vol3 = dagmc.find_volume([1, .1, .1], [-1, 0, 0]) vol4 = dagmc.find_volume([1.1, 0, 0]) return [vol1, vol2, vol3, vol4, vols]
def test_find_volume(self): vol = dagmc.find_volume([0, 0, 0]) self.assertEqual(vol, 2) vol = dagmc.find_volume([.9, .9, .9]) self.assertEqual(vol, 2) # boundary case -- point [1,.1,.1] is on surface between vols 2 and 3 # the behavior on boundaries will vary with uvw, but ensure that # only the two volumes the touch the location are ever returned. for uvw in [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0)]: vol = dagmc.find_volume([1, .1, .1], uvw) self.assertTrue(vol in (2, 3)) # boundary case-- exiting volume 3 => in volume 3 vol = dagmc.find_volume([1, .1, .1], [-1, 0, 0]) self.assertEqual(vol, 3) vol = dagmc.find_volume([1.1, 0, 0]) self.assertEqual(vol, 3)
def find_volume(): from pyne import dagmc dagmc.load(path) vol = dagmc.find_volume([0, 0, 0]) assert_equal(vol, 2) vol = dagmc.find_volume([.9, .9, .9]) assert_equal(vol, 2) # boundary case -- point [1,.1,.1] is on surface between vols 2 and 3 # the behavior on boundaries will vary with uvw, but ensure that # only the two volumes the touch the location are ever returned. for uvw in [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0)]: vol = dagmc.find_volume([1, .1, .1], uvw) assert_true(vol in (2, 3)) # boundary case-- exiting volume 3 => in volume 3 vol = dagmc.find_volume([1, .1, .1], [-1, 0, 0]) assert_equal(vol, 3) vol = dagmc.find_volume([1.1, 0, 0]) assert_equal(vol, 3)
def test_ray_iterator(self): start = [-2, 0, 0] startvol = dagmc.find_volume(start) self.assertEqual(startvol, 3) direction = [1, 0, 0] expected_vols = [2, 3, 1, 4] expected_dists = [1, 2, 3.156921938, 0] for i, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction)): self.assertEqual(expected_vols[i], vol) if expected_dists[i] != 0: self.assertAlmostEqual(expected_dists[i], dist) self.assertEqual(i, 3) for i, (vol, dist, surf) in enumerate( dagmc.ray_iterator(startvol, start, direction, dist_limit=4)): self.assertEqual(expected_vols[i], vol) if expected_dists[i] != 0: self.assertAlmostEqual(expected_dists[i], dist) self.assertEqual(i, 1)