@@ -301,15 +301,17 @@ def flip_sense(surf):
301301 a , b , c , d , e , f , g , h , j , k = coeffs
302302 surf = openmc .Quadric (surface_id = s ['id' ], a = a , b = b , c = c , d = d , e = e ,
303303 f = f , g = g , h = h , j = j , k = k )
304- elif s ['mnemonic' ] == 'tx' :
304+ elif s ['mnemonic' ] in ( 'tx' , 'ty' , 'tz' ) :
305305 x0 , y0 , z0 , a , b , c = coeffs
306- surf = openmc .XTorus (surface_id = s ['id' ], x0 = x0 , y0 = y0 , z0 = z0 , a = a , b = b , c = c )
307- elif s ['mnemonic' ] == 'ty' :
308- x0 , y0 , z0 , a , b , c = coeffs
309- surf = openmc .YTorus (surface_id = s ['id' ], x0 = x0 , y0 = y0 , z0 = z0 , a = a , b = b , c = c )
310- elif s ['mnemonic' ] == 'tz' :
311- x0 , y0 , z0 , a , b , c = coeffs
312- surf = openmc .ZTorus (surface_id = s ['id' ], x0 = x0 , y0 = y0 , z0 = z0 , a = a , b = b , c = c )
306+ if isclose (a , 0.0 , abs_tol = 1e-12 ) and isclose (b , c ):
307+ warnings .warn (
308+ f"Degenerate torus surface { s ['id' ]} (A=0, B=C) converted "
309+ f"to an openmc.Sphere of radius { b } ."
310+ )
311+ surf = openmc .Sphere (surface_id = s ['id' ], x0 = x0 , y0 = y0 , z0 = z0 , r = b )
312+ else :
313+ cls = getattr (openmc , f"{ s ['mnemonic' ][1 ].upper ()} Torus" )
314+ surf = cls (surface_id = s ['id' ], x0 = x0 , y0 = y0 , z0 = z0 , a = a , b = b , c = c )
313315 elif s ['mnemonic' ] in ('x' , 'y' , 'z' ):
314316 axis = s ['mnemonic' ].upper ()
315317 cls_plane = getattr (openmc , f'{ axis } Plane' )
0 commit comments