Example of a Quadric surface.

Right now, openmc.XCylinder, openmc.YCylinder, openmc.ZCylinder, can be modeled on its axis. To model XCylinder in 45, 135, 225, 315-degree angle openmc uses Quadric surface. Does anyone have an example of how the Quadric surface works? A demo of the behavior is very helpful to understand. This is also true for the Openmc documentation sites. I have an octagon shape surrounding multiple z cylinders. I have x and y cylinders pierced through the octagon and ended up in different z cylinders outer. Now, I want these x and y cylinders in the 45, 135, 225, 315-degree angle (in the inclined sections of the octagon). Attached is the image of my current design and also the Python code. Any example of Quadric surface is also much appreciated. Thank you.

build-xml1.py (7.08 KB)

Since a cylinder is defined as the locus of points that are equidistant from a line, you can use the formula for a line-point distance to derive the equation for a general cylinder. Starting from Eq. 10 from here, let x0 be a point (x,y,z) on the cylinder and x1 and x2 be two points on the line going through the middle of the cylinder. So, for a 45 degree rotated cylinder, you could use x1 = (0,0,0) and x2 = (1,1,0). Expanding out all the terms gives you the following equation: x^2 + y^2 + 2z^2 - 2xy - 2r^2. For a Quadric surface, the corresponding coefficients would be: A=1, B=1, C=2, D=-2, K=-2r^2.

I realize that this is pretty tedious and in practice, you probably don’t want to go through all this math just to figure out what the surface equation is. I went through a derivation for the general case and put together a Python function that will return the cylindrical surface given two points going through the center and a radius. For now, you can copy this function into your script and use it – it should be part of the next release of OpenMC and will be available to you by default then. I’m also going to add a function for generating a plane given three points on the plane (which would have been useful for your octagon!).

Best,
Paul

Hello Dr, Thanks for the explanation of the quadric function. I was able to understand the application and was able to create a demo of 45 angular x cylinder, piercing z cylinder. Below is the code I am using and attached is the figure showing the behavior.

Now, with the python function, you provided above, I believe that function is for calculating the coefficients of a quadric for different x1 and x2? this does not impact on how openmc create quadric. since I can use the “openmc.Quadric” to create the quadric. And if I know the coefficients I should be good to go? Now, with the function I know I can calculate the a,b,c,d,…values for 135 degrees (x1=(0,0,0) and x2=(-1,1,0)) and
225 degrees (x1=(0,0,0) and x2=(-1,-1,0)) and 315 degrees (x1=(0,0,0) and x2=(1,-1,0)) manually. But, I want to put x1 and x2 value on the script and get the output as the a,b,c,d,…values for different xi and x2 value. Can you please guide here on this? Also, I did not understand " For now, you can copy this function into your script and use it – it should be part of the next release of OpenMC and will be available to you by default then." can you please elaborate how. Lastly. I haven’t tried with the octagon surface yet with quadric. I will try and see how things turn out. “I’m also going to add a function for generating a plane given three points on the plane (which would have been useful for your octagon!).” please do. Thanks.

xp1=openmc.XPlane(surface_id=1, x0=0)
yp2=openmc.YPlane(surface_id=2, y0=0)
zp1=openmc.ZPlane(surface_id=3, z0=5)
zp2=openmc.ZPlane(surface_id=4, z0=-5)
zc1=openmc.ZCylinder(surface_id=5, R=1)
zc2=openmc.ZCylinder(surface_id=6, R=1.5)

xyzc1=openmc.Quadric(surface_id=7, a=1, b=1, c=2, d=-2, k=-0.18)

region1 = openmc.Cell(cell_id=1, name=‘cell 3’)
region2 = openmc.Cell(cell_id=2, name=‘cell 2’)
region3 = openmc.Cell(cell_id=3, name=‘cell 3’)

region1.region=(-zp1&+zp2&+zc1&-zc2&+xyzc1&+xp1&+yp2) | (-zp1&+zp2&+zc1&-zc2&-yp2) | (-zp1&+zp2&+zc1&-zc2&-xp1)
region2.region=-zp1&+zp2&-zc1
region3.region=-xyzc1&+xp1&+yp2&-zc2&+zc1

Instantiate ZCylinder surfaces

root = openmc.Universe(universe_id=0, name=‘root universe’)

Register Materials with Cells

region1.fill = SS304
region2.fill = graphite
region3.fill = water

Instantiate Universe

root.add_cells([region1, region2, region3])

Instantiate a Geometry, register the root Universe, and export to XML

geometry = openmc.Geometry(root)
geometry.export_to_xml()

Screen Shot 2019-03-05 at 6.33.38 PM.png

Hello, Dr. I was able to resolve my issue of quadric surface, piercing z cylinder and in an octagon surrounding. Attached is the image of the design. This is generally my reactor design of TRIGA with all the rods and components are inside the center ring, which I already design. I also was able to design an angular beam of different radius. Your python code for calculating the coefficients of quadric was really helpful. I believe openmc documentation website should have at least one sample python code for all type for surfaces, cells, the universe, lattices…etc. design. That will help new learners like me benefit more and people will be more interested to use the platform. And being open source is also a boost for us academics. I am providing the python code of my design, so anyone with a similar problem can benefit from it. Dr. Please look into my design code and see if I am doing anything wrong or there are an easier way. Thank for all your support so far. I really really appreciate your guidance. You are the boss. Thanks.

Screen Shot 2019-03-06 at 11.31.39 AM.png