TypeError: bad operand type for unary -: 'Intersection'

I am working on a project which requires a hexagonal FA. To make it, I used a hex lattice (for the fuel rods) and openmc.get_hexagonal_prism for the FA structure.
Unfortunately, I had an issue when converting the input file to XML. Since I have no experience using Python, I have explored through several forums but still not sure how to resolve this issue.

I have attached the geometry file and the error message. Looking forward to discussing it.

input (11.4 KB)


Hi Arief,

The object returned by get_hexagonal_prism is a region not a surface. That is, when you call this function, OpenMC will create the six planar surfaces needed and take the intersection of the appropriate half-spaces. Thus, it doesn’t make sense to use the “-” operator on it because it’s not a half-space. If you want to assign the inside of the hexagonal prism to a cell, just use the object returned from get_hexagonal_prism directly. If you want the outside, you should use the complement operator, ~. So, in your case, it would be something like ~FA_01_surf.

Best regards,


I’m having a similar issue with hexagonal surfaces. I’m trying to model a hexagon which contains a hexagonal lattice, but this is then nested in another hexagon. If the ‘hexagonal_prism’ object returns a surface how do I model nested hexagonal prisms?

Best wishes,


@es2517 welcome to the community.

As my previous post above notes, hexagonal_prism does not return a surface object that you can use - and + on as you can with other surfaces. Instead, it returns the region inside the hexagon. If you want the region outside of the hexagon, apply the ~ operator (complement) to the object returned by hexagonal_prism.