Periodic Boundary Conditions

Hi all,

I recently updated OpenMC to v0.12.1 and my input file that previously worked is now throwing an error for periodic boundary conditions. The error is:

libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: Rotational periodic BCs are only supported for rotations about the origin, but surface 4 does not intersect the origin.

I have attached a minimal working example.
test.py (2.0 KB)
My geometry is a hexagonal fuel assembly with periodic boundary conditions.


I read in the documentation that "If both planes have the same normal vector, a translational
periodicity is assumed; rotational periodicity is assumed otherwise. " I’m not sure why OpenMC does not recognize the paired surfaces as having the same normal vector. Any ideas to why this is happening?

Best,
Gwen

Thanks for reporting this @gwenchee. It looks like when we expanded boundary conditions in our latest release, we messed up this particular case. Right now it only works for general planes (Ax + By + Cy = D) if you have √(A² + B² + C²) = 1. A workaround for your particular case then is as follows:

def plane(m, x, y, bc="transmission"):
    norm = np.sqrt(1 + m*m)
    return openmc.Plane(a=-m/norm, b=1/norm, d=(-m * x + y)/norm, boundary_type=bc)

I’ll get a proper fix submitted today so that this is not an issue in the future.

By the way, you may be interested in the openmc.model.hexagonal_prism function that makes it much easier to create geometries with hexagonal prisms in them!

Fix has been submitted for review.

Thank you for the fix!

Hey Paul,

I might have found another issue with the periodic boundary conditions for translational planes. I set up a cube with x-y periodicity and the simulation runs for v0.12.0 but throws this error for v0.12.1 and v0.12.2:

ERROR: Found at least three periodic surfaces without a specified partner. Please specify the partner for each periodic surface.

This occurs when I define the translational periodic planes with openmc.XPlane and openmc.YPlane, and then with openmc.Plane. I have attached the simple minimal working examples.
test.py (1.2 KB)
test3.py (1.2 KB)

Best,
Gwen

@gwenchee I would say this is actually by design. Now that OpenMC has the ability to do both translational and rotationally periodic boundary conditions, If you have two x-planes and y-planes that are specified as periodic, it’s not clear which pairs of planes should be periodic with respect to one another. To explicitly set pairs of planes as being periodic, you can add the following to your code:

x_right.periodic_surface = x_left
y_bot.periodic_surface = y_top

@paulromano I explicitly defined the pairs of planes, yet still, get the error. This is how I defined the surfaces in test.py:

x_left = +openmc.XPlane(x0=0, boundary_type="periodic")

x_right = -openmc.XPlane(x0=5, boundary_type="periodic")

y_top = -openmc.YPlane(y0=5, boundary_type="periodic")

y_bot = +openmc.YPlane(y0=0, boundary_type="periodic")

x_left.periodic_surface = x_right

y_top.periodic_surface = y_bot

z_top = -openmc.ZPlane(z0=5, boundary_type="reflective")

z_bot = +openmc.ZPlane(z0=0, boundary_type="reflective")

The error only occurs from v0.12.1 onwards.

The periodic_surface attribute has to be set on a Surface object, whereas you are trying to apply it to a region (the result of taking the unary + or - operator on a surface). So you should have:

x_left = openmc.XPlane(...)
x_right = openmc.XPlane(...)
y_top = openmc.YPlane(...)
y_bot = openmc.YPlane(...)
x_left.periodic_surface = x_right
y_top.periodic_surface = y_top

...
region = +x_left & -x_right & ...

Ah I see, I totally missed that. Thanks, Paul!

Gwen