@@ -618,3 +618,36 @@ def test_mesh_material_volumes_serialize():
618618 assert new_volumes .by_element (1 ) == [(None , 1.0 )]
619619 assert new_volumes .by_element (2 ) == [(2 , 0.5 ), (1 , 0.5 )]
620620 assert new_volumes .by_element (3 ) == [(2 , 1.0 )]
621+
622+
623+ def test_raytrace_mesh_infinite_loop ():
624+ # Create a model with one large spherical cell
625+ sphere = openmc .Sphere (r = 100 , boundary_type = 'vacuum' )
626+ cell = openmc .Cell (region = - sphere )
627+ model = openmc .Model ()
628+ model .geometry = openmc .Geometry ([cell ])
629+
630+ # Create a regular mesh and associated tally
631+ mesh_surface = openmc .RegularMesh ()
632+ mesh_surface .lower_left = (- 30 , - 30 , 30 )
633+ mesh_surface .upper_right = (30 , 30 , 60 )
634+ mesh_surface .dimension = (1 , 1 , 1 )
635+ reg_filter = openmc .MeshSurfaceFilter (mesh_surface )
636+ mesh_surface_tally = openmc .Tally ()
637+ mesh_surface_tally .filters = [reg_filter ]
638+ mesh_surface_tally .scores = ['current' ]
639+ model .tallies = [mesh_surface_tally ]
640+
641+ # Define a source such that the z position is on a mesh boundary with a very
642+ # small directional cosine in the z direction
643+ polar = openmc .stats .delta_function (1.75e-7 )
644+ azimuthal = openmc .stats .Uniform (0.0 , 2.0 * pi )
645+ model .settings .source = openmc .IndependentSource (
646+ angle = openmc .stats .PolarAzimuthal (polar , azimuthal )
647+ )
648+ model .settings .run_mode = 'fixed source'
649+ model .settings .particles = 10
650+ model .settings .batches = 1
651+
652+ # Run the model; this should not cause an infinite loop
653+ model .run ()
0 commit comments