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 get_all_cells_detailed(mesh,xyz,direction,speed): num_of_steps = len(xyz) time = 0.0 volumes = {} # get the tag handle tag1 = mesh.getTagHandle("vol_id") # get all tets in the mesh set tets = mesh.getEntities(iBase.Type.all,iMesh.Topology.tetrahedron) # loop over the substeps for i in range(0,num_of_steps-1): # find the volid of the origin volid = determine_volid(xyz[i]) xcomp = (xyz[i][0]-xyz[i+1][0])**2 ycomp = (xyz[i][1]-xyz[i+1][1])**2 zcomp = (xyz[i][2]-xyz[i+1][2])**2 dist_lim = sqrt(xcomp+ycomp+zcomp) # now do the rayfire for (vol,dist,surf) in ray_iterator(volid, xyz[i], direction[i],dist_limit=dist_lim): time += dist/speed[i] volumes[vol]=time # now get the tets that have volumes tags int the dictionary return volumes
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)
def get_all_cells(xyz,direction,speed): num_of_steps = len(xyz) time = 0.0 volumes = {} # loop over the substeps for i in range(0,num_of_steps-1): # find the volid of the origin volid = determine_volid(xyz[i]) xcomp = (xyz[i][0]-xyz[i+1][0])**2 ycomp = (xyz[i][1]-xyz[i+1][1])**2 zcomp = (xyz[i][2]-xyz[i+1][2])**2 dist_lim = sqrt(xcomp+ycomp+zcomp) # now do the rayfire for (vol,dist,surf) in ray_iterator(volid, xyz[i], direction[i],dist_limit=dist_lim): time += dist/speed[i] volumes[vol]=time return volumes