OpenMC Quadric surfaces in different position in Z axis.

Hello, Using the below code I can generate a 45 degree rotated cylinder coefficients for Quadric surfaces.

x1, y1, z1 = (0,0,0)x2, y2, z2 = (1,1,0)
r = 30

dx = x2 - x1
dy = y2 - y1
dz = z2 - z1
cx = y1z2 + y2z1
cy = -(x1z2 + x2z1)
cz = x1y2 + x2y1

a = dydy + dzdz
b = dxdx + dzdz
c = dxdx + dydy
d = -2dxdy
e = -2dydz
f = -2dxdz
g = cydz - czdy
h = czdx - cxdz
j = cxdy - cydx
k = -(dxdx + dydy + dz*dz)rr
print(a,b,c,d,e,f,g,h,j,k)

Now, this cylinder is in the origin. Now if I want to create the same cylinder in different position of z-axis, Say if I use x1, y1, z1 = (0,0,-5)
x2, y2, z2 = (1,1,-5)

I have a=1 b=1 c=2 d=-2 j=-10 k=-1800

Now If I create a quadric surface like

xyzc1=openmc.Quadric(surface_id=5005, a=1, b=1, c=2, d=-2, j=-10, k=-1800)

I see overlap of cells error? How to do this ?

Hi Sharif,

If r=30 really is your radius, then it seems clear to me the two cylinders would overlap if one is at z=0 and one is at z=-5. You would need a radius of r=2.5 or less for them to not overlap in this case (if I’m understanding it correctly).

Best,
Paul

Hello, Attached is a python script that demonstrates the behavior. I have four angular cylinders in 45, 135, 225, 315 and one cylinder all have radius 30. Now, with the above quadric function, I generate the four cylinders as with a z1 and z2 of -265.1535

xyzc1=openmc.Quadric(surface_id=8, a=1, b=1, c=2, d=-2, j=-530.307, k=-1800)
xyzc2=openmc.Quadric(surface_id=9, a=1, b=1, c=2, d=2, j=-530.307, k=-1800)
xyzc3=openmc.Quadric(surface_id=10, a=1, b=1, c=2, d=-2, j=-530.307, k=-1800)
xyzc4=openmc.Quadric(surface_id=11, a=1, b=1, c=2, d=2, j=-530.307, k=-1800)

Also, the x-cylinder z origin is also -265.1535, Now, when plotting, On xy(plot-1) basis and (0,0,-265.1535) only the x-cylinder shows up. Also, in the other plot, seems to show wrong info. Now, if I put the “j” values of the angular cylinder to positive(530.307) instead of (-530.307). Plot-1 seems to show all the cylinders, but other plot shows cell overlap.

Now, this whole mess is gone if I don’t use any z origin as -265.1535 in the angular cylinders. If the origin in (0,0,0), there is no j in the quadric surfaces. Then all the plots seem to show the right info.

So, my query is how do I generate angular cylinder in different position of z instead of the 0.

build-xml1.py (4.5 KB)

It looks like there was an error in the equations for determining the cylinder. It should be:

cx = y1z2 - y2z1
cy = x2z1 - x1z2
cz = x1y2 - x2y1

I’m going to submit a fix for this in OpenMC for the openmc.model.cylinder_from_points function, which uses this derivation. In the meantime, try using this to see if it fixes your problem.

Best,
Paul