# OpenMC Quadric surfaces in different position in Z axis.

**URL:** <https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455>\
**Category:** User Support\
**Created:** [July 8, 2019, 4:43pm UTC](https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455 "2019-07-08T16:43:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shabudarda](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shabudarda/32/497_2.png) [@shabudarda](https://openmc.discourse.group/u/shabudarda)\
**Post date:** [July 8, 2019, 4:43pm UTC](https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455/1 "2019-07-08T16:43:10Z")

</div>

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 = y1_z2 + y2_z1  
cy = -(x1_z2 + x2_z1)  
cz = x1_y2 + x2_y1

a = dy_dy + dz_dz  
b = dx_dx + dz_dz  
c = dx_dx + dy_dy  
d = -2_dx_dy  
e = -2_dy_dz  
f = -2_dx_dz  
g = cy_dz - cz_dy  
h = cz_dx - cx_dz  
j = cx_dy - cy_dx  
k = -(dx_dx + dy_dy + dz\*dz)_r_r  
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 ?

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 8, 2019, 8:51pm UTC](https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455/2 "2019-07-08T20:51:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shabudarda](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shabudarda/32/497_2.png) [@shabudarda](https://openmc.discourse.group/u/shabudarda)\
**Post date:** [July 9, 2019, 12:03am UTC](https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455/3 "2019-07-09T00:03:56Z")

</div>

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](https://openmc.discourse.group/uploads/short-url/dMjpxoSmMANNPIMGSzt4hnmGZ31.py) (4.5 KB)

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 9, 2019, 4:23am UTC](https://openmc.discourse.group/t/openmc-quadric-surfaces-in-different-position-in-z-axis/455/4 "2019-07-09T04:23:11Z")

</div>

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

cx = y1_z2 - y2_z1  
cy = x2_z1 - x1_z2  
cz = x1_y2 - x2_y1

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
